From fb96141dda72d1ae351ad47d160f70d284db62c4 Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Thu, 28 Mar 2019 22:37:24 +0200 Subject: [PATCH 01/10] MXS-2243_labels Maxscale system tests prepare environment by themselves maxscale-system-test changed in order to control test environment by itself. Every test checks which machines are running, compare with list of needed machines and start new VMs is they are missing in the running machines list. Tests are executiong MDBCI commands, MDBCI executable should be in the PATH --- maxscale-system-test/CMakeLists.txt | 100 +-- maxscale-system-test/big_load.cpp | 2 +- maxscale-system-test/big_load.h | 6 +- maxscale-system-test/big_transaction.h | 5 +- maxscale-system-test/binary_ps.cpp | 2 +- maxscale-system-test/blob_test.h | 5 +- maxscale-system-test/bug488.cpp | 4 +- maxscale-system-test/bug509.cpp | 3 +- maxscale-system-test/bug561.sh | 20 +- maxscale-system-test/bug562.sh | 16 +- maxscale-system-test/bug564.sh | 21 +- maxscale-system-test/bug567.sh | 19 +- maxscale-system-test/bug670_sql.h | 5 +- maxscale-system-test/cache_basic.sh | 49 +- .../cdc_datatypes/CMakeLists.txt | 2 +- maxscale-system-test/change_user.cpp | 6 +- maxscale-system-test/check_backend.cpp | 35 +- maxscale-system-test/copy_logs.sh | 13 +- maxscale-system-test/different_size.h | 5 +- maxscale-system-test/envv.cpp | 61 ++ maxscale-system-test/envv.h | 30 + maxscale-system-test/execute_cmd.h | 5 +- maxscale-system-test/failover_common.cpp | 2 +- maxscale-system-test/fw_copy_rules.h | 5 +- maxscale-system-test/get_com_select_insert.h | 6 +- maxscale-system-test/get_my_ip.cpp | 4 +- maxscale-system-test/get_my_ip.h | 5 +- maxscale-system-test/insertstream.sh | 4 - maxscale-system-test/keepalived_func.h | 5 +- .../keepalived_masterdown.cpp | 28 +- maxscale-system-test/labels_table.cpp | 20 + maxscale-system-test/labels_table.h | 29 + maxscale-system-test/long_test.cpp | 98 +-- maxscale-system-test/lots_of_rows.cpp | 2 +- maxscale-system-test/mariadb_func.h | 9 +- maxscale-system-test/mariadb_nodes.cpp | 90 +-- maxscale-system-test/mariadb_nodes.h | 30 +- maxscale-system-test/mariadb_tests_hartmut.sh | 10 +- .../masking_mysqltest_driver.sh | 46 +- maxscale-system-test/masking_user.sh | 46 +- maxscale-system-test/maxadmin_operations.cpp | 2 +- maxscale-system-test/maxadmin_operations.h | 6 +- maxscale-system-test/maxinfo_func.h | 6 +- maxscale-system-test/maxpython.py | 32 +- maxscale-system-test/maxscales.cpp | 83 +-- maxscale-system-test/maxscales.h | 25 +- maxscale-system-test/mdbci/README.md | 79 +-- maxscale-system-test/mdbci/copy_logs.sh | 4 +- maxscale-system-test/mdbci/create_config.sh | 13 +- maxscale-system-test/mdbci/run_test.sh | 79 +-- .../mdbci/run_test_snapshot.sh | 40 +- maxscale-system-test/mdbci/set_env.sh | 87 +-- .../mdbci/set_run_test_variables.sh | 22 +- .../mdbci/templates/big.json.template | 41 +- .../mdbci/templates/big15.json.template | 62 +- .../mdbci/templates/default.json.template | 30 + .../mdbci/templates/nogalera.json.template | 66 -- .../mdbci/templates/onemaxscale.json.template | 118 ---- .../templates/twomaxscales.json.template | 78 --- maxscale-system-test/mxs1776_ps_exec_hang.cpp | 36 +- maxscale-system-test/mxs1804_long_ps_hang.cpp | 2 +- .../mxs2043_select_for_update.cpp | 2 +- maxscale-system-test/mxs2106_avro_null.cpp | 30 +- maxscale-system-test/mxs2111_auth_string.cpp | 2 +- .../mxs244_prepared_stmt_loop.cpp | 1 - .../mxs37_table_privilege.cpp | 9 +- maxscale-system-test/mxs585.py | 2 +- maxscale-system-test/mxs682_cyrillic.cpp | 15 +- maxscale-system-test/mxs791.sh | 10 +- maxscale-system-test/mxs791_base.sh | 12 +- maxscale-system-test/mxs791_galera.sh | 17 - .../mysqlmon_failover_manual.cpp | 2 +- maxscale-system-test/mysqlmon_rejoin_bad.cpp | 2 +- maxscale-system-test/mysqlmon_rejoin_good.cpp | 2 +- .../mysqlmon_rejoin_manual.cpp | 4 +- .../mysqlmon_rejoin_manual2.cpp | 10 +- maxscale-system-test/mysqltest_driver.sh | 17 +- maxscale-system-test/nodes.cpp | 233 +++---- maxscale-system-test/nodes.h | 47 +- maxscale-system-test/non_native_setup.cpp | 17 +- maxscale-system-test/pers_02.cpp | 2 +- maxscale-system-test/proxy_protocol.cpp | 6 +- maxscale-system-test/rds_vpc.cpp | 6 +- maxscale-system-test/rds_vpc.h | 5 +- maxscale-system-test/run_ctrl_c.sh | 27 +- maxscale-system-test/run_session_hang.sh | 24 +- maxscale-system-test/script.cpp | 2 +- .../session_hang/run_setmix.sh | 3 +- maxscale-system-test/sql_t1.h | 5 +- maxscale-system-test/sysbench_commands.h | 18 +- maxscale-system-test/templates.h.in | 3 +- maxscale-system-test/test_binlog_fnc.cpp | 8 +- maxscale-system-test/test_binlog_fnc.h | 5 +- .../test_ctrl_c/start_killer.sh | 2 +- .../test_ctrl_c/test_ctrl_c.sh | 4 +- maxscale-system-test/testconnections.cpp | 598 ++++++++++++------ maxscale-system-test/testconnections.h | 118 +++- maxscale-system-test/utilities.cmake | 20 +- 98 files changed, 1394 insertions(+), 1660 deletions(-) create mode 100644 maxscale-system-test/envv.cpp create mode 100644 maxscale-system-test/envv.h create mode 100644 maxscale-system-test/labels_table.cpp create mode 100644 maxscale-system-test/labels_table.h delete mode 100644 maxscale-system-test/mdbci/templates/nogalera.json.template delete mode 100644 maxscale-system-test/mdbci/templates/onemaxscale.json.template delete mode 100644 maxscale-system-test/mdbci/templates/twomaxscales.json.template delete mode 100755 maxscale-system-test/mxs791_galera.sh diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index a1d63a75c..7d25204ed 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -36,7 +36,7 @@ add_library(testcore SHARED testconnections.cpp nodes.cpp mariadb_nodes.cpp maxs mariadb_func.cpp get_com_select_insert.cpp maxadmin_operations.cpp big_transaction.cpp sql_t1.cpp test_binlog_fnc.cpp get_my_ip.cpp big_load.cpp get_com_select_insert.cpp different_size.cpp fw_copy_rules maxinfo_func.cpp config_operations.cpp rds_vpc.cpp execute_cmd.cpp - blob_test.cpp keepalived_func.cpp tcp_connection.cpp + blob_test.cpp keepalived_func.cpp tcp_connection.cpp labels_table.cpp envv.cpp # Include the CDC connector in the core library ${CMAKE_SOURCE_DIR}/../connectors/cdc-connector/cdc_connector.cpp) target_link_libraries(testcore ${MYSQL_CLIENT} ${JANSSON_LIBRARIES} z m pthread ssl dl rt crypto crypt) @@ -47,21 +47,21 @@ add_dependencies(testcore connector-c jansson) include_directories(${CMAKE_SOURCE_DIR}/../connectors/cdc-connector/) # Tool used to check backend state -add_test_executable_notest(check_backend.cpp check_backend check_backend LABELS CONFIG) +add_test_executable_notest(check_backend.cpp check_backend check_backend LABELS CONFIG REPL_BACKEND GALERA_BACKEND TWO_MAXSCALES) # Configuration tests -add_template(bug359 bug359) -add_template(bug495 bug495) -add_template(bug526 bug526) -add_template(bug479 bug479) -add_template(bug493 bug493) -add_template(bug643_1 bug643_1) -add_template(mxs652_bad_ssl bad_ssl) -add_template(mxs710_bad_socket mxs710_bad_socket) -add_template(mxs710_bad_socket mxs711_two_ports) -add_template(mxs720_line_with_no_equal mxs720_line_with_no_equal) -add_template(mxs720_wierd_line mxs720_wierd_line) -add_template(mxs710_bad_socket mxs799) +add_template_manual(bug359 bug359) +add_template_manual(bug495 bug495) +add_template_manual(bug526 bug526) +add_template_manual(bug479 bug479) +add_template_manual(bug493 bug493) +add_template_manual(bug643_1 bug643_1) +add_template_manual(mxs652_bad_ssl bad_ssl) +add_template_manual(mxs710_bad_socket mxs710_bad_socket) +add_template_manual(mxs710_bad_socket mxs711_two_ports) +add_template_manual(mxs720_line_with_no_equal mxs720_line_with_no_equal) +add_template_manual(mxs720_wierd_line mxs720_wierd_line) +add_template_manual(mxs710_bad_socket mxs799) add_test_executable(config_test.cpp config_test replication LABELS CONFIG) add_subdirectory(cdc_datatypes) @@ -181,7 +181,7 @@ add_test_executable(bug658.cpp bug658 replication LABELS readwritesplit readconn add_test_executable(bug662.cpp bug662 bug662 LABELS readwritesplit readconnroute maxscale REPL_BACKEND) # Bad TEE filter configuration -add_test_executable(bug664.cpp bug664 bug664 LABELS MySQLAuth MySQLProtocol) +add_test_executable(bug664.cpp bug664 bug664 LABELS MySQLAuth MySQLProtocol REPL_BACKEND) # TEE fileter: execute long sequence of queries ans session commands in the loop #add_test_executable(bug670.cpp bug670 bug670 LABELS tee REPL_BACKEND) @@ -319,7 +319,7 @@ add_test_executable(galera_priority.cpp galera_priority galera_priority LABELS g add_test_executable(kill_master.cpp kill_master replication LABELS readwritesplit LIGHT REPL_BACKEND) # Test insertstream filter -add_test_script(insertstream insertstream.sh insertstream LABELS insertstream REPL_BACKEND) +add_test_script(insertstream.sh insertstream.sh insertstream LABELS insertstream REPL_BACKEND) # Check load balancing add_test_executable(load_balancing.cpp load_balancing load LABELS readwritesplit LIGHT REPL_BACKEND) @@ -343,7 +343,7 @@ add_test_derived(load_balancing_pers10 load_balancing load_pers10 LABELS readwri add_test_executable(longblob.cpp longblob longblob LABELS readwritesplit readconnroute UNSTABLE HEAVY REPL_BACKEND) # Test with extremely big blob inserting/selecting with > 16 mb data blocks -add_test_executable(mxs1110_16mb.cpp mxs1110_16mb longblob_filters LABELS readwritesplit readconnroute HEAVY REPL_BACKEND) +add_test_executable(mxs1110_16mb.cpp mxs1110_16mb longblob_filters LABELS readwritesplit readconnroute HEAVY REPL_BACKEND GALERA_BACKEND) # Schemarouter implicit database detection add_test_executable(mxs1310_implicit_db.cpp mxs1310_implicit_db mxs1310_implicit_db LABELS schemarouter REPL_BACKEND) @@ -356,10 +356,10 @@ add_test_executable(mxs1323_stress.cpp mxs1323_stress mxs1323 LABELS readwritesp add_test_executable(lots_of_rows.cpp lots_of_rows galera LABELS readwritesplit HEAVY GALERA_BACKEND) # A set of MariaDB server tests executed against Maxscale RWSplit -add_test_script(mariadb_tests_hartmut mariadb_tests_hartmut.sh replication LABELS readwritesplit REPL_BACKEND) +add_test_script(mariadb_tests_hartmut.sh mariadb_tests_hartmut.sh replication LABELS readwritesplit REPL_BACKEND) # A set of MariaDB server tests executed against Maxscale RWSplit (Galera backend) -add_test_script(mariadb_tests_hartmut_galera mariadb_tests_hartmut.sh galera_hartmut LABELS readwritesplit GALERA_BACKEND) +add_test_script(mariadb_tests_hartmut_galera.sh mariadb_tests_hartmut.sh galera_hartmut LABELS readwritesplit GALERA_BACKEND) # Creates a number of connections > max_connections setting add_test_executable(max_connections.cpp max_connections replication LABELS MySQLAuth MySQLProtocol UNSTABLE HEAVY REPL_BACKEND) @@ -377,7 +377,7 @@ add_test_script(maxinfo.py maxinfo.py maxinfo LABELS maxinfo LIGHT REPL_BACKEND) add_test_executable(maxscale_process_user.cpp maxscale_process_user replication LABELS maxscale LIGHT REPL_BACKEND) # Test of multi master monitor -add_test_executable(mm.cpp mm mm LABELS mmmon BREAKS_REPL) +add_test_executable(mm.cpp mm mm LABELS mmmon BREAKS_REPL REPL_BACKEND) # MySQL Monitor with Multi-master configurations add_test_executable(mm_mysqlmon.cpp mm_mysqlmon mm_mysqlmon LABELS mysqlmon REPL_BACKEND BREAKS_REPL) @@ -408,7 +408,7 @@ add_test_executable(binary_ps_cursor.cpp binary_ps_cursor replication LABELS rea add_test_executable(mxs321.cpp mxs321 replication LABELS maxscale REPL_BACKEND) # Crash with Galera and backend restart when persistant cfonnections are in use -add_test_derived(mxs361 pers_02 mxs361 mxs361 LABELS maxscale GALERA_BACKEND) +add_test_derived(mxs361 pers_02 mxs361 mxs361 LABELS maxscale REPL_BACKEND GALERA_BACKEND) # Load huge file with 'LOAD DATA LOCAL INFILE' add_test_executable(mxs365.cpp mxs365 replication LABELS readwritesplit REPL_BACKEND) @@ -469,7 +469,7 @@ add_test_executable(mxs729_maxadmin.cpp mxs729_maxadmin replication LABELS MaxAd add_test_script(mxs791.sh mxs791.sh replication LABELS UNSTABLE HEAVY REPL_BACKEND) # Simple connect test in bash, checks that defined in cmd line DB is selected (Galera backend) -add_test_script(mxs791_galera.sh mxs791_galera.sh galera LABELS UNSTABLE HEAVY GALERA_BACKEND) +add_test_script(mxs791_galera.sh mxs791.sh galera LABELS UNSTABLE HEAVY GALERA_BACKEND) # Checks "Current no. of conns" maxadmin output after long blob inserting add_test_executable(mxs812_1.cpp mxs812_1 longblob LABELS readwritesplit REPL_BACKEND) @@ -534,7 +534,7 @@ add_test_executable(mxs951_utfmb4.cpp mxs951_utfmb4 replication LABELS REPL_BACK add_test_executable(mxs957.cpp mxs957 replication LABELS readwritesplit REPL_BACKEND) # Proxy protocol test -add_test_executable(proxy_protocol.cpp proxy_protocol proxy_protocol LABELS MySQLAuth MySQLProtocol) +add_test_executable(proxy_protocol.cpp proxy_protocol proxy_protocol LABELS MySQLAuth MySQLProtocol REPL_BACKEND) # Regression case for the bug "Defunct processes after maxscale have executed script during failover" add_test_executable(mxs1045.cpp mxs1045 mxs1045 LABELS maxscale REPL_BACKEND) @@ -595,7 +595,7 @@ add_test_executable(mxs1543.cpp mxs1543 avro LABELS REPL_BACKEND) # MXS-1585: Crash in MaxScale 2.1.12 # https://jira.mariadb.org/browse/MXS-1585 -add_test_executable(mxs1585.cpp mxs1585 mxs1585 LABELS REPL_BACKEND) +add_test_executable(mxs1585.cpp mxs1585 mxs1585 LABELS GALERA_BACKEND) # MXS-1643: Too many monitor events are triggered # https://jira.mariadb.org/browse/MXS-1643 @@ -747,13 +747,13 @@ add_test_executable(rwsplit_read_only_trx.cpp rwsplit_read_only_trx rwsplit_read add_test_executable(schemarouter_duplicate_db.cpp schemarouter_duplicate_db schemarouter_duplicate_db LABELS schemarouter REPL_BACKEND) # Test of external script execution -add_test_executable(script.cpp script script LABELS maxscale REPL_BACKEND) +add_test_executable(script.cpp script script LABELS maxscale REPL_BACKEND GALERA_BACKEND) # Test 10.3 SEQUENCE objects -add_test_executable(sequence.cpp sequence replication LABELS LIGHT) +add_test_executable(sequence.cpp sequence replication LABELS LIGHT REPL_BACKEND) # Test 10.1 compound statements -add_test_executable(compound_statement.cpp compound_statement replication LABELS LIGHT) +add_test_executable(compound_statement.cpp compound_statement replication LABELS LIGHT REPL_BACKEND) # Check if 'weightby' parameter works add_test_executable(server_weight.cpp server_weight galera.weight LABELS readwritesplit readconnroute LIGHT GALERA_BACKEND) @@ -762,10 +762,10 @@ add_test_executable(server_weight.cpp server_weight galera.weight LABELS readwri add_test_executable(session_limits.cpp session_limits session_limits LABELS readwritesplit REPL_BACKEND) # Test of schema router -add_test_executable(sharding.cpp sharding sharding LABELS schemarouter BREAKS_REPL) +add_test_executable(sharding.cpp sharding sharding LABELS schemarouter BREAKS_REPL REPL_BACKEND) # MXS-1160: LOAD DATA LOCAL INFILE with schemarouter -add_test_executable(sharding_load_data.cpp sharding_load_data sharding LABELS schemarouter BREAKS_REPL) +add_test_executable(sharding_load_data.cpp sharding_load_data sharding LABELS schemarouter BREAKS_REPL REPL_BACKEND) # Do short sessions (open conn, short query, close conn) in the loop add_test_executable(short_sessions.cpp short_sessions replication LABELS readwritesplit readconnroute REPL_BACKEND) @@ -774,7 +774,7 @@ add_test_executable(short_sessions.cpp short_sessions replication LABELS readwri add_test_derived(short_sessions_ssl short_sessions ssl LABELS readwritesplit readconnroute REPL_BACKEND) # Regression case for crash if maxadmin 'show monitors' command is issued, but no monitor is not running -add_test_executable(show_monitor_crash.cpp show_monitor_crash show_monitor_crash LABELS maxscale) +add_test_executable(show_monitor_crash.cpp show_monitor_crash show_monitor_crash LABELS maxscale REPL_BACKEND) # Check how Maxscale works in case of one slave failure, only one slave is configured add_test_executable(slave_failover.cpp slave_failover replication.one_slave LABELS readwritesplit REPL_BACKEND) @@ -819,32 +819,32 @@ add_test_executable(test_hints.cpp test_hints hints2 LABELS hintfilter LIGHT REP # add_test_executable(test_maxctrl.cpp test_maxctrl maxctrl LABELS REPL_BACKEND) # Binlogrouter tests, these heavily alter the replication so they are run last -add_test_executable(avro.cpp avro avro LABELS avrorouter binlogrouter LIGHT BREAKS_REPL) -add_test_executable(avro_alter.cpp avro_alter avro LABELS avrorouter binlogrouter LIGHT BREAKS_REPL) +add_test_executable(avro.cpp avro avro LABELS avrorouter binlogrouter LIGHT BREAKS_REPL REPL_BACKEND) +add_test_executable(avro_alter.cpp avro_alter avro LABELS avrorouter binlogrouter LIGHT BREAKS_REPL REPL_BACKEND) # Test avrorouter file compression -#add_test_script(avro_compression avro avro_compression LABELS avrorouter binlogrouter LIGHT BREAKS_REPL) +#add_test_script(avro_compression avro avro_compression LABELS avrorouter binlogrouter LIGHT BREAKS_REPL REPL_BACKEND) # In the binlog router setup stop Master and promote one of the Slaves to be new Master -add_test_executable(binlog_change_master.cpp binlog_change_master setup_binlog_tx_safe LABELS binlogrouter BREAKS_REPL) +add_test_executable(binlog_change_master.cpp binlog_change_master setup_binlog_tx_safe LABELS binlogrouter BREAKS_REPL REPL_BACKEND) # In the binlog router setup stop Master and promote one of the Slaves to be new Master (use GTID) -add_test_executable(binlog_change_master.cpp binlog_change_master_gtid setup_binlog_tx_safe_gtid LABELS binlogrouter BREAKS_REPL) +add_test_executable(binlog_change_master.cpp binlog_change_master_gtid setup_binlog_tx_safe_gtid LABELS binlogrouter BREAKS_REPL REPL_BACKEND) # trying to start binlog setup with incomplete Maxscale.cnf -add_test_executable(binlog_incompl.cpp binlog_incompl binlog_incompl LABELS binlogrouter BREAKS_REPL) +add_test_executable(binlog_incompl.cpp binlog_incompl binlog_incompl LABELS binlogrouter BREAKS_REPL REPL_BACKEND) # configure binlog router setup, execute queries and transactions, check data; install semysync plugin, router options semisync=1,transaction_safety=1 -add_test_executable(binlog_semisync.cpp binlog_semisync setup_binlog_semisync LABELS binlogrouter HEAVY BREAKS_REPL) +add_test_executable(binlog_semisync.cpp binlog_semisync setup_binlog_semisync LABELS binlogrouter HEAVY BREAKS_REPL REPL_BACKEND) # configure binlog router setup, execute queries and transactions, check data; install semysync plugin, router options semisync=0,transaction_safety=0 -add_test_derived(binlog_semisync_txs0_ss0 binlog_semisync setup_binlog_semisync_txs0_ss0 LABELS binlogrouter HEAVY BREAKS_REPL) +add_test_derived(binlog_semisync_txs0_ss0 binlog_semisync setup_binlog_semisync_txs0_ss0 LABELS binlogrouter HEAVY BREAKS_REPL REPL_BACKEND) # configure binlog router setup, execute queries and transactions, check data; install semysync plugin, router options semisync=0,transaction_safety=1 -add_test_derived(binlog_semisync_txs0_ss1 binlog_semisync setup_binlog_semisync_txs0_ss1 LABELS binlogrouter HEAVY BREAKS_REPL) +add_test_derived(binlog_semisync_txs0_ss1 binlog_semisync setup_binlog_semisync_txs0_ss1 LABELS binlogrouter HEAVY BREAKS_REPL REPL_BACKEND) # configure binlog router setup, execute queries and transactions, check data; install semysync plugin, router options semisync=1,transaction_safety=0 -add_test_derived(binlog_semisync_txs1_ss0 binlog_semisync setup_binlog_semisync_txs1_ss0 LABELS binlogrouter HEAVY BREAKS_REPL) +add_test_derived(binlog_semisync_txs1_ss0 binlog_semisync setup_binlog_semisync_txs1_ss0 LABELS binlogrouter HEAVY BREAKS_REPL REPL_BACKEND) set_tests_properties(binlog_semisync PROPERTIES TIMEOUT 3600) set_tests_properties(binlog_semisync_txs0_ss0 PROPERTIES TIMEOUT 3600) @@ -855,38 +855,38 @@ set_tests_properties(binlog_semisync_txs1_ss0 PROPERTIES TIMEOUT 3600) # The encryption tests don't work as they require the file key management plugin # # Binlog encription test (aes_cbr encryption) -#add_test_executable(mxs1073_binlog_enc.cpp mxs1073_binlog_enc binlog_enc_aes_cbc LABELS binlogrouter 10.1 BREAKS_REPL) +#add_test_executable(mxs1073_binlog_enc.cpp mxs1073_binlog_enc binlog_enc_aes_cbc LABELS binlogrouter 10.1 BREAKS_REPL REPL_BACKEND) # Binlog encription test (aes_ctr encryption) -#add_test_script(mxs1073_binlog_enc_aes_ctr mxs1073_binlog_enc binlog_enc_aes_ctr LABELS binlogrouter 10.1 BREAKS_REPL) +#add_test_script(mxs1073_binlog_enc_aes_ctr mxs1073_binlog_enc binlog_enc_aes_ctr LABELS binlogrouter 10.1 BREAKS_REPL REPL_BACKEND) # Test of CDC protocol (avro listener) -add_test_executable(cdc_client.cpp cdc_client avro LABELS avrorouter binlogrouter BREAKS_REPL) +add_test_executable(cdc_client.cpp cdc_client avro LABELS avrorouter binlogrouter BREAKS_REPL REPL_BACKEND) # Tries INSERTs with size close to 0x0ffffff * N (with binlog backend) -add_test_executable(different_size_binlog.cpp different_size_binlog setup_binlog LABELS binlogrouter HEAVY BREAKS_REPL) +add_test_executable(different_size_binlog.cpp different_size_binlog setup_binlog LABELS binlogrouter HEAVY BREAKS_REPL REPL_BACKEND) # Try to configure binlog router to use wrong password for Master and check 'slave status' on binlog -add_test_executable(mxs781_binlog_wrong_passwrd.cpp mxs781_binlog_wrong_passwrd setup_binlog LABELS binlogrouter BREAKS_REPL) +add_test_executable(mxs781_binlog_wrong_passwrd.cpp mxs781_binlog_wrong_passwrd setup_binlog LABELS binlogrouter BREAKS_REPL REPL_BACKEND) # Regression case for crash if long host name is used for binlog router (in 'change master to ...') -add_test_executable(mxs813_long_hostname.cpp mxs813_long_hostname setup_binlog LABELS binlogrouter BREAKS_REPL) +add_test_executable(mxs813_long_hostname.cpp mxs813_long_hostname setup_binlog LABELS binlogrouter BREAKS_REPL REPL_BACKEND) # Test that masking filter can handle multi-statements. add_test_executable(mxs1719.cpp mxs1719 mxs1719 LABELS masking REPL_BACKEND) # configure binlog router setup, execute queries and transactions, check data; -add_test_executable(setup_binlog.cpp setup_binlog setup_binlog LABELS binlogrouter BREAKS_REPL) +add_test_executable(setup_binlog.cpp setup_binlog setup_binlog LABELS binlogrouter BREAKS_REPL REPL_BACKEND) # configure binlog router setup, execute queries and transactions, check data; -add_test_executable(setup_binlog_gtid.cpp setup_binlog_gtid setup_binlog_gtid LABELS binlogrouter BREAKS_REPL) +add_test_executable(setup_binlog_gtid.cpp setup_binlog_gtid setup_binlog_gtid LABELS binlogrouter BREAKS_REPL REPL_BACKEND) # configure binlog router setup, execute queries and transactions, check data; install semysync plugin, backends started with --binlog-checksum=CRC32 option # disabled because it is included into setup_binlog test, separate test was created for debugging -# add_test_executable(setup_binlog_crc_32.cpp setup_binlog_crc_32 setup_binlog LABELS binlogrouter BREAKS_REPL) +# add_test_executable(setup_binlog_crc_32.cpp setup_binlog_crc_32 setup_binlog LABELS binlogrouter BREAKS_REPL REPL_BACKEND) # configure binlog router setup, execute queries and transactions, check data; install semysync plugin, backends started with --binlog-checksum=NONE option # disabled because it is included into setup_binlog test, separate test was created for debugging -# add_test_executable(setup_binlog_crc_none.cpp setup_binlog_crc_none setup_binlog LABELS binlogrouter LIGHT BREAKS_REPL) +# add_test_executable(setup_binlog_crc_none.cpp setup_binlog_crc_none setup_binlog LABELS binlogrouter LIGHT BREAKS_REPL REPL_BACKEND) # Creates KDC and tries authrization via GSSAPI (both client and backend) diff --git a/maxscale-system-test/big_load.cpp b/maxscale-system-test/big_load.cpp index a6412750b..bca2d4a6f 100644 --- a/maxscale-system-test/big_load.cpp +++ b/maxscale-system-test/big_load.cpp @@ -56,7 +56,7 @@ void load(long int *new_inserts, long int *new_selects, long int *selects, long Test->maxscales->close_rwsplit(0); Test->tprintf("Waiting for the table to replicate\n"); - Test->repl->sync_slaves(); + nodes->sync_slaves(); pthread_t thread1[threads_num]; pthread_t thread2[threads_num]; diff --git a/maxscale-system-test/big_load.h b/maxscale-system-test/big_load.h index f4e94bdb0..a9bd7b73b 100644 --- a/maxscale-system-test/big_load.h +++ b/maxscale-system-test/big_load.h @@ -1,6 +1,4 @@ -#ifndef BIG_LOAD_H -#define BIG_LOAD_H - +#pragma once #include "testconnections.h" #include "sql_t1.h" @@ -35,5 +33,3 @@ void *query_thread2(void *ptr ); */ void load(long *new_inserts, long *new_selects, long *selects, long *inserts, int threads_num, TestConnections *Test, long *i1, long *i2, int rwsplit_only, bool galera, bool report_errors); - -#endif // BIG_LOAD_H diff --git a/maxscale-system-test/big_transaction.h b/maxscale-system-test/big_transaction.h index d5be98e01..638cf138b 100644 --- a/maxscale-system-test/big_transaction.h +++ b/maxscale-system-test/big_transaction.h @@ -1,5 +1,4 @@ -#ifndef BIG_TRANSACTION_H -#define BIG_TRANSACTION_H +#pragma once #include #include @@ -13,5 +12,3 @@ * @return 0 if success */ int big_transaction(MYSQL * conn, int N); - -#endif // BIG_TRANSACTION_H diff --git a/maxscale-system-test/binary_ps.cpp b/maxscale-system-test/binary_ps.cpp index 235521299..91b017b6e 100644 --- a/maxscale-system-test/binary_ps.cpp +++ b/maxscale-system-test/binary_ps.cpp @@ -7,7 +7,7 @@ int main(int argc, char** argv) { TestConnections test(argc, argv); - char server_id[test.galera->N][1024]; + char server_id[test.repl->N][1024]; test.repl->connect(); diff --git a/maxscale-system-test/blob_test.h b/maxscale-system-test/blob_test.h index a7f88b888..5e8179de5 100644 --- a/maxscale-system-test/blob_test.h +++ b/maxscale-system-test/blob_test.h @@ -1,5 +1,4 @@ -#ifndef BLOB_TEST_H -#define BLOB_TEST_H +#pragma once #include "testconnections.h" @@ -28,5 +27,3 @@ int test_longblob(TestConnections* Test, MYSQL * conn, char * blob_name, unsigne */ int check_longblob_data(TestConnections* Test, MYSQL * conn, unsigned long chunk_size, int chunks, int rows); - -#endif // BLOB_TEST_H diff --git a/maxscale-system-test/bug488.cpp b/maxscale-system-test/bug488.cpp index 0cc2619bd..25cbecb66 100644 --- a/maxscale-system-test/bug488.cpp +++ b/maxscale-system-test/bug488.cpp @@ -80,7 +80,7 @@ int main(int argc, char *argv[]) Test->set_timeout(10); int i; - Test->repl->connect(); + Test->galera->connect(); Test->maxscales->connect_maxscale(0); Test->tprintf("Trying SHOW VARIABLES to different Maxscale services\n"); @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) Test->set_timeout(10); Test->maxscales->close_maxscale_connections(0); - Test->repl->close_connections(); + Test->galera->close_connections(); Test->check_maxscale_alive(0); diff --git a/maxscale-system-test/bug509.cpp b/maxscale-system-test/bug509.cpp index 779542744..b36ac8a48 100644 --- a/maxscale-system-test/bug509.cpp +++ b/maxscale-system-test/bug509.cpp @@ -76,7 +76,8 @@ int main(int argc, char *argv[]) Test->try_query(Test->galera->nodes[2], (char *) "insert into t2 (x) values (10);"); Test->stop_timeout(); - Test->repl->sync_slaves(); + + Test->galera->sync_slaves(); Test->tprintf("Trying \n"); char last_insert_id1[1024]; diff --git a/maxscale-system-test/bug561.sh b/maxscale-system-test/bug561.sh index b2136c4b4..b46bfe5d7 100755 --- a/maxscale-system-test/bug561.sh +++ b/maxscale-system-test/bug561.sh @@ -7,27 +7,16 @@ ## - repeat for RWSplit, ReadConn -rp=`realpath $0` -export src_dir=`dirname $rp` -export test_dir=`pwd` -export test_name=`basename $rp` - -$test_dir/non_native_setup $test_name - -if [ $? -ne 0 ] ; then - echo "configuring maxscale failed" - exit 1 -fi export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem" #echo "Waiting for 15 seconds" #sleep 15 -mariadb_err=`mysql -u$node_user -p$node_password -h $node_000_network $ssl_options --socket=$node_000_socket -P $node_000_port non_existing_db 2>&1` -maxscale_err=`mysql -u$node_user -p$node_password -h $maxscale_IP -P 4006 $ssl_options non_existing_db 2>&1` +mariadb_err=`mysql -u$node_user -p$node_password -h $node_000_network $ssl_options $node_000_socket_cmd -P $node_000_port non_existing_db 2>&1` +maxscale_err=`mysql -u$node_user -p$node_password -h ${maxscale_000_network} -P 4006 $ssl_options non_existing_db 2>&1` -maxscale_err1=`mysql -u$node_user -p$node_password -h $maxscale_IP -P 4008 $ssl_options non_existing_db 2>&1` -maxscale_err2=`mysql -u$node_user -p$node_password -h $maxscale_IP -P 4009 $ssl_options non_existing_db 2>&1` +maxscale_err1=`mysql -u$node_user -p$node_password -h ${maxscale_000_network} -P 4008 $ssl_options non_existing_db 2>&1` +maxscale_err2=`mysql -u$node_user -p$node_password -h ${maxscale_000_network} -P 4009 $ssl_options non_existing_db 2>&1` echo "MariaDB message" echo "$mariadb_err" @@ -70,5 +59,4 @@ else echo "Messages are same" fi -$src_dir/copy_logs.sh bug561 exit $res diff --git a/maxscale-system-test/bug562.sh b/maxscale-system-test/bug562.sh index 3f22e4a74..6aaba840c 100755 --- a/maxscale-system-test/bug562.sh +++ b/maxscale-system-test/bug562.sh @@ -5,21 +5,10 @@ ## - try to connect with bad credestials directly to MariaDB server and via Maxscale ## - compare error messages -rp=`realpath $0` -export src_dir=`dirname $rp` -export test_dir=`pwd` -export test_name=`basename $rp` - -$test_dir/non_native_setup $test_name - -if [ $? -ne 0 ] ; then - echo "configuring maxscale failed" - exit 1 -fi export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem" -mariadb_err=`mysql -u no_such_user -psome_pwd -h $node_001_network $ssl_option --socket=$node_000_socket test 2>&1` -maxscale_err=`mysql -u no_such_user -psome_pwd -h $maxscale_IP -P 4006 $ssl_options test 2>&1` +mariadb_err=`mysql -u no_such_user -psome_pwd -h $node_001_network $ssl_option $node_001_socket_cmd test 2>&1` +maxscale_err=`mysql -u no_such_user -psome_pwd -h ${maxscale_000_network} -P 4006 $ssl_options test 2>&1` echo "MariaDB message" echo "$mariadb_err" @@ -39,5 +28,4 @@ else res=0 fi -$src_dir/copy_logs.sh bug562 exit $res diff --git a/maxscale-system-test/bug564.sh b/maxscale-system-test/bug564.sh index 990de5160..60d3801d1 100755 --- a/maxscale-system-test/bug564.sh +++ b/maxscale-system-test/bug564.sh @@ -5,24 +5,14 @@ ## - call MariaDB client with different --default-character-set= settings ## - check output of SHOW VARIABLES LIKE 'char%' -rp=`realpath $0` -export src_dir=`dirname $rp` -export test_dir=`pwd` -export test_name=`basename $rp` -$test_dir/non_native_setup $test_name - -if [ $? -ne 0 ] ; then - echo "configuring maxscale failed" - exit 1 -fi export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem" for char_set in "latin1" "latin2" do - line1=`mysql -u$node_user -p$node_password -h $maxscale_IP -P 4006 $ssl_options --default-character-set="$char_set" -e "SHOW VARIABLES LIKE 'char%'" | grep "character_set_client"` - line2=`mysql -u$node_user -p$node_password -h $maxscale_IP -P 4006 $ssl_options --default-character-set="$char_set" -e "SHOW VARIABLES LIKE 'char%'" | grep "character_set_connection"` - line3=`mysql -u$node_user -p$node_password -h $maxscale_IP -P 4006 $ssl_options --default-character-set="$char_set" -e "SHOW VARIABLES LIKE 'char%'" | grep "character_set_results"` + line1=`mysql -u$node_user -p$node_password -h ${maxscale_000_network} -P 4006 $ssl_options --default-character-set="$char_set" -e "SHOW VARIABLES LIKE 'char%'" | grep "character_set_client"` + line2=`mysql -u$node_user -p$node_password -h ${maxscale_000_network} -P 4006 $ssl_options --default-character-set="$char_set" -e "SHOW VARIABLES LIKE 'char%'" | grep "character_set_connection"` + line3=`mysql -u$node_user -p$node_password -h ${maxscale_000_network} -P 4006 $ssl_options --default-character-set="$char_set" -e "SHOW VARIABLES LIKE 'char%'" | grep "character_set_results"` echo $line1 | grep "$char_set" res1=$? @@ -34,10 +24,9 @@ do if [[ $res1 != 0 ]] || [[ $res2 != 0 ]] || [[ $res3 != 0 ]] ; then echo "charset is ignored" - mysql -u$node_user -p$node_password -h $maxscale_IP -P 4006 $ssl_options --default-character-set="latin2" -e "SHOW VARIABLES LIKE 'char%'" - $src_dir/copy_logs.sh bug564 + mysql -u$node_user -p$node_password -h ${maxscale_000_network} -P 4006 $ssl_options --default-character-set="latin2" -e "SHOW VARIABLES LIKE 'char%'" exit 1 fi done -$src_dir/copy_logs.sh bug564 + exit 0 diff --git a/maxscale-system-test/bug567.sh b/maxscale-system-test/bug567.sh index bcfd90b1d..de8f8ab42 100755 --- a/maxscale-system-test/bug567.sh +++ b/maxscale-system-test/bug567.sh @@ -5,31 +5,20 @@ ## - try to remove everythign from /dev/shm/$maxscale_pid ## check if Maxscale is alive -rp=`realpath $0` -export src_dir=`dirname $rp` -export test_dir=`pwd` -export test_name=`basename $rp` -$test_dir/non_native_setup $test_name - -if [ $? -ne 0 ] ; then - echo "configuring maxscale failed" - exit 1 -fi export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem" -#pid=`ssh -i $maxscale_sshkey -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $maxscale_access_user@$maxscale_IP "pgrep maxscale"` +#pid=`ssh -i $maxscale_sshkey -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${maxscale_000_whoami}@${maxscale_000_network} "pgrep maxscale"` #echo "Maxscale pid is $pid" echo "removing log directory from /dev/shm/" -if [ $maxscale_IP != "127.0.0.1" ] ; then - ssh -i $maxscale_sshkey -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $maxscale_access_user@$maxscale_IP "sudo rm -rf /dev/shm/maxscale/*" +if [ ${maxscale_000_network} != "127.0.0.1" ] ; then + ssh -i ${maxscale_000_keyfile} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${maxscale_000_whoami}@${maxscale_000_network} "sudo rm -rf /dev/shm/maxscale/*" else sudo rm -rf /dev/shm/maxscale/* fi sleep 1 echo "checking if Maxscale is alive" -echo "show databases;" | mysql -u$node_user -p$node_password -h $maxscale_IP -P 4006 $ssl_options +echo "show databases;" | mysql -u$node_user -p$node_password -h ${maxscale_000_network} -P 4006 $ssl_options res=$? -$src_dir/copy_logs.sh bug567 exit $res diff --git a/maxscale-system-test/bug670_sql.h b/maxscale-system-test/bug670_sql.h index 88040a769..2f87ee37b 100644 --- a/maxscale-system-test/bug670_sql.h +++ b/maxscale-system-test/bug670_sql.h @@ -1,5 +1,4 @@ -#ifndef BUG670_SQL_H -#define BUG670_SQL_H +#pragma once const char * bug670_sql = "set autocommit=0;\ @@ -39,5 +38,3 @@ const char * bug670_sql = set autocommit=1;\ delete from mysql.t1 where id = 7; \ select 1 as \"endof cycle\" from dual;\n"; - -#endif // BUG670_SQL_H diff --git a/maxscale-system-test/cache_basic.sh b/maxscale-system-test/cache_basic.sh index 4056e6714..234585938 100755 --- a/maxscale-system-test/cache_basic.sh +++ b/maxscale-system-test/cache_basic.sh @@ -1,10 +1,8 @@ #!/bin/bash -rp=`realpath $0` -export src_dir=`dirname $rp` -user=skysql -password=skysql +user=$maxscale_user +password=$maxscale_password # See cnf/maxscale.cnf.template.cache_basic port=4008 @@ -20,8 +18,7 @@ function run_test echo $test_name logdir=log_$test_name mkdir -p $logdir - - mysqltest --host=$maxscale_IP --port=$port \ + mysqltest --host=${maxscale_000_network} --port=$port \ --user=$user --password=$password \ --logdir=$logdir \ --test-file=$dir/t/$test_name.test \ @@ -40,37 +37,15 @@ function run_test return $rc } -if [ $# -lt 1 ] -then - echo "usage: $script name" - echo "" - echo "name : The name of the test (from CMakeLists.txt) That selects the" - echo " configuration template to be used." - exit 1 -fi - -if [ "$maxscale_IP" == "" ] -then - echo "Error: The environment variable maxscale_IP must be set." - exit 1 -fi - -expected_name="cache_basic" - -if [ "$1" != "$expected_name" ] -then - echo "warning: Expected test name to be $expected_name_basic, was $1." -fi - -export dir="$src_dir/cache/$expected_name" +export dir="$src_dir/cache/$1" source=$src_dir/cache/$1/cache_rules.json -target=vagrant@$maxscale_IP:/home/$maxscale_access_user/cache_rules.json +target=${maxscale_000_whoami}@${maxscale_000_network}:/home/${maxscale_000_whoami}/cache_rules.json -if [ $maxscale_IP != "127.0.0.1" ] ; then - scp -i $maxscale_keyfile -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $source $target +if [ ${maxscale_000_network} != "127.0.0.1" ] ; then + scp -i ${maxscale_000_keyfile} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $source $target else - cp $source /home/$maxscale_access_user/cache_rules.json + cp $source /home/${maxscale_000_whoami}/cache_rules.json fi if [ $? -ne 0 ] @@ -79,13 +54,9 @@ then exit 1 fi -echo $source copied to $target +echo $source copied to $target, restarting Maxscale -test_dir=`pwd` - -$test_dir/non_native_setup $1 - -echo +ssh -i $maxscale_000_keyfile -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${maxscale_000_whoami}@${maxscale_000_network} 'sudo service maxscale restart' # We sleep slightly longer than the TTL to ensure that the TTL mechanism # kicks in. diff --git a/maxscale-system-test/cdc_datatypes/CMakeLists.txt b/maxscale-system-test/cdc_datatypes/CMakeLists.txt index b10375204..b9c47ea96 100644 --- a/maxscale-system-test/cdc_datatypes/CMakeLists.txt +++ b/maxscale-system-test/cdc_datatypes/CMakeLists.txt @@ -1,3 +1,3 @@ -add_test_executable(cdc_datatypes.cpp cdc_datatypes avro LABELS avrorouter binlogrouter BREAKS_REPL) +add_test_executable(cdc_datatypes.cpp cdc_datatypes avro LABELS avrorouter binlogrouter BREAKS_REPL REPL_BACKEND) add_library(cdc_result cdc_result.cpp) target_link_libraries(cdc_datatypes cdc_result) diff --git a/maxscale-system-test/change_user.cpp b/maxscale-system-test/change_user.cpp index e4c48595f..7dddd69ab 100644 --- a/maxscale-system-test/change_user.cpp +++ b/maxscale-system-test/change_user.cpp @@ -15,13 +15,13 @@ void run_test(TestConnections& test, MYSQL* conn) { test.expect(mysql_change_user(conn, "user", "pass2", "test") == 0, - "changing user failed: %s", mysql_error(conn)); + "changing user failed: %s", mysql_error(conn)); test.expect(execute_query_silent(conn, "INSERT INTO t1 VALUES (77, 11);") != 0, "INSERT query succeeded without INSERT privilege"); test.expect(mysql_change_user(conn, test.repl->user_name, test.repl->password, "test") == 0, - "changing user failed: %s", mysql_error(conn)); + "changing user failed: %s", mysql_error(conn)); test.expect(execute_query_silent(conn, "INSERT INTO t1 VALUES (77, 11);") == 0, "INSERT query succeeded without INSERT privilege"); @@ -31,7 +31,7 @@ void run_test(TestConnections& test, MYSQL* conn) "changing user with wrong password successed!"); test.expect(strstr(mysql_error(conn), "Access denied for user"), - "Wrong error message returned on failed authentication"); + "Wrong error message returned on failed authentication"); test.expect(execute_query_silent(conn, "INSERT INTO t1 VALUES (77, 11);") != 0, "Query should fail, MaxScale should disconnect on auth failure"); diff --git a/maxscale-system-test/check_backend.cpp b/maxscale-system-test/check_backend.cpp index f9a62372c..5ebca0257 100644 --- a/maxscale-system-test/check_backend.cpp +++ b/maxscale-system-test/check_backend.cpp @@ -14,11 +14,6 @@ int main(int argc, char *argv[]) // Reset server settings by replacing the config files Test->repl->reset_server_settings(); - std::string src = std::string(test_dir) + "/mdbci/add_core_cnf.sh"; - Test->maxscales->copy_to_node(0, src.c_str(), Test->maxscales->access_homedir[0]); - Test->maxscales->ssh_node_f(0, true, "%s/add_core_cnf.sh %s", Test->maxscales->access_homedir[0], - Test->verbose ? "verbose" : ""); - Test->set_timeout(10); Test->tprintf("Connecting to Maxscale maxscales->routers[0] with Master/Slave backend\n"); @@ -27,21 +22,15 @@ int main(int argc, char *argv[]) Test->add_result(Test->test_maxscale_connections(0, true, true, true), "Can't connect to backend\n"); - if ((Test->galera != NULL) && (Test->galera->N != 0)) + Test->tprintf("Connecting to Maxscale router with Galera backend\n"); + MYSQL * g_conn = open_conn(4016, Test->maxscales->IP[0], Test->maxscales->user_name, Test->maxscales->password, Test->ssl); + if (g_conn != NULL ) { - Test->tprintf("Connecting to Maxscale router with Galera backend\n"); - MYSQL * g_conn = open_conn(4016 , Test->maxscales->IP[0], Test->maxscales->user_name, Test->maxscales->password, Test->ssl); - if (g_conn != NULL ) - { - Test->tprintf("Testing connection\n"); - Test->add_result(Test->try_query(g_conn, (char *) "SELECT 1"), - (char *) "Error executing query against RWSplit Galera\n"); - } - } - else - { - Test->tprintf("Galera is not in use\n"); + Test->tprintf("Testing connection\n"); + Test->add_result(Test->try_query(g_conn, (char *) "SELECT 1"), + (char *) "Error executing query against RWSplit Galera\n"); } + Test->tprintf("Closing connections\n"); Test->maxscales->close_maxscale_connections(0); Test->check_maxscale_alive(0); @@ -50,16 +39,6 @@ int main(int argc, char *argv[]) char * ver = Test->maxscales->ssh_node_output(0, "maxscale --version-full", false, &exit_code); Test->tprintf("Maxscale_full_version_start:\n%s\nMaxscale_full_version_end\n", ver); - if ((Test->global_result == 0) && (Test->use_snapshots)) - { - Test->tprintf("Taking snapshot\n"); - Test->take_snapshot((char *) "clean"); - } - else - { - Test->tprintf("Snapshots are not in use\n"); - } - int rval = Test->global_result; delete Test; return rval; diff --git a/maxscale-system-test/copy_logs.sh b/maxscale-system-test/copy_logs.sh index 0f3bfbfa6..aba0a87e7 100755 --- a/maxscale-system-test/copy_logs.sh +++ b/maxscale-system-test/copy_logs.sh @@ -22,20 +22,17 @@ if [ $? -ne 0 ]; then echo "Error creating log dir" fi -export maxscale_sshkey=$maxscale_keyfile echo "log_dir: $logs_dir" -echo "maxscale_sshkey: $maxscale_sshkey" -echo "maxscale_IP: $maxscale_IP" +echo "maxscale_sshkey: $maxscale_000_keyfile" +echo "maxscale_IP: $maxscale_000_network" if [ $maxscale_IP != "127.0.0.1" ] ; then - ssh -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet $maxscale_access_user@$maxscale_IP "rm -rf logs; mkdir logs; $maxscale_access_sudo cp $maxscale_log_dir/*.log logs/; $maxscale_access_sudo cp /tmp/core* logs; $maxscale_access_sudo chmod 777 -R logs" - scp -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet $maxscale_access_user@$maxscale_IP:logs/* $logs_dir + ssh -i ${maxscale_000_keyfile} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet ${maxscale_000_whoami}@${maxscale_000_network} "rm -rf logs; mkdir logs; ${maxscale_000_access_sudo} cp ${maxscale_log_dir}/*.log logs/; ${maxscale_000_access_sudo} cp /tmp/core* logs; ${maxscale_000_access_sudo} chmod 777 -R logs" + scp -i ${maxscale_000_keyfile} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet ${maxscale_000_whoami}@${maxscale_000_network}:logs/* $logs_dir if [ $? -ne 0 ]; then echo "Error copying Maxscale logs" fi - #scp -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet $maxscale_access_user@$maxscale_IP:/tmp/core* $logs_dir - #scp -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet $maxscale_access_user@$maxscale_IP:/root/core* $logs_dir - scp -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet $maxscale_access_user@$maxscale_IP:$maxscale_cnf $logs_dir + scp -i ${maxscale_000_keyfile} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet ${maxscale_000_whoami}@${maxscale_000_network}:$maxscale_cnf $logs_dir chmod a+r $logs_dir/* else sudo cp $maxscale_log_dir/*.log $logs_dir diff --git a/maxscale-system-test/different_size.h b/maxscale-system-test/different_size.h index b28117dd5..fd81ec9d6 100644 --- a/maxscale-system-test/different_size.h +++ b/maxscale-system-test/different_size.h @@ -1,5 +1,4 @@ -#ifndef DIFFERENT_SIZE_H -#define DIFFERENT_SIZE_H +#pragma once #include #include @@ -34,5 +33,3 @@ void set_max_packet(TestConnections* Test, bool binlog, char * cmd); * @param binlog if true - connects to Master, otherwise - to RWSplit router */ void different_packet_size(TestConnections* Test, bool binlog); - -#endif // DIFFERENT_SIZE_H diff --git a/maxscale-system-test/envv.cpp b/maxscale-system-test/envv.cpp new file mode 100644 index 000000000..bcd60cb56 --- /dev/null +++ b/maxscale-system-test/envv.cpp @@ -0,0 +1,61 @@ +#include +#include +#include "envv.h" + +char * readenv(const char * name, const char *format, ...) +{ + char * env = getenv(name); + if (!env) + { + va_list valist; + + va_start(valist, format); + int message_len = vsnprintf(NULL, 0, format, valist); + va_end(valist); + + if (message_len < 0) + { + return NULL; + } + + env = (char*)malloc(message_len + 1); + + va_start(valist, format); + vsnprintf(env, message_len + 1, format, valist); + va_end(valist); + setenv(name, env, 1); + } + return env; +} + +int readenv_int(const char * name, int def) +{ + int x; + char * env = getenv(name); + if (env) + { + sscanf(env, "%d", &x); + } + else + { + x = def; + setenv(name, (std::to_string(x).c_str()), 1); + } + return x; +} + +bool readenv_bool(const char * name, bool def) +{ + char * env = getenv(name); + if (env) + { + return ((strcasecmp(env, "yes") == 0) || + (strcasecmp(env, "y") == 0) || + (strcasecmp(env, "true") == 0)); + } + else + { + setenv(name, def ? "true" : "false", 1); + return def; + } +} diff --git a/maxscale-system-test/envv.h b/maxscale-system-test/envv.h new file mode 100644 index 000000000..76ffdcdad --- /dev/null +++ b/maxscale-system-test/envv.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include +#include + +/** + * @brief readenv Read enviromental variable, if emtpy - set dafault + * @param name Name of the variable + * @param format Default value + * @return Enviromental variable value + */ +char * readenv(const char * name, const char *format, ...); + +/** + * @brief readenv_int Read integer value of enviromental variable, if empty - set dafault + * @param name Name of the variable + * @param def Default value + * @return Enviromental variable value converted to int + */ +int readenv_int(const char * name, int def); + +/** + * @brief readenv_int Read boolean value of enviromental variable, if empty - set dafault + * Values 'yes', 'y', 'true' (case independedant) are interpreted as TRUE, everything else - as FALSE + * @param name Name of the variable + * @param def Default value + * @return Enviromental variable value converted to bool + */ +bool readenv_bool(const char * name, bool def); diff --git a/maxscale-system-test/execute_cmd.h b/maxscale-system-test/execute_cmd.h index 4562c8017..12569eb76 100644 --- a/maxscale-system-test/execute_cmd.h +++ b/maxscale-system-test/execute_cmd.h @@ -1,5 +1,4 @@ -#ifndef EXECUTE_CMD_H -#define EXECUTE_CMD_H +#pragma once #include #include @@ -13,5 +12,3 @@ using namespace std; * @return Process exit code */ int execute_cmd(char * cmd, char ** res); - -#endif // EXECUTE_CMD_H diff --git a/maxscale-system-test/failover_common.cpp b/maxscale-system-test/failover_common.cpp index e0c422c61..a88ea452b 100644 --- a/maxscale-system-test/failover_common.cpp +++ b/maxscale-system-test/failover_common.cpp @@ -29,7 +29,7 @@ void reset_replication(TestConnections& test) int ec; stringstream switchover; switchover << "maxadmin call command mysqlmon switchover MySQL-Monitor server1 server" << master_id; - test.maxscales->ssh_node_output(0, switchover.str().c_str() , true, &ec); + test.maxscales->ssh_node_output(0, switchover.str().c_str(), true, &ec); test.maxscales->wait_for_monitor(2); master_id = get_master_server_id(test); cout << "Master server id is now back to " << master_id << endl; diff --git a/maxscale-system-test/fw_copy_rules.h b/maxscale-system-test/fw_copy_rules.h index fb3437270..4d959d4a8 100644 --- a/maxscale-system-test/fw_copy_rules.h +++ b/maxscale-system-test/fw_copy_rules.h @@ -1,5 +1,4 @@ -#ifndef FW_COPY_RULES_H -#define FW_COPY_RULES_H +#pragma once #include "testconnections.h" @@ -10,5 +9,3 @@ * @param rules_dir Directory where file is located */ void copy_rules(TestConnections* Test, const char* rules_name, const char* rules_dir); - -#endif // FW_COPY_RULES_H diff --git a/maxscale-system-test/get_com_select_insert.h b/maxscale-system-test/get_com_select_insert.h index 2beb46376..1ef666cb8 100644 --- a/maxscale-system-test/get_com_select_insert.h +++ b/maxscale-system-test/get_com_select_insert.h @@ -1,5 +1,4 @@ -#ifndef GET_COM_SELECT_INSERT_H -#define GET_COM_SELECT_INSERT_H +#pragma once #include "testconnections.h" @@ -24,6 +23,3 @@ int get_global_status_allnodes(long int *selects, long int *inserts, Mariadb_nod */ int print_delta(long int *new_selects, long int *new_inserts, long int *selects, long int *inserts, int nodes_num); - - -#endif // GET_COM_SELECT_INSERT_H diff --git a/maxscale-system-test/get_my_ip.cpp b/maxscale-system-test/get_my_ip.cpp index 84a7e953f..a3801ec85 100644 --- a/maxscale-system-test/get_my_ip.cpp +++ b/maxscale-system-test/get_my_ip.cpp @@ -33,7 +33,7 @@ int get_my_ip(char * remote_ip, char * my_ip ) serv.sin_addr.s_addr = inet_addr( remote_ip ); serv.sin_port = htons( dns_port ); - connect( sock , (const struct sockaddr*) &serv , sizeof(serv) ); + connect( sock, (const struct sockaddr*) &serv, sizeof(serv) ); struct sockaddr_in name; socklen_t namelen = sizeof(name); @@ -52,7 +52,7 @@ int get_my_ip(char * remote_ip, char * my_ip ) else { //Some error - printf ("Error number : %d . Error message : %s \n" , errno , strerror(errno)); + printf ("Error number : %d . Error message : %s \n", errno, strerror(errno)); close(sock); return 2; } diff --git a/maxscale-system-test/get_my_ip.h b/maxscale-system-test/get_my_ip.h index 255d935b0..8d82e5443 100644 --- a/maxscale-system-test/get_my_ip.h +++ b/maxscale-system-test/get_my_ip.h @@ -1,5 +1,4 @@ -#ifndef GET_MY_IP_H -#define GET_MY_IP_H +#pragma once /** * @brief get_my_ip Get IP address of machine where this code is executed as it is visible from remote machine @@ -9,5 +8,3 @@ * @return 0 in case of success */ int get_my_ip(char * remote_ip, char *my_ip ); - -#endif // GET_MY_IP_H diff --git a/maxscale-system-test/insertstream.sh b/maxscale-system-test/insertstream.sh index 55950f0ef..b6d68f251 100755 --- a/maxscale-system-test/insertstream.sh +++ b/maxscale-system-test/insertstream.sh @@ -1,8 +1,4 @@ #!/bin/bash -rp=`realpath $0` -export src_dir=`dirname $rp` - -./non_native_setup insertstream $src_dir/mysqltest_driver.sh insertstream $src_dir/insertstream 4006 diff --git a/maxscale-system-test/keepalived_func.h b/maxscale-system-test/keepalived_func.h index 221dd4996..0308c4091 100644 --- a/maxscale-system-test/keepalived_func.h +++ b/maxscale-system-test/keepalived_func.h @@ -1,5 +1,4 @@ -#ifndef KEEPALIVED_FUNC_H -#define KEEPALIVED_FUNC_H +#pragma once #include "testconnections.h" @@ -8,5 +7,3 @@ char virtual_ip[16]; char * print_version_string(TestConnections * Test); void configure_keepalived(TestConnections* Test, char *keepalived_file); - -#endif // KEEPALIVED_FUNC_H diff --git a/maxscale-system-test/keepalived_masterdown.cpp b/maxscale-system-test/keepalived_masterdown.cpp index 902c84feb..50d2b35f1 100644 --- a/maxscale-system-test/keepalived_masterdown.cpp +++ b/maxscale-system-test/keepalived_masterdown.cpp @@ -98,10 +98,10 @@ int main(int argc, char *argv[]) sprintf(str, "Performing automatic failover to replace failed master 'server%d'", first_master + 1); Test->tprintf("Checking Maxscale log on 000 for the failover message %s\n", str); - Test->check_log_err(0, str , true); + Test->check_log_err(0, str, true); sprintf(str, "Performing automatic failover to replace failed master"); Test->tprintf("Checking Maxscale log on 001 for the lack of failover message\n"); - Test->check_log_err(1, str , false); + Test->check_log_err(1, str, false); passive = check_maxscale_passive(Test, 0); if (passive) @@ -140,11 +140,11 @@ int main(int argc, char *argv[]) } sprintf(str, "Performing automatic failover to replace failed master 'server%d'", second_master + 1); Test->tprintf("Checking Maxscale log on 001 for the failover message %s\n", str); - Test->check_log_err(1, str , true); + Test->check_log_err(1, str, true); - Test->check_log_err(1, (char *) "Multiple failed master servers detected" , false); - Test->check_log_err(1, (char *) "Failed to perform failover" , false); - Test->check_log_err(1, (char *) "disabling automatic failover" , false); + Test->check_log_err(1, (char *) "Multiple failed master servers detected", false); + Test->check_log_err(1, (char *) "Failed to perform failover", false); + Test->check_log_err(1, (char *) "disabling automatic failover", false); Test->tprintf("Start Maxscale 000\n"); @@ -165,17 +165,17 @@ int main(int argc, char *argv[]) sprintf(str, "Performing automatic failover to replace failed master 'server%d'", second_master + 1); Test->tprintf("Checking Maxscale log on 001 for the failover message %s\n", str); - Test->check_log_err(1, str , true); + Test->check_log_err(1, str, true); Test->tprintf("Checking Maxscale log on 000 for the lack of failover message %s\n", str); - Test->check_log_err(0, str , false); + Test->check_log_err(0, str, false); - Test->check_log_err(1, (char *) "Multiple failed master servers detected" , false); - Test->check_log_err(1, (char *) "Failed to perform failover" , false); - Test->check_log_err(1, (char *) "disabling automatic failover" , false); + Test->check_log_err(1, (char *) "Multiple failed master servers detected", false); + Test->check_log_err(1, (char *) "Failed to perform failover", false); + Test->check_log_err(1, (char *) "disabling automatic failover", false); - Test->check_log_err(0, (char *) "Multiple failed master servers detected" , false); - Test->check_log_err(0, (char *) "Failed to perform failover" , false); - Test->check_log_err(0, (char *) "disabling automatic failover" , false); + Test->check_log_err(0, (char *) "Multiple failed master servers detected", false); + Test->check_log_err(0, (char *) "Failed to perform failover", false); + Test->check_log_err(0, (char *) "disabling automatic failover", false); // Test->repl->require_gtid(false); diff --git a/maxscale-system-test/labels_table.cpp b/maxscale-system-test/labels_table.cpp new file mode 100644 index 000000000..79910be7f --- /dev/null +++ b/maxscale-system-test/labels_table.cpp @@ -0,0 +1,20 @@ +#include +#include +#include +#include "labels_table.h" + +std::string get_mdbci_lables(const char *labels_string) +{ + std::string mdbci_labels("MAXSCALE"); + + for (size_t i = 0; i < sizeof(labels_table) / sizeof(labels_table_t); i++) + { + printf("%lu\t %s\n", i, labels_table[i].test_label); + if (strstr(labels_string, labels_table[i].test_label)) + { + mdbci_labels += "," + std::string(labels_table[i].mdbci_label); + } + } + printf("mdbci labels %s\n", mdbci_labels.c_str()); + return mdbci_labels; +} diff --git a/maxscale-system-test/labels_table.h b/maxscale-system-test/labels_table.h new file mode 100644 index 000000000..c0e10052b --- /dev/null +++ b/maxscale-system-test/labels_table.h @@ -0,0 +1,29 @@ +#pragma once + +#include + +struct labels_table_t +{ + const char* test_label; + const char* mdbci_label; + +}; + +const labels_table_t labels_table [] __attribute__((unused)) = +{ + {"REPL_BACKEND", "REPL_BACKEND"}, + {"GALERA_BACKEND", "GALERA_BACKEND"}, + {"TWO_MAXSCALES", "SECOND_MAXSCALE"}, + {"COLUMNSTORE_BACKEND", "COLUMNSTORE_BACKEND"}, +}; + +/** + * @brief get_mdbci_lables Finds all MDBCI labels which are needed by test + * Every test has a number of labels defined in the CMakeLists.txt, + * some of these lables defines which nodes (virtual machines) are needed + * for this particular test. Function finds such labels and forms labels string + * in the 'mdbci up' command format + * @param labels_string All lables from CMakeLists.txt + * @return Labels string in the 'mdbci up' --labels parameter format + */ +std::string get_mdbci_lables(const char * labels_string); diff --git a/maxscale-system-test/long_test.cpp b/maxscale-system-test/long_test.cpp index ce1c9b111..ac5b110d4 100644 --- a/maxscale-system-test/long_test.cpp +++ b/maxscale-system-test/long_test.cpp @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) for (i = 0; i < threads_num[j]; i++) { data[j][i].sql = (char*) malloc((i +1) * 32 * 14 + 32); - create_insert_string(data[j][i].sql, (i + 1) * 32 , i); + create_insert_string(data[j][i].sql, (i + 1) * 32, i); Test->tprintf("sqL %d: %d\n", i, strlen(data[j][i].sql)); data[j][i].exit_flag = false; data[j][i].id = i; @@ -178,12 +178,12 @@ void try_and_reconnect(MYSQL * conn, char * db, char * sql) Test->tprintf("reconnect"); mysql_close(conn); conn = open_conn_db_timeout(port, - IP, - db, - Test->repl->user_name, - Test->repl->password, - 20, - Test->ssl); + IP, + db, + Test->repl->user_name, + Test->repl->password, + 20, + Test->ssl); } } @@ -194,12 +194,12 @@ void *query_thread(void *ptr ) int inserts_until_optimize = 100000; int tn = 0; conn = open_conn_db_timeout(port, - IP, - (char *) "test", - Test->repl->user_name, - Test->repl->password, - 20, - Test->ssl); + IP, + (char *) "test", + Test->repl->user_name, + Test->repl->password, + 20, + Test->ssl); while (!data->exit_flag) { @@ -227,12 +227,12 @@ void *read_thread(void *ptr ) int i = 0; char sql[256]; conn = open_conn_db_timeout(port, - IP, - (char *) "test", - Test->repl->user_name, - Test->repl->password, - 20, - Test->ssl); + IP, + (char *) "test", + Test->repl->user_name, + Test->repl->password, + 20, + Test->ssl); while (!data->exit_flag) { sprintf(sql, "SELECT * FROM t1 WHERE fl=%d", data->id); @@ -250,12 +250,12 @@ void *transaction_thread(void *ptr ) int tn = 0; t_data * data = (t_data *) ptr; conn = open_conn_db_timeout(port, - IP, - (char *) "test1", - Test->repl->user_name, - Test->repl->password, - 20, - Test->ssl); + IP, + (char *) "test1", + Test->repl->user_name, + Test->repl->password, + 20, + Test->ssl); while (!data->exit_flag) { @@ -281,12 +281,12 @@ void *transaction_thread(void *ptr ) mysql_close(conn); conn = open_conn_db_timeout(port, - IP, - (char *) "", - Test->maxscales->user_name, - Test->maxscales->password, - 20, - Test->ssl); + IP, + (char *) "", + Test->maxscales->user_name, + Test->maxscales->password, + 20, + Test->ssl); Test->try_query(conn, "DROP DATABASE test1"); mysql_close(conn); return NULL; @@ -299,12 +299,12 @@ void *short_session_thread(void *ptr ) while (!data->exit_flag) { conn = open_conn_db_timeout(port, - IP, - (char *) "test", - Test->repl->user_name, - Test->repl->password, - 20, - Test->ssl); + IP, + (char *) "test", + Test->repl->user_name, + Test->repl->password, + 20, + Test->ssl); mysql_close(conn); } return NULL; @@ -317,12 +317,12 @@ void *prepared_stmt_thread(void *ptr ) t_data * data = (t_data *) ptr; char sql[256]; conn = open_conn_db_timeout(port, - IP, - (char *) "test2", - Test->repl->user_name, - Test->repl->password, - 20, - Test->ssl); + IP, + (char *) "test2", + Test->repl->user_name, + Test->repl->password, + 20, + Test->ssl); while (!data->exit_flag) { sprintf(sql, "PREPARE stmt%d FROM 'SELECT * FROM t1 WHERE fl=@x;';", data->id); @@ -340,12 +340,12 @@ void *prepared_stmt_thread(void *ptr ) mysql_close(conn); conn = open_conn_db_timeout(port, - IP, - (char *) "", - Test->maxscales->user_name, - Test->maxscales->password, - 20, - Test->ssl); + IP, + (char *) "", + Test->maxscales->user_name, + Test->maxscales->password, + 20, + Test->ssl); Test->try_query(conn, "DROP DATABASE test2"); mysql_close(conn); return NULL; diff --git a/maxscale-system-test/lots_of_rows.cpp b/maxscale-system-test/lots_of_rows.cpp index 0debd5384..5180e49c7 100644 --- a/maxscale-system-test/lots_of_rows.cpp +++ b/maxscale-system-test/lots_of_rows.cpp @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) Test->tprintf("done, syncing slaves"); Test->stop_timeout(); - Test->repl->sync_slaves(); + Test->galera->sync_slaves(); Test->tprintf("Trying SELECT"); Test->set_timeout(60); Test->try_query(Test->maxscales->conn_rwsplit[0], (char *) "SELECT * FROM t1"); diff --git a/maxscale-system-test/mariadb_func.h b/maxscale-system-test/mariadb_func.h index bf020ba3d..88f43fbcb 100644 --- a/maxscale-system-test/mariadb_func.h +++ b/maxscale-system-test/mariadb_func.h @@ -1,6 +1,4 @@ -#ifndef MARIADB_FUNC_H -#define MARIADB_FUNC_H - +#pragma once /** * @file mariadb_func.h - basic DB interaction routines @@ -107,7 +105,8 @@ static MYSQL* open_conn(int port, std::string ip, std::string user, std::string * * @return MYSQL struct */ -static MYSQL* open_conn_no_db(int port, std::string ip, std::string user, std::string password, bool ssl = false) +static MYSQL* open_conn_no_db(int port, std::string ip, std::string user, std::string password, + bool ssl = false) { return open_conn_db_flags(port, ip, "", user, password, CLIENT_MULTI_STATEMENTS, ssl); } @@ -229,5 +228,3 @@ Row get_row(MYSQL* conn, std::string sql); Result get_result(MYSQL* conn, std::string sql); int get_int_version(std::string version); - -#endif // MARIADB_FUNC_H diff --git a/maxscale-system-test/mariadb_nodes.cpp b/maxscale-system-test/mariadb_nodes.cpp index ffd314f64..e350d655a 100644 --- a/maxscale-system-test/mariadb_nodes.cpp +++ b/maxscale-system-test/mariadb_nodes.cpp @@ -17,6 +17,7 @@ #include #include #include +#include "envv.h" namespace { @@ -28,7 +29,8 @@ void Mariadb_nodes::require_gtid(bool value) g_require_gtid = value; } -Mariadb_nodes::Mariadb_nodes(const char *pref, const char *test_cwd, bool verbose): +Mariadb_nodes::Mariadb_nodes(const char *pref, const char *test_cwd, bool verbose, + std::string network_config): v51(false) { use_ipv6 = false; @@ -37,6 +39,7 @@ Mariadb_nodes::Mariadb_nodes(const char *pref, const char *test_cwd, bool verbos memset(blocked, 0, sizeof(blocked)); no_set_pos = false; this->verbose = verbose; + this->network_config = network_config; strcpy(test_dir, test_cwd); read_env(); truncate_mariadb_logs(); @@ -100,43 +103,21 @@ void Mariadb_nodes::close_connections() } } - - void Mariadb_nodes::read_env() { - char * env; char env_name[64]; read_basic_env(); sprintf(env_name, "%s_user", prefix); - env = getenv(env_name); - if (env != NULL) - { - sscanf(env, "%s", user_name); - } - else - { - sprintf(user_name, "skysql"); - } + user_name = readenv(env_name, "skysql"); + sprintf(env_name, "%s_password", prefix); - env = getenv(env_name); - if (env != NULL) - { - sscanf(env, "%s", password); - } - else - { - sprintf(password, "skysql"); - } + password = readenv(env_name, "skysql"); ssl = false; sprintf(env_name, "%s_ssl", prefix); - env = getenv(env_name); - if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) - { - ssl = true; - } + ssl = readenv_bool(env_name, false); if ((N > 0) && (N < 255)) { @@ -144,65 +125,34 @@ void Mariadb_nodes::read_env() { //reading ports sprintf(env_name, "%s_%03d_port", prefix, i); - env = getenv(env_name); - if (env != NULL) - { - sscanf(env, "%d", &port[i]); - } - else - { - port[i] = 3306; - } + port[i] = readenv_int(env_name, 3306); + //reading sockets sprintf(env_name, "%s_%03d_socket", prefix, i); - env = getenv(env_name); - if (env != NULL) + socket[i] = readenv(env_name, " "); + if (strcmp(socket[i], " ")) { - sprintf(socket[i], "%s", env); - sprintf(socket_cmd[i], "--socket=%s", env); + socket_cmd[i] = (char *) malloc(strlen(socket[i]) + 10); + sprintf(socket_cmd[i], "--socket=%s", socket[i]); } else { - sprintf(socket[i], " "); - sprintf(socket_cmd[i], " "); + socket_cmd[i] = (char *) " "; } - + sprintf(env_name, "%s_%03d_socket_cmd", prefix, i); + setenv(env_name, socket_cmd[i], 1); //reading start_db_command sprintf(env_name, "%s_%03d_start_db_command", prefix, i); - env = getenv(env_name); - if (env != NULL) - { - sprintf(start_db_command[i], "%s", env); - } - else - { - sprintf(start_db_command[i], "%s", "service mysql start"); - } + start_db_command[i] = readenv(env_name, (char *) "service mysql start"); //reading stop_db_command sprintf(env_name, "%s_%03d_stop_db_command", prefix, i); - env = getenv(env_name); - if (env != NULL) - { - sprintf(stop_db_command[i], "%s", env); - } - else - { - sprintf(stop_db_command[i], "%s", "service mysql stop"); - } + stop_db_command[i] = readenv(env_name, (char *) "service mysql stop"); //reading cleanup_db_command sprintf(env_name, "%s_%03d_cleanup_db_command", prefix, i); - env = getenv(env_name); - if (env != NULL) - { - sprintf(cleanup_db_command[i], "%s", env); - } - else - { - sprintf(cleanup_db_command[i], "rm -rf /var/lib/mysql/*; killall -9 mysqld"); - } + cleanup_db_command[i] = readenv(env_name, (char *) "rm -rf /var/lib/mysql/*; killall -9 mysqld"); } } } diff --git a/maxscale-system-test/mariadb_nodes.h b/maxscale-system-test/mariadb_nodes.h index 2b2b398f9..f8b800c56 100644 --- a/maxscale-system-test/mariadb_nodes.h +++ b/maxscale-system-test/mariadb_nodes.h @@ -1,5 +1,4 @@ -#ifndef MARIADB_NODES_H -#define MARIADB_NODES_H +#pragma once /** * @file mariadb_nodes.h - backend nodes routines @@ -36,7 +35,7 @@ public: * @brief Constructor * @param pref name of backend setup (like 'repl' or 'galera') */ - Mariadb_nodes(const char *pref, const char *test_cwd, bool verbose); + Mariadb_nodes(const char *pref, const char *test_cwd, bool verbose, std::string network_config); virtual ~Mariadb_nodes(); @@ -55,20 +54,20 @@ public: /** * @brief Unix socket to connecto to MariaDB */ - char socket[256][1024]; + char * socket[256]; /** * @brief 'socket=$socket' line */ - char socket_cmd[256][1024]; + char * socket_cmd[256]; /** * @brief User name to access backend nodes */ - char user_name[256]; + char * user_name; /** * @brief Password to access backend nodes */ - char password[256]; + char * password; /** * @brief master index of node which was last configured to be Master */ @@ -77,18 +76,18 @@ public: /** * @brief start_db_command Command to start DB server */ - char start_db_command[256][4096]; + char * start_db_command[256]; /** * @brief stop_db_command Command to start DB server */ - char stop_db_command[256][4096]; + char * stop_db_command[256]; /** * @brief cleanup_db_command Command to remove all * data files and re-install DB with mysql_install_db */ - char cleanup_db_command[256][4096]; + char * cleanup_db_command[256]; /** * @brief ssl if true ssl will be used @@ -353,7 +352,7 @@ public: * Only works with master-slave replication and should not be used with Galera clusters. * The function expects that the first node, @c nodes[0], is the master. */ - void sync_slaves(int node = 0); + virtual void sync_slaves(int node = 0); /** * @brief Close all connections to this node @@ -456,8 +455,8 @@ class Galera_nodes : public Mariadb_nodes { public: - Galera_nodes(const char *pref, const char *test_cwd, bool verbose) : - Mariadb_nodes(pref, test_cwd, verbose) { } + Galera_nodes(const char *pref, const char *test_cwd, bool verbose, std::string network_config) : + Mariadb_nodes(pref, test_cwd, verbose, network_config) { } int start_galera(); @@ -479,6 +478,9 @@ public: //{ // return prepare_galera_server(i); //} + virtual void sync_slaves(int node = 0) + { + sleep(10); + } }; -#endif // MARIADB_NODES_H diff --git a/maxscale-system-test/mariadb_tests_hartmut.sh b/maxscale-system-test/mariadb_tests_hartmut.sh index f23c46ce5..4b8d9fa35 100755 --- a/maxscale-system-test/mariadb_tests_hartmut.sh +++ b/maxscale-system-test/mariadb_tests_hartmut.sh @@ -4,8 +4,6 @@ # # TODO: Don't test correctness of routing with mysqltest # -rp=`realpath $0` -export src_dir=`dirname $rp` # TODO: Don't copy this and "unmangle" the test instead cp -r $src_dir/Hartmut_tests/maxscale-mysqltest ./Hartmut_tests/maxscale-mysqltest/ @@ -15,9 +13,9 @@ echo "--disable_query_log" > Hartmut_tests/maxscale-mysqltest/testconf.inc echo "SET @TMASTER_ID=$master_id;" >> Hartmut_tests/maxscale-mysqltest/testconf.inc echo "--enable_query_log" >> Hartmut_tests/maxscale-mysqltest/testconf.inc -$src_dir/mysqltest_driver.sh $1 $PWD/Hartmut_tests/maxscale-mysqltest 4006 +echo "--disable_query_log" > testconf.inc +echo "SET @TMASTER_ID=$master_id;" >> testconf.inc +echo "--enable_query_log" >> testconf.inc -ret=$? -$src_dir/copy_logs.sh $1 +$src_dir/mysqltest_driver.sh "$1" "$PWD/Hartmut_tests/maxscale-mysqltest" 4006 -exit $ret diff --git a/maxscale-system-test/masking_mysqltest_driver.sh b/maxscale-system-test/masking_mysqltest_driver.sh index b9b12ea00..08288b378 100755 --- a/maxscale-system-test/masking_mysqltest_driver.sh +++ b/maxscale-system-test/masking_mysqltest_driver.sh @@ -2,31 +2,13 @@ script=`basename "$0"` -if [ $# -lt 1 ] -then - echo "usage: $script name [user] [password]" - echo "" - echo "name : The name of the test (from CMakeLists.txt) That selects the" - echo " configuration template to be used." - echo "user : The user using which the test should be run." - echo "password: The password of the user." - exit 1 -fi - -if [ "$maxscale_IP" == "" ] -then - echo "Error: The environment variable maxscale_IP must be set." - exit 1 -fi - -src_dir=$(dirname $(realpath $0)) source=$src_dir/masking/$1/masking_rules.json -target=$maxscale_access_user@$maxscale_IP:/home/$maxscale_access_user/masking_rules.json +target=${maxscale_000_whoami}@${maxscale_000_network}:/home/${maxscale_000_whoami}/masking_rules.json -if [ $maxscale_IP != "127.0.0.1" ] ; then - scp -i $maxscale_keyfile -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $source $target +if [ ${maxscale_000_network} != "127.0.0.1" ] ; then + scp -i $maxscale_000_keyfile -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $source $target else - cp $source /home/$maxscale_access_user/masking_rules.json + cp $source /home/${maxscale_000_whoami}/masking_rules.json fi if [ $? -ne 0 ] @@ -35,25 +17,11 @@ then exit 1 fi -echo $source copied to $target +echo $source copied to $target, restarting Maxscale -test_dir=`pwd` - -$test_dir/non_native_setup $1 - -password= -if [ $# -ge 3 ] -then - password=$3 -fi - -user= -if [ $# -ge 2 ] -then - user=$2 -fi +ssh -i $maxscale_000_keyfile -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${maxscale_000_whoami}@${maxscale_000_network} 'sudo service maxscale restart' # [Read Connection Listener Master] in cnf/maxscale.maxscale.cnf.template.$1 port=4008 -$src_dir/mysqltest_driver.sh $1 $src_dir/masking/$1 $port $user $password +$src_dir/mysqltest_driver.sh $1 $src_dir/masking/$1 $port $maxscale_user $maxscale_password diff --git a/maxscale-system-test/masking_user.sh b/maxscale-system-test/masking_user.sh index c07d95a2f..181bb4cff 100755 --- a/maxscale-system-test/masking_user.sh +++ b/maxscale-system-test/masking_user.sh @@ -2,30 +2,13 @@ script=`basename "$0"` -if [ $# -lt 1 ] -then - echo "usage: $script name" - echo "" - echo "name : The name of the test (from CMakeLists.txt) That selects the" - echo " configuration template to be used." - exit 1 -fi - -if [ "$maxscale_IP" == "" ] -then - echo "Error: The environment variable maxscale_IP must be set." - exit 1 -fi - -src_dir=$(dirname $(realpath $0)) -echo "src_dir: $src_dir" source=$src_dir/masking/$1/masking_rules.json -target=vagrant@$maxscale_IP:/home/$maxscale_access_user/masking_rules.json +target=${maxscale_000_whoami}@${maxscale_000_network}:/home/${maxscale_000_whoami}/masking_rules.json -if [ $maxscale_IP != "127.0.0.1" ] ; then - scp -i $maxscale_keyfile -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $source $target +if [ ${maxscale_000_network} != "127.0.0.1" ] ; then + scp -i $maxscale_000_keyfile -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $source $target else - cp $source /home/$maxscale_access_user/masking_rules.json + cp $source /home/${maxscale_000_whoami}/masking_rules.json fi if [ $? -ne 0 ] @@ -34,25 +17,25 @@ then exit 1 fi -echo $source copied to $target +echo $source copied to $target, restarting maxscale + +ssh -i $maxscale_000_keyfile -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${maxscale_000_whoami}@${maxscale_000_network} 'sudo service maxscale restart' test_dir=`pwd` -$test_dir/non_native_setup $1 logdir=log_$1 [ -d $logdir ] && rm -r $logdir mkdir $logdir || exit 1 # [Read Connection Listener Master] in cnf/maxscale.maxscale.cnf.template.$1 port=4008 -password=skysql dir="$src_dir/masking/$1" user=skysql test_name=masking_user -mysqltest --host=$maxscale_IP --port=$port \ - --user=$user --password=$password \ +mysqltest --host=${maxscale_000_network} --port=$port \ + --user=$maxscale_user --password=$maxscale_password \ --logdir=$logdir \ --test-file=$dir/t/$test_name.test \ --result-file=$dir/r/"$test_name"_"$user".result \ @@ -67,8 +50,8 @@ fi user=maxskysql test_name=masking_user -mysqltest --host=$maxscale_IP --port=$port \ - --user=$user --password=$password \ +mysqltest --host=${maxscale_000_network} --port=$port \ + --user=$maxscale_user --password=$maxscale_password \ --logdir=$logdir \ --test-file=$dir/t/$test_name.test \ --result-file=$dir/r/"$test_name"_"$user".result \ @@ -81,9 +64,4 @@ else res=1 fi -echo - -# Copy logs from the VM -$src_dir/copy_logs.sh $1 - -exit $res +echo $res diff --git a/maxscale-system-test/maxadmin_operations.cpp b/maxscale-system-test/maxadmin_operations.cpp index 83f9bee93..31496a2e6 100644 --- a/maxscale-system-test/maxadmin_operations.cpp +++ b/maxscale-system-test/maxadmin_operations.cpp @@ -43,7 +43,7 @@ connectMaxScale(char *hostname, char *port) return -1; } if (setsockopt(so, SOL_SOCKET, - SO_KEEPALIVE, &keepalive , sizeof(keepalive ))) + SO_KEEPALIVE, &keepalive, sizeof(keepalive ))) { perror("setsockopt"); } diff --git a/maxscale-system-test/maxadmin_operations.h b/maxscale-system-test/maxadmin_operations.h index a426d95fe..93001b4fc 100644 --- a/maxscale-system-test/maxadmin_operations.h +++ b/maxscale-system-test/maxadmin_operations.h @@ -1,6 +1,4 @@ -#ifndef MAXADMIN_OPERATIONS_H -#define MAXADMIN_OPERATIONS_H - +#pragma once #include #include @@ -102,5 +100,3 @@ int execute_maxadmin_command_tcp(char * hostname, char *user, char *password, ch * @return 0 if parameter is found */ int execute_maxadmin_command_print_pcp(char * hostname, char *user, char *password, char * cmd); - -#endif // MAXADMIN_OPERATIONS_H diff --git a/maxscale-system-test/maxinfo_func.h b/maxscale-system-test/maxinfo_func.h index 1a9686201..9e384b4ac 100644 --- a/maxscale-system-test/maxinfo_func.h +++ b/maxscale-system-test/maxinfo_func.h @@ -1,5 +1,4 @@ -#ifndef MAXINFO_FUNC_H -#define MAXINFO_FUNC_H +#pragma once int create_tcp_socket(); char *get_ip(char *host); @@ -20,6 +19,3 @@ static char* bin2hex(const unsigned char *old, const size_t oldlen); char * cdc_auth_srt(char * user, char * password); int setnonblocking(int sock); int get_x_fl_from_json(char * line, long long int * x1, long long int * fl); - - -#endif // MAXINFO_FUNC_H diff --git a/maxscale-system-test/maxpython.py b/maxscale-system-test/maxpython.py index 254c13c32..7f1ad021b 100644 --- a/maxscale-system-test/maxpython.py +++ b/maxscale-system-test/maxpython.py @@ -59,31 +59,31 @@ class MaxScaleTest: def __init__(self, testname = "python_test"): self.testname = testname - prepare_test(testname) +# prepare_test(testname) # MaxScale connections self.maxscale = dict() - self.maxscale['rwsplit'] = SQLConnection(host = os.getenv("maxscale_IP"), port = "4006", user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) - self.maxscale['rcmaster'] = SQLConnection(host = os.getenv("maxscale_IP"), port = "4008", user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) - self.maxscale['rcslave'] = SQLConnection(host = os.getenv("maxscale_IP"), port = "4009", user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) + self.maxscale['rwsplit'] = SQLConnection(host = os.getenv("maxscale_000_network"), port = "4006", user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) + self.maxscale['rcmaster'] = SQLConnection(host = os.getenv("maxscale_000_network"), port = "4008", user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) + self.maxscale['rcslave'] = SQLConnection(host = os.getenv("maxscale_000_network"), port = "4009", user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) # Master-Slave nodes self.repl = dict() - self.repl['node0'] = SQLConnection(host = os.getenv("node_000_network"), port = os.getenv("node_000_port"), user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) - self.repl['node1'] = SQLConnection(host = os.getenv("node_001_network"), port = os.getenv("node_001_port"), user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) - self.repl['node2'] = SQLConnection(host = os.getenv("node_002_network"), port = os.getenv("node_002_port"), user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) - self.repl['node3'] = SQLConnection(host = os.getenv("node_003_network"), port = os.getenv("node_003_port"), user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) + self.repl['node0'] = SQLConnection(host = os.getenv("node_000_network"), port = os.getenv("node_000_port"), user = os.getenv("node_user"), password = os.getenv("node_password")) + self.repl['node1'] = SQLConnection(host = os.getenv("node_001_network"), port = os.getenv("node_001_port"), user = os.getenv("node_user"), password = os.getenv("node_password")) + self.repl['node2'] = SQLConnection(host = os.getenv("node_002_network"), port = os.getenv("node_002_port"), user = os.getenv("node_user"), password = os.getenv("node_password")) + self.repl['node3'] = SQLConnection(host = os.getenv("node_003_network"), port = os.getenv("node_003_port"), user = os.getenv("node_user"), password = os.getenv("node_password")) # Galera nodes self.galera = dict() - self.galera['node0'] = SQLConnection(host = os.getenv("galera_000_network"), port = os.getenv("galera_000_port"), user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) - self.galera['node1'] = SQLConnection(host = os.getenv("galera_001_network"), port = os.getenv("galera_001_port"), user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) - self.galera['node2'] = SQLConnection(host = os.getenv("galera_002_network"), port = os.getenv("galera_002_port"), user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) - self.galera['node3'] = SQLConnection(host = os.getenv("galera_003_network"), port = os.getenv("galera_003_port"), user = os.getenv("maxscale_user"), password = os.getenv("maxscale_password")) + self.galera['node0'] = SQLConnection(host = os.getenv("galera_000_network"), port = os.getenv("galera_000_port"), user = os.getenv("galera_user"), password = os.getenv("galera_password")) + self.galera['node1'] = SQLConnection(host = os.getenv("galera_001_network"), port = os.getenv("galera_001_port"), user = os.getenv("galera_user"), password = os.getenv("galera_password")) + self.galera['node2'] = SQLConnection(host = os.getenv("galera_002_network"), port = os.getenv("galera_002_port"), user = os.getenv("galera_user"), password = os.getenv("galera_password")) + self.galera['node3'] = SQLConnection(host = os.getenv("galera_003_network"), port = os.getenv("galera_003_port"), user = os.getenv("galera_user"), password = os.getenv("galera_password")) - def __del__(self): - subprocess.call(os.getcwd() + "/copy_logs.sh " + str(self.testname), shell=True) +# def __del__(self): +# subprocess.call(os.getcwd() + "/copy_logs.sh " + str(self.testname), shell=True) # Read test environment variables -def prepare_test(testname = "replication"): - subprocess.call(os.getcwd() + "/non_native_setup " + str(testname), shell=True) +#def prepare_test(testname = "replication"): +# subprocess.call(os.getcwd() + "/non_native_setup " + str(testname), shell=True) diff --git a/maxscale-system-test/maxscales.cpp b/maxscale-system-test/maxscales.cpp index 9c890c37d..92c9dfa67 100644 --- a/maxscale-system-test/maxscales.cpp +++ b/maxscale-system-test/maxscales.cpp @@ -1,14 +1,19 @@ #include "maxscales.h" #include #include +#include -Maxscales::Maxscales(const char *pref, const char *test_cwd, bool verbose, bool use_valgrind) +#include "envv.h" + +Maxscales::Maxscales(const char *pref, const char *test_cwd, bool verbose, bool use_valgrind, + std::string network_config) { strcpy(prefix, pref); this->verbose = verbose; this->use_valgrind = use_valgrind; valgring_log_num = 0; strcpy(test_dir, test_cwd); + this->network_config = network_config; read_env(); if (use_valgrind) { @@ -24,7 +29,6 @@ Maxscales::Maxscales(const char *pref, const char *test_cwd, bool verbose, bool int Maxscales::read_env() { - char * env; char env_name[64]; read_basic_env(); @@ -34,69 +38,16 @@ int Maxscales::read_env() for (int i = 0; i < N; i++) { sprintf(env_name, "%s_%03d_cnf", prefix, i); - env = getenv(env_name); - if (env == NULL) - { - sprintf(env_name, "%s_cnf", prefix); - env = getenv(env_name); - } - if (env != NULL) - { - sprintf(maxscale_cnf[i], "%s", env); - } - else - { - sprintf(maxscale_cnf[i], "/etc/maxscale.cnf"); - } + maxscale_cnf[i] = readenv(env_name, DEFAULT_MAXSCALE_CNF); sprintf(env_name, "%s_%03d_log_dir", prefix, i); - env = getenv(env_name); - if (env == NULL) - { - sprintf(env_name, "%s_log_dir", prefix); - env = getenv(env_name); - } - - if (env != NULL) - { - sprintf(maxscale_log_dir[i], "%s", env); - } - else - { - sprintf(maxscale_log_dir[i], "/var/log/maxscale/"); - } + maxscale_log_dir[i] = readenv(env_name, DEFAULT_MAXSCALE_LOG_DIR); sprintf(env_name, "%s_%03d_binlog_dir", prefix, i); - env = getenv(env_name); - if (env == NULL) - { - sprintf(env_name, "%s_binlog_dir", prefix); - env = getenv(env_name); - } - if (env != NULL) - { - sprintf(maxscale_binlog_dir[i], "%s", env); - } - else - { - sprintf(maxscale_binlog_dir[i], "/var/lib/maxscale/Binlog_Service/"); - } + maxscale_binlog_dir[i] = readenv(env_name, DEFAULT_MAXSCALE_BINLOG_DIR); sprintf(env_name, "%s_%03d_maxadmin_password", prefix, i); - env = getenv(env_name); - if (env == NULL) - { - sprintf(env_name, "%s_maxadmin_password", prefix); - env = getenv(env_name); - } - if (env != NULL) - { - sprintf(maxadmin_password[i], "%s", env); - } - else - { - sprintf(maxadmin_password[i], "mariadb"); - } + maxadmin_password[i] = readenv(env_name, DEFAULT_MAXADMIN_PASSWORD); rwsplit_port[i] = 4006; readconn_master_port[i] = 4008; @@ -115,7 +66,6 @@ int Maxscales::read_env() return 0; } - int Maxscales::connect_rwsplit(int m) { if (use_ipv6) @@ -228,7 +178,7 @@ int Maxscales::restart_maxscale(int m) } else { - res =ssh_node(m, "service maxscale restart", true); + res = ssh_node(m, "service maxscale restart", true); } fflush(stdout); return res; @@ -240,9 +190,9 @@ int Maxscales::start_maxscale(int m) if (use_valgrind) { res = ssh_node_f(m, false, - "sudo --user=maxscale valgrind --leak-check=full --show-leak-kinds=all " - "--log-file=/%s/valgrind%02d.log --trace-children=yes " - "--track-origins=yes /usr/bin/maxscale", maxscale_log_dir[m], valgring_log_num); + "sudo --user=maxscale valgrind --leak-check=full --show-leak-kinds=all " + "--log-file=/%s/valgrind%02d.log --trace-children=yes " + "--track-origins=yes /usr/bin/maxscale", maxscale_log_dir[m], valgring_log_num); valgring_log_num++; } else @@ -485,7 +435,8 @@ void Maxscales::wait_for_monitor(int intervals, int m) auto get_ticks = [&](std::string name) { int rc; - char* ticks = ssh_node_output_f(m, false, &rc, "maxctrl api get monitors/%s data.attributes.ticks", name.c_str()); + char* ticks = ssh_node_output_f(m, false, &rc, "maxctrl api get monitors/%s data.attributes.ticks", + name.c_str()); char* ptr; int rval = strtol(ticks, &ptr, 10); @@ -515,7 +466,7 @@ void Maxscales::wait_for_monitor(int intervals, int m) ticks[name] = get_ticks(name); } - for (auto a: ticks) + for (auto a : ticks) { // Wait a maximum of 60 seconds for a single monitor interval for (int i = 0; i < 60; i++) diff --git a/maxscale-system-test/maxscales.h b/maxscale-system-test/maxscales.h index 815d5ef2a..038c081b0 100644 --- a/maxscale-system-test/maxscales.h +++ b/maxscale-system-test/maxscales.h @@ -1,10 +1,15 @@ -#ifndef MAXSCALES_H -#define MAXSCALES_H +#pragma once +#include #include "nodes.h" #include "mariadb_func.h" #include "mariadb_nodes.h" +#define DEFAULT_MAXSCALE_CNF "/etc/maxscale.cnf" +#define DEFAULT_MAXSCALE_LOG_DIR "/var/log/maxscale/" +#define DEFAULT_MAXSCALE_BINLOG_DIR "/var/lib/maxscale/Binlog_Service/" +#define DEFAULT_MAXADMIN_PASSWORD "mariadb" + class Maxscales: public Nodes { public: @@ -15,7 +20,9 @@ public: READCONN_SLAVE }; - Maxscales(const char *pref, const char *test_cwd, bool verbose, bool use_valgrind); + Maxscales(const char *pref, const char *test_cwd, bool verbose, bool use_valgrind, + std::__cxx11::string network_config); + int read_env(); /** @@ -76,29 +83,28 @@ public: /** * @brief maxadmin_Password Password to access Maxadmin tool */ - char maxadmin_password[256][256]; + char * maxadmin_password[256]; /** * @brief maxscale_cnf full name of Maxscale configuration file */ - char maxscale_cnf[256][4096]; + char * maxscale_cnf[256]; /** * @brief maxscale_log_dir name of log files directory */ - char maxscale_log_dir[256][4096]; + char * maxscale_log_dir[256]; /** * @brief maxscale_lbinog_dir name of binlog files (for binlog router) directory */ - char maxscale_binlog_dir[256][4096]; + char * maxscale_binlog_dir[256]; /** * @brief N_ports Default number of routers */ int N_ports[256]; - /** * @brief test_dir path to test application */ @@ -282,7 +288,4 @@ public: */ int valgring_log_num; - }; - -#endif // MAXSCALES_H diff --git a/maxscale-system-test/mdbci/README.md b/maxscale-system-test/mdbci/README.md index 33437498a..92d69c150 100644 --- a/maxscale-system-test/mdbci/README.md +++ b/maxscale-system-test/mdbci/README.md @@ -31,11 +31,11 @@ Template for this configuration is Another templates: +NOTE: templates 'nogalera' and 'onemaxscale' are removed. Please use 'default' and define MDBCI labels to limit the +number of started VMs + Template name|Description ---|--- - ```nogalera``` |only 1 VM for Maxscale and 4 for Master/Slaves| - ```twomaxscales``` |2 VMs for Maxscale and 4 for Master/Slaves| - ```onemaxscale``` |1 VM for Maxscale, 4 for Master/Slaves and 4 for Galera| ```big``` |1 VM for Maxscale, 8 for Master/Slaves and 4 for Galera| ```big15``` |1 VM for Maxscale, 15 for Master/Slaves and 4 for Galera| @@ -45,8 +45,7 @@ Template can contain references to any environmental variables - they all will be replaced with values before VMs starting The [maxscale-system-test/mdbci/run_test.sh](run_test.sh) script -brings test VMs configuration up and tries to execute -```maxscale-system-test``` using 'ctest'. +Executes ```maxscale-system-test``` using 'ctest'. Script can be executed without any parameters and without defining any environmental variables. @@ -58,12 +57,22 @@ VMs will not be destroyed after the tests. The name of test run (and name of VMs set) is generated based on ```box``` parameter and current date/time +Only needed VMs will be started. Every test has labels like ```REPL_BACKEND```, +```GALERA_BACKEND``` + +Test can be executed directly by calling its executable from command line or ```ctest``` +Every test checks running VMs, brings up VMs if they are not running, checks backend. +If backend is broken test tries to fix it. If attempt to fix backend failed test tries +to execute ```mdbci``` with ```--recreate``` option. In this case ```mdbci``` kills all VMs and +brings up new ones + ### Basic run_test.sh parameters Variable name|Meaning ---|--- ```target``` |name of binary repository to install Maxscale from| -```box``` |Vagrant box to be used to create VMs | +```box``` |Vagrant box to be used to create Maxscale VMs | +```backend_box``` |Vagrant box to be used to create backend VMs | ```test_set``` |Set of test to be executed in the 'ctest' format| ```version```|Version of DB server in Master/Slave backend| ```galera_version```|Version of DB server in Galera backend| @@ -71,7 +80,7 @@ Variable name|Meaning ```template```|Name of *.json.template file with VMs descriptions in MDBCI format| ```team_keys```|Path to the file with public ssh keys - this file is loaded to VMs| ```do_not_destroy_vm```|if 'yes' VMs stay alive after test| -```name```|The name of test run - any string to identify VMs set| +```mdbci_config_name```|The name of test run - any string to identify VMs set| For complete list of environmental variables see comments in @@ -97,38 +106,22 @@ If ```galera_version``` is not defined the value of ```version``` is used also f After execution of 'run_test.sh` by default VMs stay alive and other tests can be executed. -Test use environmental variables to get all infio about test setup (about VMs). +Test use ```${MDBCI_VM_PATH}/${mdbci_config_name}_network_config``` file to get all info about test setup (about VMs). -The script [maxscale-system-test/mdbci/set_env.sh](set_env.sh) -loads all needed values (IPs, paths to ssh keyfiles, -user names, etc) into environmental variables. Script uses -data from ```${MDBCI_VM_PATH}/${name}_network_config``` file -and also calls MDBCI commands. +NOTE: enviromental variables are not in use any more to describe backend. However test sets all these variables inside itself +and any process called by test code can use enviromental variables. This way can be used to create non-c++ tests (bach, python, etc). -Script have to be sourced: +TODO: describe 'non_native_setup` -```bash -source ./mdbci/set_env.sh $name -``` +The script [maxscale-system-test/mdbci/set_env.sh](set_env.sh) is not in use any more. -or - -```bash -. ./mdbci/set_env.sh $name -``` - -After it, any 'maxscale-system-test ' can be executed, e.g.: - -```bash -./sql_queries -``` ### Basic MDBCI and Vagrant operations #### Restore ${name}.config_file ```bash -${mdbci_dir}/mdbci show network_config $name +${mdbci_dir}/mdbci show network_config ${mdbci_config_name} ``` #### Suspend VMs @@ -137,45 +130,29 @@ Before rebooting computer it is recommended to suspend Vagrant-controlled VMs ```bash -cd ${MDBCI_VM_PATH}/$name +cd ${MDBCI_VM_PATH}/${mdbci_config_name} vagrant suspend ``` #### Resume suspended VMs ```bash -cd ${MDBCI_VM_PATH}/$name +cd ${MDBCI_VM_PATH}/${mdbci_config_name} vagrant resume ``` #### Destroying VMs ```bash -${mdbci_dir}/mdbci destroy $name +${mdbci_dir}/mdbci destroy ${mdbci_config_name} ``` -#### Restoring backend +#### Start all backend VMs -Every test before any actions checks backend and tries to restore it if its broken. -To restore backend separatelly and for intial backend setup check_backend' can be used: +Every test before any actions checks backend and brings up needed VMs. +To bring up all backend VMs without running excuting any test 'check_backend' can be used: ```bash -. ./mdbci/set_env.sh $name -./check_backend -``` - -#### Restoring VMs from snapshot - -'run_test.sh' makes snapshot of all VMs before tests. The name of snapshot is 'clean'. - -In case of problem, after 'snapshot revert' it is recommended to re-create -${name}_network_config file, re-load environmental variables and run -'check_backend' - -```bash -${mdbci_dir}/mdbci snapshot revert --path-to-nodes $name --snapshot-name clean -${mdbci_dir}/mdbci show network_config $name -. ./mdbci/set_env.sh $name ./check_backend ``` diff --git a/maxscale-system-test/mdbci/copy_logs.sh b/maxscale-system-test/mdbci/copy_logs.sh index a3a9ba3db..be8728d62 100755 --- a/maxscale-system-test/mdbci/copy_logs.sh +++ b/maxscale-system-test/mdbci/copy_logs.sh @@ -1,5 +1,5 @@ set -x rsync -a --no-o --no-g LOGS ${logs_publish_dir} chmod a+r ${logs_publish_dir}/* -cp -r ${MDBCI_VM_PATH}/$name ${logs_publish_dir} -cp ${MDBCI_VM_PATH}/${name}.json ${logs_publish_dir} +cp -r ${MDBCI_VM_PATH}/${mdbci_config_name} ${logs_publish_dir} +cp ${MDBCI_VM_PATH}/${mdbci_config_name}.json ${logs_publish_dir} diff --git a/maxscale-system-test/mdbci/create_config.sh b/maxscale-system-test/mdbci/create_config.sh index 697ff4cac..5cf94ce81 100755 --- a/maxscale-system-test/mdbci/create_config.sh +++ b/maxscale-system-test/mdbci/create_config.sh @@ -7,14 +7,11 @@ export script_dir="$(dirname $(readlink -f $0))" . ${script_dir}/set_run_test_variables.sh -export provider=`${mdbci_dir}/mdbci show provider $box --silent 2> /dev/null` -export backend_box=${backend_box:-"centos_7_"$provider} - if [ "$product" == "mysql" ] ; then export cnf_path=${script_dir}/cnf/mysql56 fi -${mdbci_dir}/mdbci destroy $name +mdbci destroy $name mkdir -p ${MDBCI_VM_PATH}/$name export cnf_path="${MDBCI_VM_PATH}/$name/cnf/" @@ -27,22 +24,20 @@ fi $(<${script_dir}/templates/${template}.json.template) " 2> /dev/null > ${MDBCI_VM_PATH}/${name}.json -${mdbci_dir}/mdbci --override --template ${MDBCI_VM_PATH}/${name}.json generate $name +mdbci --override --template ${MDBCI_VM_PATH}/${name}.json generate $name mkdir ${MDBCI_VM_PATH}/$name/cnf cp -r ${script_dir}/cnf/* ${MDBCI_VM_PATH}/$name/cnf/ echo "running vagrant up $provider" -${mdbci_dir}/mdbci up $name --attempts 3 +mdbci up $name --attempts 3 --labels MAXSCALE if [ $? != 0 ]; then echo "Error creating configuration" - rm -f ~/vagrant_lock exit 1 fi #cp ~/build-scripts/team_keys . -${mdbci_dir}/mdbci public_keys --key ${team_keys} $name +mdbci public_keys --key ${team_keys} $name -rm -f ~/vagrant_lock exit 0 diff --git a/maxscale-system-test/mdbci/run_test.sh b/maxscale-system-test/mdbci/run_test.sh index 16574e342..68e3958d1 100755 --- a/maxscale-system-test/mdbci/run_test.sh +++ b/maxscale-system-test/mdbci/run_test.sh @@ -16,13 +16,6 @@ # If it is not defined, name will be automatically genereted # using $box and current date and time -# $ci_url - URL to Maxscale CI repository -# (default "http://max-tst-01.mariadb.com/ci-repository/") -# if build is done also locally and binaries are not uploaded to -# max-tst-01.mariadb.com $ci_url should toint to local web server -# e.g. http://192.168.122.1/repository (IP should be a host IP in the -# virtual network (not 127.0.0.1)) - # $product - 'mariadb' or 'mysql' # $version - version of backend DB (e.g. '10.1', '10.2') @@ -36,7 +29,7 @@ # $team_keys - path to the file with open ssh keys to be # installed on all VMs (default ${HOME}/team_keys) -# $don_not_destroy_vm - if 'yes' VM won't be destored afther the test +# $do_not_destroy_vm - if 'yes' VM won't be destored afther the test # $test_set - parameters to be send to 'ctest' (e.g. '-I 1,100', # '-LE UNSTABLE' @@ -58,58 +51,40 @@ export script_dir="$(dirname $(readlink -f $0))" rm -rf LOGS export target=`echo $target | sed "s/?//g"` -export name=`echo $name | sed "s/?//g"` +export mdbci_config_name=`echo ${mdbci_config_name} | sed "s/?//g"` + +export provider=`mdbci show provider $box --silent 2> /dev/null` +export backend_box=${backend_box:-"centos_7_"$provider} + +mdbci destroy ${mdbci_config_name} . ${script_dir}/configure_log_dir.sh -${script_dir}/create_config.sh -res=$? - ulimit -c unlimited -if [ $res == 0 ] ; then - . ${script_dir}/set_env.sh $name - cd ${script_dir}/.. - mkdir build && cd build - cmake .. -DBUILDNAME=$name -DCMAKE_BUILD_TYPE=Debug - make -set -x - echo ${test_set} | grep "NAME#" - if [ $? == 0 ] ; then - named_test=`echo ${test_set} | sed "s/NAME#//"` - echo ${named_test} | grep "\./" - if [ $? != 0 ] ; then - named_test="./"${named_test} - fi - fi +cd ${script_dir}/.. +mkdir build && cd build +cmake .. -DBUILDNAME={mdbci_config_name} -DCMAKE_BUILD_TYPE=Debug +make - if [ ! -z "${named_test}" ] ; then - eval ${named_test} - else - ./check_backend - if [ $? != 0 ]; then - echo "Backend broken!" - if [ "${do_not_destroy_vm}" != "yes" ] ; then - ${mdbci_dir}/mdbci destroy $name - fi - rm -f ~/vagrant_lock - exit 1 - fi - ${mdbci_dir}/mdbci snapshot take --path-to-nodes $name --snapshot-name clean - ctest -VV -D Nightly ${test_set} +echo ${test_set} | grep "NAME#" +if [ $? == 0 ] ; then + named_test=`echo ${test_set} | sed "s/NAME#//"` + echo ${named_test} | grep "\./" + if [ $? != 0 ] ; then + named_test="./"${named_test} fi - cp core.* ${logs_publish_dir} - ${script_dir}/copy_logs.sh - cd $dir -else - echo "Failed to create VMs, exiting" - if [ "${do_not_destroy_vm}" != "yes" ] ; then - ${mdbci_dir}/mdbci destroy $name - fi - rm -f ~/vagrant_lock - exit 1 fi +if [ ! -z "${named_test}" ] ; then + eval ${named_test} +else + ctest -VV -D Nightly ${test_set} +fi +cp core.* ${logs_publish_dir} +${script_dir}/copy_logs.sh +cd $dir + if [ "${do_not_destroy_vm}" != "yes" ] ; then - ${mdbci_dir}/mdbci destroy $name + mdbci destroy ${mdbci_config_name} echo "clean up done!" fi diff --git a/maxscale-system-test/mdbci/run_test_snapshot.sh b/maxscale-system-test/mdbci/run_test_snapshot.sh index 485cbc871..aeba37bed 100755 --- a/maxscale-system-test/mdbci/run_test_snapshot.sh +++ b/maxscale-system-test/mdbci/run_test_snapshot.sh @@ -19,19 +19,19 @@ export dir=`pwd` export script_dir="$(dirname $(readlink -f $0))" . ${script_dir}/set_run_test_variables.sh -export name="$box-$product-$version-permanent" +export mdbci_config_name="$box-$product-$version-permanent" export snapshot_name=${snapshot_name:-"clean"} rm -rf LOGS export target=`echo $target | sed "s/?//g"` -export name=`echo $name | sed "s/?//g"` +export mdbci_config_name=`echo ${mdbci_config_name} | sed "s/?//g"` . ${script_dir}/configure_log_dir.sh # Setting snapshot_lock -export snapshot_lock_file=${MDBCI_VM_PATH}/${name}_snapshot_lock +export snapshot_lock_file=${MDBCI_VM_PATH}/${mdbci_config_name}_snapshot_lock if [ -f ${snapshot_lock_file} ]; then echo "Snapshot is locked, waiting ..." fi @@ -43,34 +43,18 @@ done touch ${snapshot_lock_file} echo $JOB_NAME-$BUILD_NUMBER >> ${snapshot_lock_file} -${mdbci_dir}/mdbci snapshot revert --path-to-nodes $name --snapshot-name $snapshot_name +mdbci snapshot revert --path-to-nodes ${mdbci_config_name} --snapshot-name ${snapshot_name} if [ $? != 0 ]; then - ${mdbci_dir}/mdbci destroy $name - ${MDBCI_VM_PATH}/scripts/clean_vms.sh $name + mdbci destroy ${mdbci_config_name} + ${MDBCI_VM_PATH}/scripts/clean_vms.sh ${mdbci_config_name} - ${script_dir}/create_config.sh - checkExitStatus $? "Error creating configuration" $snapshot_lock_file + new_config=true - echo "Creating snapshot from new config" - ${mdbci_dir}/mdbci snapshot take --path-to-nodes $name --snapshot-name $snapshot_name -fi - -. ${script_dir}/set_env.sh "$name" - -if [ ${maxscale_N} -gt 1 ] ; then - maxscales_vm=`env | grep maxscale | grep network | sed 's/_network.*//' | grep "_"` -else - maxscales_vm="maxscale" fi for maxscale_vm_name in ${maxscales_vm} do - ${mdbci_dir}/mdbci sudo --command 'yum remove maxscale -y' $name/${maxscale_vm_name} - ${mdbci_dir}/mdbci sudo --command 'yum clean all' $name/${maxscale_vm_name} - - ${mdbci_dir}/mdbci setup_repo --product maxscale_ci --product-version ${target} $name/${maxscale_vm_name} - ${mdbci_dir}/mdbci install_product --product maxscale_ci $name/${maxscale_vm_name} checkExitStatus $? "Error installing Maxscale" $snapshot_lock_file done @@ -83,9 +67,15 @@ mkdir build && cd build cmake .. -DBUILDNAME=$JOB_NAME-$BUILD_NUMBER-$target -DBUILD_SYSTEM_TESTS=Y -DCMAKE_BUILD_TYPE=Debug make -./check_backend --restart-galera - +./check_backend --restart-galera --reinstall-maxscale checkExitStatus $? "Failed to check backends" $snapshot_lock_file + +if [${new_config}] == "true" ; then + echo "Creating snapshot from new config" + mdbci snapshot take --path-to-nodes ${mdbci_config_name} --snapshot-name $snapshot_name +fi + + ulimit -c unlimited ctest $test_set -VV -D Nightly cp core.* ${logs_publish_dir} diff --git a/maxscale-system-test/mdbci/set_env.sh b/maxscale-system-test/mdbci/set_env.sh index 7f1f14fa5..9d649d8ec 100644 --- a/maxscale-system-test/mdbci/set_env.sh +++ b/maxscale-system-test/mdbci/set_env.sh @@ -1,87 +1,2 @@ #!/bin/bash -set -x -echo $* -export MDBCI_VM_PATH=${MDBCI_VM_PATH:-$HOME/vms} -export mdbci_dir=${mdbci_dir:-"$HOME/mdbci/"} - -export config_name="$1" -if [ -z $1 ] ; then - config_name="test1" -fi - -export curr_dir=`pwd` - -export maxscale_binlog_dir="/var/lib/maxscale/Binlog_Service" -export maxdir="/usr/bin/" -export maxdir_bin="/usr/bin/" -export maxscale_cnf="/etc/maxscale.cnf" -export maxscale_log_dir="/var/log/maxscale/" - -# Number of nodes -export galera_N=`cat "$MDBCI_VM_PATH/$config_name"_network_config | grep galera | grep network | wc -l` -export node_N=`cat "$MDBCI_VM_PATH/$config_name"_network_config | grep node | grep network | wc -l` -export maxscale_N=`cat "$MDBCI_VM_PATH/$config_name"_network_config | grep maxscale | grep network | wc -l` -sed "s/^/export /g" "$MDBCI_VM_PATH/$config_name"_network_config > "$curr_dir"/"$config_name"_network_config_export -source "$curr_dir"/"$config_name"_network_config_export -rm "$curr_dir"/"$config_name"_network_config_export - - -# User name and Password for Master/Slave replication setup (should have all PRIVILEGES) -export node_user="skysql" -export node_password="skysql" - -# User name and Password for Galera setup (should have all PRIVILEGES) -export galera_user="skysql" -export galera_password="skysql" - -export maxscale_user="skysql" -export maxscale_password="skysql" - -export maxadmin_password="mariadb" - -for prefix in "node" "galera" "maxscale" -do - N_var="$prefix"_N - Nx=${!N_var} - N=`expr $Nx - 1` - for i in $(seq 0 $N) - do - num=`printf "%03d" $i` - eval 'export "$prefix"_"$num"_port=3306' - eval 'export "$prefix"_"$num"_access_sudo=sudo' - - start_cmd_var="$prefix"_"$num"_start_db_command - stop_cmd_var="$prefix"_"$num"_stop_db_command - eval 'export $start_cmd_var="service mysql start "' - eval 'export $stop_cmd_var="service mysql stop "' - eval 'export "$prefix"_"$num"_start_vm_command="cd ${MDBCI_VM_PATH}/$config_name;vagrant resume ${prefix}_$num ; cd $curr_dir"' - eval 'export "$prefix"_"$num"_stop_vm_command="cd ${MDBCI_VM_PATH}/$config_name;vagrant suspend ${prefix}_$num ; cd $curr_dir"' - done -done - - -export maxscale_access_sudo="sudo " - -# IP Of MaxScale machine -if [ ${maxscale_N} -gt 1 ] ; then - export maxscale_whoami=$maxscale_000_whoami - export maxscale_network=$maxscale_000_network - export maxscale_keyfile=$maxscale_000_keyfile - export maxscale_sshkey=$maxscale_000_keyfile -fi - -export maxscale_IP=$maxscale_network -export maxscale_access_user=$maxscale_whoami - -# Sysbench directory (should be sysbench >= 0.5) -sb=`which sysbench` -export sysbench_dir=$(dirname ${sb}) -#export sysbench_dir=${sysbench_dir:-""} - -export ssl=true - -export take_snapshot_command="${mdbci_dir}/mdbci snapshot take --path-to-nodes ${config_name} --snapshot-name " -export revert_snapshot_command="${mdbci_dir}/mdbci snapshot revert --path-to-nodes ${config_name} --snapshot-name " -#export use_snapshots=yes - -set +x +export PATH=$PATH:$HOME/mdbci/ diff --git a/maxscale-system-test/mdbci/set_run_test_variables.sh b/maxscale-system-test/mdbci/set_run_test_variables.sh index 152d4f229..8a1a323c3 100644 --- a/maxscale-system-test/mdbci/set_run_test_variables.sh +++ b/maxscale-system-test/mdbci/set_run_test_variables.sh @@ -1,31 +1,15 @@ #!/bin/bash - -export MDBCI_VM_PATH=${MDBCI_VM_PATH:-$HOME/vms} -mkdir -p $MDBCI_VM_PATH -echo "MDBCI_VM_PATH=$MDBCI_VM_PATH" - -export box=${box:-"centos_7_libvirt"} -echo "box=$box" - -export template=${template:-"default"} - +export MDBCI_VM_PATH=${MDBCI_VM_PATH:-"$HOME/vms/"} export curr_date=`date '+%Y-%m-%d_%H-%M'` +export mdbci_config_name=${name:-$box-${curr_date}} -export name=${name:-$box-${curr_date}} +export PATH=$PATH:$HOME/mdbci/ -export mdbci_dir=${mdbci_dir:-"$HOME/mdbci/"} -export ci_url=${ci_url:-"http://max-tst-01.mariadb.com/ci-repository/"} - -export product=${product:-"mariadb"} -export version=${version:-"10.2"} -export target=${target:-"develop"} -export vm_memory=${vm_memory:-"2048"} export JOB_NAME=${JOB_NAME:-"local_test"} export BUILD_NUMBER=${BUILD_NUMBER:-`date '+%Y%m%d%H%M'`} export BUILD_TAG=${BUILD_TAG:-jenkins-${JOB_NAME}-${BUILD_NUMBER}} export team_keys=${team_keys:-${HOME}/team_keys} -export galera_version=${galera_version:-$version} export do_not_destroy_vm=${do_not_destroy_vm:-"yes"} #export test_set=${test_set:-"-LE UNSTABLE"} export test_set=${test_set:-"-I 1,5"} diff --git a/maxscale-system-test/mdbci/templates/big.json.template b/maxscale-system-test/mdbci/templates/big.json.template index eb7c36901..19d88b78f 100644 --- a/maxscale-system-test/mdbci/templates/big.json.template +++ b/maxscale-system-test/mdbci/templates/big.json.template @@ -3,6 +3,9 @@ { "hostname" : "node000", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -16,6 +19,9 @@ { "hostname" : "node001", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -28,6 +34,9 @@ { "hostname" : "node002", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -40,6 +49,9 @@ { "hostname" : "node003", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -51,6 +63,9 @@ { "hostname" : "node004", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -62,6 +77,9 @@ { "hostname" : "node005", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -73,6 +91,9 @@ { "hostname" : "node006", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -84,6 +105,9 @@ { "hostname" : "node007", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -96,6 +120,9 @@ { "hostname" : "galera000", "box" : "centos_7_aws", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -108,6 +135,9 @@ { "hostname" : "galera001", "box" : "centos_7_aws", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -120,6 +150,9 @@ { "hostname" : "galera002", "box" : "centos_7_aws", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -132,6 +165,9 @@ { "hostname" : "galera003", "box" : "centos_7_aws", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -140,10 +176,13 @@ } }, - "maxscale" : + "maxscale_000" : { "hostname" : "maxscale", "box" : "centos_7_aws_large", + "labels" : [ + "MAXSCALE" + ], "product" : { "name" : "maxscale_ci", "version" : "${target}" diff --git a/maxscale-system-test/mdbci/templates/big15.json.template b/maxscale-system-test/mdbci/templates/big15.json.template index 0fe08cf4d..d0dd01e97 100644 --- a/maxscale-system-test/mdbci/templates/big15.json.template +++ b/maxscale-system-test/mdbci/templates/big15.json.template @@ -3,6 +3,9 @@ { "hostname" : "node_000", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -16,6 +19,9 @@ { "hostname" : "node_001", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -28,6 +34,9 @@ { "hostname" : "node_002", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -40,6 +49,9 @@ { "hostname" : "node_003", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -51,6 +63,9 @@ { "hostname" : "node_004", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -62,6 +77,9 @@ { "hostname" : "node_005", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -73,6 +91,9 @@ { "hostname" : "node_006", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -84,6 +105,9 @@ { "hostname" : "node_007", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -95,6 +119,9 @@ { "hostname" : "node_008", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -106,6 +133,9 @@ { "hostname" : "node_009", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -117,6 +147,9 @@ { "hostname" : "node_0010", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -128,6 +161,9 @@ { "hostname" : "node_0011", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -139,6 +175,9 @@ { "hostname" : "node_0012", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -150,6 +189,9 @@ { "hostname" : "node_0013", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -161,6 +203,9 @@ { "hostname" : "node_0014", "box" : "centos_7_aws_large", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -173,6 +218,9 @@ { "hostname" : "galera_000", "box" : "centos_7_aws", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -185,6 +233,9 @@ { "hostname" : "galera_001", "box" : "centos_7_aws", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -197,6 +248,9 @@ { "hostname" : "galera_002", "box" : "centos_7_aws", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -209,6 +263,9 @@ { "hostname" : "galera_003", "box" : "centos_7_aws", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -217,10 +274,13 @@ } }, - "maxscale" : + "maxscale_000" : { "hostname" : "maxscale", "box" : "centos_7_aws_large", + "labels" : [ + "MAXSCALE" + ], "product" : { "name" : "maxscale_ci", "version" : "${target}" diff --git a/maxscale-system-test/mdbci/templates/default.json.template b/maxscale-system-test/mdbci/templates/default.json.template index cb670b99d..306288cb2 100644 --- a/maxscale-system-test/mdbci/templates/default.json.template +++ b/maxscale-system-test/mdbci/templates/default.json.template @@ -4,6 +4,9 @@ "hostname" : "node000", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -18,6 +21,9 @@ "hostname" : "node001", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -31,6 +37,9 @@ "hostname" : "node002", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -44,6 +53,9 @@ "hostname" : "node003", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "labels" : [ + "REPL_BACKEND" + ], "product" : { "name": "${product}", "version": "${version}", @@ -57,6 +69,9 @@ "hostname" : "galera000", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -70,6 +85,9 @@ "hostname" : "galera001", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -83,6 +101,9 @@ "hostname" : "galera002", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -96,6 +117,9 @@ "hostname" : "galera003", "box" : "${backend_box}", "memory_size" : "${vm_memory}", + "labels" : [ + "GALERA_BACKEND" + ], "product" : { "name": "galera", "version": "${galera_version}", @@ -109,6 +133,9 @@ "hostname" : "maxscale", "box" : "${box}", "memory_size" : "${vm_memory}", + "labels" : [ + "MAXSCALE" + ], "product" : { "name" : "maxscale_ci", "version" : "${target}" @@ -121,6 +148,9 @@ "hostname" : "maxscale2", "box" : "${box}", "memory_size" : "${vm_memory}", + "labels" : [ + "SECOND_MAXSCALE" + ], "product" : { "name" : "maxscale_ci", "version" : "${target}" diff --git a/maxscale-system-test/mdbci/templates/nogalera.json.template b/maxscale-system-test/mdbci/templates/nogalera.json.template deleted file mode 100644 index e8b11d30b..000000000 --- a/maxscale-system-test/mdbci/templates/nogalera.json.template +++ /dev/null @@ -1,66 +0,0 @@ -{ - "node_000" : - { - "hostname" : "node000", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server1.cnf", - "cnf_template_path": "${cnf_path}" - } - - }, - - "node_001" : - { - "hostname" : "node001", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server2.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "node_002" : - { - "hostname" : "node002", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server3.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "node_003" : - { - "hostname" : "node003", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server4.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "maxscale_000" : - { - "hostname" : "maxscale1", - "box" : "${box}", - "memory_size" : "${vm_memory}", - "product" : { - "name" : "maxscale_ci", - "version" : "${target}" - } - - } -} diff --git a/maxscale-system-test/mdbci/templates/onemaxscale.json.template b/maxscale-system-test/mdbci/templates/onemaxscale.json.template deleted file mode 100644 index 1523eb6c2..000000000 --- a/maxscale-system-test/mdbci/templates/onemaxscale.json.template +++ /dev/null @@ -1,118 +0,0 @@ -{ - "node_000" : - { - "hostname" : "node000", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server1.cnf", - "cnf_template_path": "${cnf_path}" - } - - }, - - "node_001" : - { - "hostname" : "node001", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server2.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "node_002" : - { - "hostname" : "node002", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server3.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "node_003" : - { - "hostname" : "node003", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server4.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "galera_000" : - { - "hostname" : "galera000", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "galera", - "version": "${galera_version}", - "cnf_template" : "galera_server1.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "galera_001" : - { - "hostname" : "galera001", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "galera", - "version": "${galera_version}", - "cnf_template" : "galera_server2.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "galera_002" : - { - "hostname" : "galera002", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "galera", - "version": "${galera_version}", - "cnf_template" : "galera_server3.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "galera_003" : - { - "hostname" : "galera003", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "galera", - "version": "${galera_version}", - "cnf_template" : "galera_server4.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "maxscale" : - { - "hostname" : "maxscale", - "box" : "${box}", - "memory_size" : "${vm_memory}", - "product" : { - "name" : "maxscale_ci", - "version" : "${target}" - } - - } -} diff --git a/maxscale-system-test/mdbci/templates/twomaxscales.json.template b/maxscale-system-test/mdbci/templates/twomaxscales.json.template deleted file mode 100644 index a9ddc64f2..000000000 --- a/maxscale-system-test/mdbci/templates/twomaxscales.json.template +++ /dev/null @@ -1,78 +0,0 @@ -{ - "node_000" : - { - "hostname" : "node000", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server1.cnf", - "cnf_template_path": "${cnf_path}" - } - - }, - - "node_001" : - { - "hostname" : "node001", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server2.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "node_002" : - { - "hostname" : "node002", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server3.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "node_003" : - { - "hostname" : "node003", - "box" : "${backend_box}", - "memory_size" : "${vm_memory}", - "product" : { - "name": "${product}", - "version": "${version}", - "cnf_template" : "server4.cnf", - "cnf_template_path": "${cnf_path}" - } - }, - - "maxscale_000" : - { - "hostname" : "maxscale", - "box" : "${box}", - "memory_size" : "${vm_memory}", - "product" : { - "name" : "maxscale_ci", - "version" : "${target}" - } - - }, - - "maxscale_001" : - { - "hostname" : "maxscale", - "box" : "${box}", - "memory_size" : "${vm_memory}", - "product" : { - "name" : "maxscale_ci", - "version" : "${target}" - } - - } -} diff --git a/maxscale-system-test/mxs1776_ps_exec_hang.cpp b/maxscale-system-test/mxs1776_ps_exec_hang.cpp index b9fdb4548..f96fdeea2 100644 --- a/maxscale-system-test/mxs1776_ps_exec_hang.cpp +++ b/maxscale-system-test/mxs1776_ps_exec_hang.cpp @@ -86,7 +86,7 @@ int main(int argc, char* argv[]) bool rval = true; if (mysql_stmt_execute(stmt) || - mysql_stmt_bind_result(stmt, &bind.bind)) + mysql_stmt_bind_result(stmt, &bind.bind)) { rval = false; } @@ -106,10 +106,10 @@ int main(int argc, char* argv[]) bool rval = true; if (mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt)) + mysql_stmt_execute(stmt) || + mysql_stmt_execute(stmt) || + mysql_stmt_execute(stmt) || + mysql_stmt_execute(stmt)) { rval = false; } @@ -124,10 +124,10 @@ int main(int argc, char* argv[]) bool rval = true; if (mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_bind_result(stmt, &bind.bind)) + mysql_stmt_execute(stmt) || + mysql_stmt_execute(stmt) || + mysql_stmt_execute(stmt) || + mysql_stmt_bind_result(stmt, &bind.bind)) { rval = false; } @@ -147,10 +147,10 @@ int main(int argc, char* argv[]) bool rval = true; if (mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_bind_result(stmt, &bind.bind)) + mysql_stmt_execute(stmt) || + mysql_stmt_execute(stmt) || + mysql_stmt_execute(stmt) || + mysql_stmt_bind_result(stmt, &bind.bind)) { rval = false; } @@ -170,11 +170,11 @@ int main(int argc, char* argv[]) bool rval = true; if (mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_stmt_execute(stmt) || - mysql_query(conn, "SET @a = 1")) + mysql_stmt_execute(stmt) || + mysql_stmt_execute(stmt) || + mysql_stmt_execute(stmt) || + mysql_stmt_execute(stmt) || + mysql_query(conn, "SET @a = 1")) { rval = false; } diff --git a/maxscale-system-test/mxs1804_long_ps_hang.cpp b/maxscale-system-test/mxs1804_long_ps_hang.cpp index 93ee83d14..50f5adeea 100644 --- a/maxscale-system-test/mxs1804_long_ps_hang.cpp +++ b/maxscale-system-test/mxs1804_long_ps_hang.cpp @@ -34,7 +34,7 @@ int main(int argc, char** argv) MYSQL_STMT* stmt = mysql_stmt_init(test.maxscales->conn_rwsplit[0]); test.expect(mysql_stmt_prepare(stmt, sqlstr, strlen(sqlstr)) != 0, - "Prepare should fail in 2.2 but not hang. Error: %s", + "Prepare should fail in 2.2 but not hang. Error: %s", mysql_stmt_error(stmt)); mysql_stmt_close(stmt); diff --git a/maxscale-system-test/mxs2043_select_for_update.cpp b/maxscale-system-test/mxs2043_select_for_update.cpp index 2b6c9e518..b42ac60bd 100644 --- a/maxscale-system-test/mxs2043_select_for_update.cpp +++ b/maxscale-system-test/mxs2043_select_for_update.cpp @@ -150,7 +150,7 @@ int main(int argc, char* argv[]) if (create_user(test, pMysql)) { int rv = test.repl->connect(); - test.repl->sync_slaves(); + test.repl->sync_slaves(); test.expect(rv == 0, "Could not connect to MS."); diff --git a/maxscale-system-test/mxs2106_avro_null.cpp b/maxscale-system-test/mxs2106_avro_null.cpp index 4c8ad169d..a82d5d557 100644 --- a/maxscale-system-test/mxs2106_avro_null.cpp +++ b/maxscale-system-test/mxs2106_avro_null.cpp @@ -39,22 +39,22 @@ int main(int argc, char** argv) test.expect(conn.connect("test.test1"), "Failed to connect"); auto check = [&](const std::string& name) { - static int i = 1; - CDC::SRow row = conn.read(); + static int i = 1; + CDC::SRow row = conn.read(); - if (row) - { - test.expect(row->is_null(name), - "%d: `%s` is not null: %s", - i++, - name.c_str(), - row->value(name).c_str()); - } - else - { - test.tprintf("Error: %s", conn.error().c_str()); - } - }; + if (row) + { + test.expect(row->is_null(name), + "%d: `%s` is not null: %s", + i++, + name.c_str(), + row->value(name).c_str()); + } + else + { + test.tprintf("Error: %s", conn.error().c_str()); + } + }; // The three inserts check("some_date"); diff --git a/maxscale-system-test/mxs2111_auth_string.cpp b/maxscale-system-test/mxs2111_auth_string.cpp index 50d008ee8..afcd1813e 100644 --- a/maxscale-system-test/mxs2111_auth_string.cpp +++ b/maxscale-system-test/mxs2111_auth_string.cpp @@ -9,7 +9,7 @@ int main(int argc, char **argv) TestConnections::require_repl_version("10.2.0"); TestConnections test(argc, argv); - auto batch = [&](std::vector queries){ + auto batch = [&](std::vector queries) { test.maxscales->connect(); for (const auto& a: queries) { diff --git a/maxscale-system-test/mxs244_prepared_stmt_loop.cpp b/maxscale-system-test/mxs244_prepared_stmt_loop.cpp index 896175ebe..a7cd970ca 100644 --- a/maxscale-system-test/mxs244_prepared_stmt_loop.cpp +++ b/maxscale-system-test/mxs244_prepared_stmt_loop.cpp @@ -21,7 +21,6 @@ int main(int argc, char *argv[]) int r = (Test->smoke) ? 1 : 3; Test->set_timeout(5); - Test->repl->connect(); Test->maxscales->connect_maxscale(0); MYSQL * router[3]; router[0] = Test->maxscales->conn_rwsplit[0]; diff --git a/maxscale-system-test/mxs37_table_privilege.cpp b/maxscale-system-test/mxs37_table_privilege.cpp index a2e03f2a5..59bb5b098 100644 --- a/maxscale-system-test/mxs37_table_privilege.cpp +++ b/maxscale-system-test/mxs37_table_privilege.cpp @@ -28,7 +28,14 @@ int main(int argc, char *argv[]) execute_query(Test->maxscales->conn_rwsplit[0], "GRANT SELECT ON test.t1 TO 'table_privilege'@'%%'"); Test->stop_timeout(); - Test->repl->sync_slaves(); + if (Test->repl) + { + Test->repl->sync_slaves(); + } + else + { + Test->galera->sync_slaves(); + } Test->tprintf("Trying to connect using this user\n"); Test->set_timeout(20); diff --git a/maxscale-system-test/mxs585.py b/maxscale-system-test/mxs585.py index 49b1d094f..772a0b209 100755 --- a/maxscale-system-test/mxs585.py +++ b/maxscale-system-test/mxs585.py @@ -6,7 +6,7 @@ import maxpython -test1 = maxpython.MaxScaleTest("mxs585.py") +test1 = maxpython.MaxScaleTest("mxs585.py1") for i in range(0,100): if i % 10 == 0: diff --git a/maxscale-system-test/mxs682_cyrillic.cpp b/maxscale-system-test/mxs682_cyrillic.cpp index 0a4d83514..d69bcf4ca 100644 --- a/maxscale-system-test/mxs682_cyrillic.cpp +++ b/maxscale-system-test/mxs682_cyrillic.cpp @@ -33,9 +33,16 @@ int main(int argc, char *argv[]) test.maxscales->disconnect(); test.stop_timeout(); - test.repl->connect(); - test.repl->sync_slaves(); - test.repl->disconnect(); + if (test.repl) + { + test.repl->connect(); + test.repl->sync_slaves(); + test.repl->disconnect(); + } + else + { + sleep(10); + } test.set_timeout(60); test.maxscales->connect(); @@ -45,7 +52,7 @@ int main(int argc, char *argv[]) test.maxscales->disconnect(); nodes->connect(); - for (int i = 0; i < test.repl->N; i++) + for (int i = 0; i < nodes->N; i++) { check_val(nodes->nodes[i], test); } diff --git a/maxscale-system-test/mxs791.sh b/maxscale-system-test/mxs791.sh index ada409f45..4ed4e831c 100755 --- a/maxscale-system-test/mxs791.sh +++ b/maxscale-system-test/mxs791.sh @@ -4,14 +4,6 @@ ## @file mxs791.sh Simple connect test in bash ## - connects to Maxscale, checks that defined in cmd line DB is selected -rp=`realpath $0` -export test_dir=`pwd` -export test_name="mxs791.sh" -echo test name is $test_name +$src_dir/mxs791_base.sh -$test_dir/mxs791_base.sh -res=$? - -$test_dir/copy_logs.sh $test_name -exit $res diff --git a/maxscale-system-test/mxs791_base.sh b/maxscale-system-test/mxs791_base.sh index 8f8857c8e..b2f2d3a9d 100755 --- a/maxscale-system-test/mxs791_base.sh +++ b/maxscale-system-test/mxs791_base.sh @@ -1,32 +1,26 @@ #!/bin/bash rp=`realpath $0` -export src_dir=`dirname $rp` -$PWD/non_native_setup $test_name -if [ $? -ne 0 ] ; then - echo "configuring maxscale failed" - exit 1 -fi export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem" res=0 echo "Trying RWSplit" -echo "show tables" | mysql -u$maxscale_user -p$maxscale_password -h $maxscale_IP -P 4006 $ssl_option test +echo "show tables" | mysql -u$maxscale_user -p$maxscale_password -h ${maxscale_000_network} -P 4006 $ssl_option test if [ $? != 0 ] ; then res=1 echo "Can't connect to DB 'test'" fi echo "Trying ReadConn master" -echo "show tables" | mysql -u$maxscale_user -p$maxscale_password -h $maxscale_IP -P 4008 $ssl_options test +echo "show tables" | mysql -u$maxscale_user -p$maxscale_password -h ${maxscale_000_network} -P 4008 $ssl_options test if [ $? != 0 ] ; then res=1 echo "Can't connect to DB 'test'" fi echo "Trying ReadConn slave" -echo "show tables" | mysql -u$maxscale_user -p$maxscale_password -h $maxscale_IP -P 4009 $ssl_options test +echo "show tables" | mysql -u$maxscale_user -p$maxscale_password -h ${maxscale_000_network} -P 4009 $ssl_options test if [ $? != 0 ] ; then res=1 echo "Can't connect to DB 'test'" diff --git a/maxscale-system-test/mxs791_galera.sh b/maxscale-system-test/mxs791_galera.sh deleted file mode 100755 index 13955bfe3..000000000 --- a/maxscale-system-test/mxs791_galera.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -### -## @file mxs791.sh Simple connect test in bash -## - connects to Maxscale, checks that defined in cmd line DB is selected - -srcdir=$(dirname $(realpath $0)) -export test_dir=`pwd` -export test_name="mxs791_galera.sh" -echo test name is $test_name - -$srcdir/mxs791_base.sh - -res=$? - -$srcdir/copy_logs.sh $test_name -exit $res diff --git a/maxscale-system-test/mysqlmon_failover_manual.cpp b/maxscale-system-test/mysqlmon_failover_manual.cpp index 6f9f5675b..1aa562e94 100644 --- a/maxscale-system-test/mysqlmon_failover_manual.cpp +++ b/maxscale-system-test/mysqlmon_failover_manual.cpp @@ -32,7 +32,7 @@ int main(int argc, char** argv) // Part 1 node0_id = prepare_test_1(test); - test.maxscales->ssh_node_output(0, FAILOVER_CMD , true, &ec); + test.maxscales->ssh_node_output(0, FAILOVER_CMD, true, &ec); test.maxscales->wait_for_monitor(); check_test_1(test, node0_id); diff --git a/maxscale-system-test/mysqlmon_rejoin_bad.cpp b/maxscale-system-test/mysqlmon_rejoin_bad.cpp index c7216d473..0e80a85a7 100644 --- a/maxscale-system-test/mysqlmon_rejoin_bad.cpp +++ b/maxscale-system-test/mysqlmon_rejoin_bad.cpp @@ -131,7 +131,7 @@ int main(int argc, char** argv) { int ec; test.maxscales->ssh_node_output(0, - "maxadmin call command mysqlmon switchover MySQL-Monitor server1 server4" , true, &ec); + "maxadmin call command mysqlmon switchover MySQL-Monitor server1 server4", true, &ec); test.maxscales->wait_for_monitor(); master_id = get_master_server_id(test); test.expect(master_id == 1, "Server 1 should be the cluster master."); diff --git a/maxscale-system-test/mysqlmon_rejoin_good.cpp b/maxscale-system-test/mysqlmon_rejoin_good.cpp index 2ddfade5f..21c796cf2 100644 --- a/maxscale-system-test/mysqlmon_rejoin_good.cpp +++ b/maxscale-system-test/mysqlmon_rejoin_good.cpp @@ -80,7 +80,7 @@ int main(int argc, char** argv) // Switch master back to server1 so last check is faster int ec; test.maxscales->ssh_node_output(0, "maxadmin call command mysqlmon switchover " - "MySQL-Monitor server1 server2" , true, &ec); + "MySQL-Monitor server1 server2", true, &ec); test.maxscales->wait_for_monitor(); // Wait for monitor to update status get_output(test); master_id = get_master_server_id(test); diff --git a/maxscale-system-test/mysqlmon_rejoin_manual.cpp b/maxscale-system-test/mysqlmon_rejoin_manual.cpp index ec07121c3..44bf36b56 100644 --- a/maxscale-system-test/mysqlmon_rejoin_manual.cpp +++ b/maxscale-system-test/mysqlmon_rejoin_manual.cpp @@ -65,7 +65,7 @@ int main(int argc, char** argv) get_output(test); test.tprintf("and manually rejoining it to cluster."); const char REJOIN_CMD[] = "maxadmin call command mariadbmon rejoin MySQL-Monitor server1"; - test.maxscales->ssh_node_output(0, REJOIN_CMD , true, &ec); + test.maxscales->ssh_node_output(0, REJOIN_CMD, true, &ec); test.maxscales->wait_for_monitor(); get_output(test); @@ -86,7 +86,7 @@ int main(int argc, char** argv) // Switch master back to server1 so last check is faster int ec; test.maxscales->ssh_node_output(0, "maxadmin call command mysqlmon switchover " - "MySQL-Monitor server1 server2" , true, &ec); + "MySQL-Monitor server1 server2", true, &ec); test.maxscales->wait_for_monitor(); // Wait for monitor to update status get_output(test); master_id = get_master_server_id(test); diff --git a/maxscale-system-test/mysqlmon_rejoin_manual2.cpp b/maxscale-system-test/mysqlmon_rejoin_manual2.cpp index 9facefe74..a75830db4 100644 --- a/maxscale-system-test/mysqlmon_rejoin_manual2.cpp +++ b/maxscale-system-test/mysqlmon_rejoin_manual2.cpp @@ -92,8 +92,8 @@ int main(int argc, char** argv) int ec; string rejoin_s3 = REJOIN_CMD + " server3"; string rejoin_s4 = REJOIN_CMD + " server4"; - test.maxscales->ssh_node_output(0, rejoin_s3.c_str() , true, &ec); - test.maxscales->ssh_node_output(0, rejoin_s4.c_str() , true, &ec); + test.maxscales->ssh_node_output(0, rejoin_s3.c_str(), true, &ec); + test.maxscales->ssh_node_output(0, rejoin_s4.c_str(), true, &ec); test.maxscales->wait_for_monitor(); get_output(test); @@ -117,8 +117,8 @@ int main(int argc, char** argv) mysql_query(nodes[0], "START SLAVE;"); test.maxscales->wait_for_monitor(); string rejoin_s2 = REJOIN_CMD + " server2"; - test.maxscales->ssh_node_output(0, rejoin_s2.c_str() , true, &ec); - test.maxscales->ssh_node_output(0, rejoin_s3.c_str() , true, &ec); + test.maxscales->ssh_node_output(0, rejoin_s2.c_str(), true, &ec); + test.maxscales->ssh_node_output(0, rejoin_s3.c_str(), true, &ec); test.maxscales->wait_for_monitor(); get_output(test); int master_id = get_master_server_id(test); @@ -131,7 +131,7 @@ int main(int argc, char** argv) { int ec; test.maxscales->ssh_node_output(0, - "maxadmin call command mysqlmon switchover MySQL-Monitor server1 server4" , true, &ec); + "maxadmin call command mysqlmon switchover MySQL-Monitor server1 server4", true, &ec); test.maxscales->wait_for_monitor(); master_id = get_master_server_id(test); test.expect(master_id == 1, "Server 1 should be the cluster master."); diff --git a/maxscale-system-test/mysqltest_driver.sh b/maxscale-system-test/mysqltest_driver.sh index 62fbbd31f..aea4cf0ac 100755 --- a/maxscale-system-test/mysqltest_driver.sh +++ b/maxscale-system-test/mysqltest_driver.sh @@ -12,7 +12,7 @@ then exit 1 fi -if [ "$maxscale_IP" == "" ] +if [ "${maxscale_000_network}" == "" ] then echo "Error: The environment variable maxscale_IP must be set." exit 1 @@ -42,19 +42,17 @@ res=0 [ -d log_$1 ] && rm -r log_$1 mkdir log_$1 -echo - # Run the test -for t in `$2/t/*.test|xargs -L 1 basename` +for t in `ls $2/t/*.test|xargs -L 1 basename` do printf "$t:" test_name=${t%%.test} - mysqltest --host=$maxscale_IP --port=$port \ + mysqltest --host=${maxscale_000_network} --port=$port \ --user=$user --password=$password \ --logdir=log_$1 \ --test-file=$2/t/$test_name.test \ - --result-file=$2/r/$test_name.result \ - --silent + --result-file=$2/r/$test_name.result #\ +# --silent if [ $? -eq 0 ] then @@ -65,9 +63,4 @@ do fi done -echo - -# Copy logs from the VM -$src_dir/copy_logs.sh $1 - exit $res diff --git a/maxscale-system-test/nodes.cpp b/maxscale-system-test/nodes.cpp index 8cfea8bef..e0fbe2df2 100644 --- a/maxscale-system-test/nodes.cpp +++ b/maxscale-system-test/nodes.cpp @@ -3,6 +3,8 @@ #include #include +#include "envv.h" + Nodes::Nodes() { } @@ -50,9 +52,7 @@ void Nodes::generate_ssh_cmd(char *cmd, int node, const char *ssh, bool sudo) } else { - sprintf(cmd, "%s", - ssh); - + sprintf(cmd, "%s", ssh); } } else @@ -105,7 +105,6 @@ char * Nodes::ssh_node_output(int node, const char *ssh, bool sudo, int *exit_co char *cmd = (char*)malloc(strlen(ssh) + 1024); generate_ssh_cmd(cmd, node, ssh, sudo); -//tprintf("############ssh smd %s\n:", cmd); FILE *output = popen(cmd, "r"); if (output == NULL) { @@ -152,6 +151,7 @@ int Nodes::ssh_node(int node, const char *ssh, bool sudo) "ssh -i %s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet %s@%s%s", sshkey[node], access_user[node], IP[node], verbose ? "" : " > /dev/null"); } + int rc = 1; FILE *in = popen(cmd, "w"); @@ -201,8 +201,6 @@ int Nodes::ssh_node_f(int node, bool sudo, const char* format, ...) int result = ssh_node(node, sys, sudo); free(sys); return (result); - - } int Nodes::copy_to_node(int i, const char* src, const char* dest) @@ -272,39 +270,15 @@ int Nodes::copy_from_node_legacy(const char* src, const char* dest, int i) int Nodes::read_basic_env() { - char * env; char env_name[64]; - sprintf(env_name, "%s_N", prefix); - env = getenv(env_name); - if (env != NULL) - { - sscanf(env, "%d", &N); - } - else - { - N = 1; - } sprintf(env_name, "%s_user", prefix); - env = getenv(env_name); - if (env != NULL) - { - sscanf(env, "%s", user_name); - } - else - { - sprintf(user_name, "skysql"); - } + user_name = readenv(env_name, "skysql"); + sprintf(env_name, "%s_password", prefix); - env = getenv(env_name); - if (env != NULL) - { - sscanf(env, "%s", password); - } - else - { - sprintf(password, "skysql"); - } + password = readenv(env_name, "skysql"); + + N = get_N(); if ((N > 0) && (N < 255)) { @@ -312,156 +286,69 @@ int Nodes::read_basic_env() { //reading IPs sprintf(env_name, "%s_%03d_network", prefix, i); - env = getenv(env_name); - if (env == NULL) - { - sprintf(env_name, "%s_network", prefix); - env = getenv(env_name); - - } - if (env != NULL) - { - sprintf(IP[i], "%s", env); - } + IP[i] = get_nc_item((char*) env_name); //reading private IPs sprintf(env_name, "%s_%03d_private_ip", prefix, i); - env = getenv(env_name); - if (env == NULL) + IP_private[i] = get_nc_item((char*) env_name); + if (IP_private[i] == NULL) { - sprintf(env_name, "%s_private_ip", prefix); - env = getenv(env_name); - } - if (env != NULL) - { - sprintf(IP_private[i], "%s", env); - } - else - { - sprintf(IP_private[i], "%s", IP[i]); + IP_private[i] = IP[i]; } + setenv(env_name, IP_private[i], 1); //reading IPv6 sprintf(env_name, "%s_%03d_network6", prefix, i); - env = getenv(env_name); - if (env == NULL) + IP6[i] = get_nc_item((char*) env_name); + if (IP6[i] == NULL) { - sprintf(env_name, "%s_network6", prefix); - env = getenv(env_name); - } - if (env != NULL) - { - sprintf(IP6[i], "%s", env); - } - else - { - sprintf(IP6[i], "%s", IP[i]); + IP6[i] = IP[i]; } + setenv(env_name, IP6[i], 1); + //reading sshkey sprintf(env_name, "%s_%03d_keyfile", prefix, i); - env = getenv(env_name); - if (env == NULL) - { - sprintf(env_name, "%s_keyfile", prefix); - env = getenv(env_name); - } - if (env != NULL) - { - sprintf(sshkey[i], "%s", env); - } + sshkey[i] = get_nc_item((char*) env_name); + sprintf(env_name, "%s_%03d_whoami", prefix, i); - env = getenv(env_name); - if (env == NULL) + access_user[i] = get_nc_item((char*) env_name); + if (access_user[i] == NULL) { - sprintf(env_name, "%s_whoami", prefix); - env = getenv(env_name); - } - - if (env != NULL) - { - sprintf(access_user[i], "%s", env); - } - else - { - sprintf(access_user[i], "vagrant"); + access_user[i] = (char *) "vagrant"; } + setenv(env_name, access_user[i], 1); sprintf(env_name, "%s_%03d_access_sudo", prefix, i); - env = getenv(env_name); - if (env == NULL) - { - sprintf(env_name, "%s_access_sudo", prefix); - env = getenv(env_name); - } - if (env != NULL) - { - sprintf(access_sudo[i], "%s", env); - } - else - { - sprintf(access_sudo[i], " "); - } + access_sudo[i] = readenv(env_name, " sudo "); if (strcmp(access_user[i], "root") == 0) { - sprintf(access_homedir[i], "/%s/", access_user[i]); + access_homedir[i] = (char *) "/root/"; } else { + access_homedir[i] = (char *) malloc(strlen(access_user[i] + 9)); sprintf(access_homedir[i], "/home/%s/", access_user[i]); } sprintf(env_name, "%s_%03d_hostname", prefix, i); - env = getenv(env_name); - if (env == NULL) + hostname[i] = get_nc_item((char*) env_name); + if (hostname[i] == NULL) { - sprintf(env_name, "%s_hostname", prefix); - env = getenv(env_name); - } - - if (env != NULL) - { - sprintf(hostname[i], "%s", env); - } - else - { - sprintf(hostname[i], "%s", IP[i]); + hostname[i] = IP[i]; } + setenv(env_name, hostname[i], 1); sprintf(env_name, "%s_%03d_start_vm_command", prefix, i); - env = getenv(env_name); - if (env == NULL) - { - sprintf(env_name, "%s_start_vm_command", prefix); - env = getenv(env_name); - } - - if (env != NULL) - { - sprintf(start_vm_command[i], "%s", env); - } - else - { - sprintf(start_vm_command[i], "exit 0"); - } + start_vm_command[i] = readenv(env_name, "curr_dir=`pwd`; cd %s/%s;vagrant resume %s_%03d ; cd $curr_dir", + getenv("MDBCI_VM_PATH"), getenv("name"), prefix, i); + setenv(env_name, start_vm_command[i], 1); sprintf(env_name, "%s_%03d_stop_vm_command", prefix, i); - env = getenv(env_name); - if (env == NULL) - { - sprintf(env_name, "%s_stop_vm_command", prefix); - env = getenv(env_name); - } - - if (env != NULL) - { - sprintf(stop_vm_command[i], "%s", env); - } - else - { - sprintf(stop_vm_command[i], "exit 0"); - } + stop_vm_command[i] = readenv(env_name, "curr_dir=`pwd`; cd %s/%s;vagrant suspend %s_%03d ; cd $curr_dir", + getenv("MDBCI_VM_PATH"), getenv("name"), prefix, i); + setenv(env_name, stop_vm_command[i], 1); } } @@ -473,12 +360,52 @@ const char* Nodes::ip(int i) const return use_ipv6 ? IP6[i] : IP[i]; } +char * Nodes::get_nc_item(char * item_name) +{ + size_t start = network_config.find(item_name); + if (start == std::string::npos) + { + return NULL; + } + size_t end = network_config.find("\n", start); + size_t equal = network_config.find("=", start); + if (end == std::string::npos) + { + end = network_config.length(); + } + if (equal == std::string::npos) + { + return NULL; + } + + char * cstr = new char [end - equal + 1]; + strcpy(cstr, network_config.substr(equal + 1, end - equal - 1).c_str()); + setenv(item_name, cstr, 1); + + return (cstr); +} + +int Nodes::get_N() +{ + int N = 0; + char item[strlen(prefix) + 13]; + do + { + sprintf(item, "%s_%03d_network", prefix, N); + N++; + } + while (network_config.find(item) != std::string::npos); + sprintf(item, "%s_N", prefix); + setenv(item, std::to_string(N).c_str(), 1); + return N - 1 ; +} + int Nodes::start_vm(int node) { - return(system(start_vm_command[node])); + return (system(start_vm_command[node])); } int Nodes::stop_vm(int node) { - return(system(stop_vm_command[node])); + return (system(stop_vm_command[node])); } diff --git a/maxscale-system-test/nodes.h b/maxscale-system-test/nodes.h index 4ab25e223..ed6a873e4 100644 --- a/maxscale-system-test/nodes.h +++ b/maxscale-system-test/nodes.h @@ -1,5 +1,4 @@ -#ifndef NODES_H -#define NODES_H +#pragma once #include #include @@ -15,16 +14,16 @@ class Nodes public: Nodes(); - char IP[256][1024]; + char * IP[256]; /** * @brief private IP address strings for every backend node (for AWS) */ - char IP_private[256][1024]; + char * IP_private[256]; /** * @brief IP address strings for every backend node (IPv6) */ - char IP6[256][1024]; + char * IP6[256]; /** * @brief use_ipv6 If true IPv6 addresses will be used to connect Maxscale and backed @@ -35,7 +34,7 @@ public: /** * @brief Path to ssh key for every backend node */ - char sshkey[256][4096]; + char * sshkey[256]; /** * @brief Number of backend nodes @@ -50,38 +49,43 @@ public: /** * @brief access_user Unix users name to access nodes via ssh */ - char access_user[256][256]; + char * access_user[256]; /** * @brief access_sudo empty if sudo is not needed or "sudo " if sudo is needed. */ - char access_sudo[256][64]; + char * access_sudo[256]; /** * @brief access_homedir home directory of access_user */ - char access_homedir[256][256]; + char * access_homedir[256]; - char hostname[256][1024]; + char * hostname[256]; /** * @brief stop_vm_command Command to suspend VM */ - char stop_vm_command[256][1024]; + char * stop_vm_command[256]; /** * @brief start_vm_command Command to resume VM */ - char start_vm_command[256][1024]; + char * start_vm_command[256]; /** * @brief User name to access backend nodes */ - char user_name[256]; + char * user_name; /** * @brief Password to access backend nodes */ - char password[256]; + char * password; + + /** + * @brief network_config Content of MDBCI network_config file + */ + std::string network_config; /** * @brief Verbose command output @@ -158,6 +162,19 @@ public: */ int read_basic_env(); + /** + * @brief get_nc_item Find variable in the MDBCI network_config file + * @param item_name Name of the variable + * @return value of variable + */ + char *get_nc_item(char * item_name); + + /** + * @brief get_N Calculate the number of nodes discribed in the _netoek_config file + * @return Number of nodes + */ + int get_N(); + /** * @brief start_vm Start virtual machine * @param node Node number @@ -176,5 +193,3 @@ private: int check_node_ssh(int node); }; - -#endif // NODES_H diff --git a/maxscale-system-test/non_native_setup.cpp b/maxscale-system-test/non_native_setup.cpp index 4855a759f..3b90dc2d7 100644 --- a/maxscale-system-test/non_native_setup.cpp +++ b/maxscale-system-test/non_native_setup.cpp @@ -14,17 +14,26 @@ using namespace std; int main(int argc, char *argv[]) { - if (argc < 2) + if (argc < 3) { return 1; } + std::string sys = + std::string(test_dir) + + std::string("/") + + std::string(argv[2]) + + std::string(" ") + + std::string(argv[1]); + int local_argc = argc - 1; char** local_argv = &argv[1]; - TestConnections * Test = new TestConnections(local_argc, local_argv); - (void)Test; + TestConnections test(local_argc, local_argv); sleep(3); + setenv("src_dir", test_dir, 1); - return 0; + test.add_result(system(sys.c_str()), "Test %s FAILED!", argv[1]); + + return test.global_result; } diff --git a/maxscale-system-test/pers_02.cpp b/maxscale-system-test/pers_02.cpp index 5d6eef6c8..27b7e4f02 100644 --- a/maxscale-system-test/pers_02.cpp +++ b/maxscale-system-test/pers_02.cpp @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) sleep(10); Test->set_timeout(60); - Test->add_result(Test->create_connections(0, 70 , true, true, true, true), + Test->add_result(Test->create_connections(0, 70, true, true, true, true), "Connections creation error \n"); Test->check_log_err(0, (char *) "fatal signal 11", false); diff --git a/maxscale-system-test/proxy_protocol.cpp b/maxscale-system-test/proxy_protocol.cpp index 9b991e007..47adbcf57 100644 --- a/maxscale-system-test/proxy_protocol.cpp +++ b/maxscale-system-test/proxy_protocol.cpp @@ -94,9 +94,9 @@ int main(int argc, char *argv[]) auto testconn = open_conn(maxscale_port, maxscale_ip, username, userpass); if (testconn) { - test.expect(execute_query(testconn, "SELECT 1") != 0, - "Query with user %s succeeded when failure was expected.", username.c_str()); - mysql_close(testconn); + test.expect(execute_query(testconn, "SELECT 1") != 0, + "Query with user %s succeeded when failure was expected.", username.c_str()); + mysql_close(testconn); } } } diff --git a/maxscale-system-test/rds_vpc.cpp b/maxscale-system-test/rds_vpc.cpp index 9a06bbb71..6c1125f53 100644 --- a/maxscale-system-test/rds_vpc.cpp +++ b/maxscale-system-test/rds_vpc.cpp @@ -113,7 +113,7 @@ json_t * RDS::get_cluster() char cmd[1024]; char *result; sprintf(cmd, "aws rds describe-db-clusters --db-cluster-identifier=%s", cluster_name_intern); - execute_cmd(cmd , &result); + execute_cmd(cmd, &result); return get_cluster_descr(result); } @@ -469,7 +469,7 @@ int RDS::create_cluster() "aws rds create-db-cluster --database-name=test --engine=aurora --master-username=skysql --master-user-password=skysqlrds --db-cluster-identifier=%s --db-subnet-group-name=%s", cluster_name_intern, cluster_name_intern); - execute_cmd(cmd , &result); + execute_cmd(cmd, &result); json_t * root = json_loads( result, 0, &error ); if ( !root ) { @@ -508,7 +508,7 @@ int RDS::get_writer(const char ** writer_name) char * json; char cmd[1024]; sprintf(cmd, "aws rds describe-db-clusters --db-cluster-identifier=%s", cluster_name_intern); - execute_cmd(cmd , &json); + execute_cmd(cmd, &json); json_t * cluster = get_cluster_descr(json); json_t * nodes = json_object_get(cluster, "DBClusterMembers"); diff --git a/maxscale-system-test/rds_vpc.h b/maxscale-system-test/rds_vpc.h index 7275798f3..fa3669271 100644 --- a/maxscale-system-test/rds_vpc.h +++ b/maxscale-system-test/rds_vpc.h @@ -1,5 +1,4 @@ -#ifndef RDS_VPC_H -#define RDS_VPC_H +#pragma once #include #include @@ -259,5 +258,3 @@ public: const char * sg_intern; }; - -#endif // RDS_VPC_H diff --git a/maxscale-system-test/run_ctrl_c.sh b/maxscale-system-test/run_ctrl_c.sh index 47377069f..c052533b7 100755 --- a/maxscale-system-test/run_ctrl_c.sh +++ b/maxscale-system-test/run_ctrl_c.sh @@ -3,30 +3,11 @@ ### ## @file run_ctrl_c.sh ## check that Maxscale is reacting correctly on ctrc+c signal and termination does not take ages - -rp=`realpath $0` -export src_dir=`dirname $rp` -export test_dir=`pwd` -export test_name=`basename $rp` - -if [ $maxscale_IP == "127.0.0.1" ] ; then - echo local test is not supporte - exit 0 -fi - -$test_dir/non_native_setup $test_name - -if [ $? -ne 0 ] ; then - echo "configuring maxscale failed" - exit 1 -fi - -scp -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r $src_dir/test_ctrl_c/* $maxscale_access_user@$maxscale_IP:./ -ssh -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $maxscale_access_user@$maxscale_IP "export maxscale_access_sudo=$maxscale_access_sudo; ./test_ctrl_c.sh" - +set -x +scp -i ${maxscale_000_keyfile} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r $src_dir/test_ctrl_c/* ${maxscale_000_whoami}@${maxscale_000_network}:./ +ssh -i ${maxscale_000_keyfile} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${maxscale_000_whoami}@${maxscale_000_network} "export maxscale_000_access_sudo=${maxscale_000_access_sudo}; ./test_ctrl_c.sh" res=$? -ssh -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $maxscale_access_user@$maxscale_IP "sudo rm -f /tmp/maxadmin.sock" +ssh -i ${maxscale_000_keyfile} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${maxscale_000_whoami}@${maxscale_000_network} "sudo rm -f /tmp/maxadmin.sock" -$src_dir/copy_logs.sh run_ctrl_c exit $res diff --git a/maxscale-system-test/run_session_hang.sh b/maxscale-system-test/run_session_hang.sh index e5e848b5d..ed6dd4305 100755 --- a/maxscale-system-test/run_session_hang.sh +++ b/maxscale-system-test/run_session_hang.sh @@ -4,21 +4,10 @@ ## @file run_session_hang.sh ## run a set of queries in the loop (see setmix.sql) using Perl client -rp=`realpath $0` -export src_dir=`dirname $rp` -export test_dir=`pwd` -export test_name=`basename $rp` -$test_dir/non_native_setup $test_name - -if [ $? -ne 0 ] -then - echo "configuring maxscale failed" - exit 1 -fi export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem" -echo "drop table if exists t1; create table t1(id integer primary key); " | mysql -u$node_user -p$node_password -h$maxscale_IP -P 4006 $ssl_options test +echo "drop table if exists t1; create table t1(id integer primary key); " | mysql -u$node_user -p$node_password -h${maxscale_000_network} -P 4006 $ssl_options test if [ $? -ne 0 ] then @@ -37,7 +26,7 @@ fi sleep 15 -echo "show databases;" | mysql -u$node_user -p$node_password -h$maxscale_IP -P 4006 $ssl_options +echo "show databases;" | mysql -u$node_user -p$node_password -h${maxscale_000_network} -P 4006 $ssl_options if [ $? -ne 0 ] then res=1 @@ -46,13 +35,4 @@ fi echo "Waiting for jobs" wait -if [ $res -eq 1 ] -then - echo "Test FAILED" -else - echo "Test PASSED" -fi - -$src_dir/copy_logs.sh run_session_hang - exit $res diff --git a/maxscale-system-test/script.cpp b/maxscale-system-test/script.cpp index 2d1a1e7d5..9a639ca6d 100644 --- a/maxscale-system-test/script.cpp +++ b/maxscale-system-test/script.cpp @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) sleep(15); Test->tprintf("Cheching Maxscale logs"); - Test->check_log_err(0, (char *) "Cannot execute file" , true); + Test->check_log_err(0, (char *) "Cannot execute file", true); Test->tprintf("checking if Maxscale is alive"); Test->check_maxscale_alive(0); diff --git a/maxscale-system-test/session_hang/run_setmix.sh b/maxscale-system-test/session_hang/run_setmix.sh index 2510d2637..763a3a390 100755 --- a/maxscale-system-test/session_hang/run_setmix.sh +++ b/maxscale-system-test/session_hang/run_setmix.sh @@ -1,6 +1,7 @@ #!/bin/bash for ((i=0 ; i<100 ; i++)) ; do - mysql --host=$maxscale_IP -P 4006 -u $node_user -p$node_password --verbose --force --unbuffered=true --disable-reconnect $ssl_options > /dev/null < $test_dir/session_hang/setmix.sql >& /dev/null + echo "Iteration $i" + mysql --host=${maxscale_000_network} -P 4006 -u $node_user -p$node_password --verbose --force --unbuffered=true --disable-reconnect $ssl_options > /dev/null < $src_dir/session_hang/setmix.sql >& /dev/null done diff --git a/maxscale-system-test/sql_t1.h b/maxscale-system-test/sql_t1.h index ba2d3bea9..e4e3214fe 100644 --- a/maxscale-system-test/sql_t1.h +++ b/maxscale-system-test/sql_t1.h @@ -1,5 +1,4 @@ -#ifndef SQL_T1_H -#define SQL_T1_H +#pragma once #include "mariadb_func.h" #include "testconnections.h" @@ -73,5 +72,3 @@ int select_from_t1(MYSQL *conn, int N); * @return 0 if content of t1 is ok */ int check_if_t1_exists(MYSQL *conn); - -#endif // SQL_T1_H diff --git a/maxscale-system-test/sysbench_commands.h b/maxscale-system-test/sysbench_commands.h index fb02e310a..33ed1394f 100644 --- a/maxscale-system-test/sysbench_commands.h +++ b/maxscale-system-test/sysbench_commands.h @@ -17,24 +17,24 @@ const char * SYSBENCH_COMMAND = --max-requests=0 --time=600 run";*/ const char * SYSBENCH_PREPARE = - "sysbench oltp_read_write \ + "sysbench oltp_read_write \ --mysql-db=test --mysql-user=skysql --mysql-password=skysql \ --mysql-port=4006 --mysql-host=%s prepare"; const char * SYSBENCH_COMMAND = - "sysbench oltp_read_write \ + "sysbench oltp_read_write \ --mysql-host=%s --mysql-port=%d --mysql-user=skysql --mysql-password=skysql \ --mysql-db=test \ --threads=32 \ --max-requests=0 --report-interval=5 --time=100 run"; const char * SYSBENCH_PREPARE_RO = - "sysbench oltp_read_only \ + "sysbench oltp_read_only \ --mysql-db=test --mysql-user=skysql --mysql-password=skysql \ --mysql-port=4006 --mysql-host=%s prepare"; const char * SYSBENCH_COMMAND_RO = - "sysbench oltp_read_only \ + "sysbench oltp_read_only \ --mysql-host=%s --mysql-port=%d --mysql-user=skysql --mysql-password=skysql \ --mysql-db=test \ --threads=32 \ @@ -42,12 +42,12 @@ const char * SYSBENCH_COMMAND_RO = const char * SYSBENCH_PREPARE1 = - "sysbench oltp_read_write \ + "sysbench oltp_read_write \ --mysql-db=test --mysql-user=skysql --mysql-password=skysql \ --mysql-port=4006 --mysql-host=%s prepare"; const char * SYSBENCH_COMMAND1 = - "sysbench oltp_read_write \ + "sysbench oltp_read_write \ --mysql-host=%s --mysql-port=%d --mysql-user=skysql --mysql-password=skysql \ --mysql-db=test \ --threads=32 \ @@ -55,7 +55,7 @@ const char * SYSBENCH_COMMAND1 = const char * SYSBENCH_COMMAND_LONG = - "sysbench oltp_read_write \ + "sysbench oltp_read_write \ --mysql-host=%s --mysql-port=%d --mysql-user=skysql --mysql-password=skysql \ --mysql-db=test \ --threads=32 \ @@ -63,12 +63,12 @@ const char * SYSBENCH_COMMAND_LONG = const char * SYSBENCH_PREPARE_SHORT = - "sysbench oltp_read_write \ + "sysbench oltp_read_write \ --mysql-db=test --mysql-user=skysql --mysql-password=skysql \ --mysql-port=4006 --mysql-host=%s prepare"; const char * SYSBENCH_COMMAND_SHORT = - "sysbench oltp_read_write \ + "sysbench oltp_read_write \ --mysql-host=%s --mysql-port=%d --mysql-user=skysql --mysql-password=skysql \ --mysql-db=test \ --threads=32 \ diff --git a/maxscale-system-test/templates.h.in b/maxscale-system-test/templates.h.in index aa64d2036..4c540af8a 100644 --- a/maxscale-system-test/templates.h.in +++ b/maxscale-system-test/templates.h.in @@ -5,8 +5,9 @@ static struct { const char* test_name; const char* test_template; + const char* test_labels; } cnf_templates[] __attribute__((unused)) = { -@CNF_TEMPLATES@ {NULL, NULL}}; +@CNF_TEMPLATES@ {NULL, NULL, NULL}}; /** The default template to use */ static const char * default_template __attribute__((unused)) = "replication"; diff --git a/maxscale-system-test/test_binlog_fnc.cpp b/maxscale-system-test/test_binlog_fnc.cpp index 6df791292..0aab957bb 100644 --- a/maxscale-system-test/test_binlog_fnc.cpp +++ b/maxscale-system-test/test_binlog_fnc.cpp @@ -26,7 +26,7 @@ int check_sha1(TestConnections* Test) Test->set_timeout(50); Test->tprintf("ls before FLUSH LOGS"); Test->tprintf("Maxscale"); - Test->maxscales->ssh_node_f(0, true, "ls -la %s/mar-bin.0000*", Test->maxscales->maxscale_binlog_dir); + Test->maxscales->ssh_node_f(0, true, "ls -la %s/mar-bin.0000*", Test->maxscales->maxscale_binlog_dir[0]); Test->tprintf("Master"); Test->set_timeout(50); Test->maxscales->ssh_node(0, "ls -la /var/lib/mysql/mar-bin.0000*", false); @@ -40,7 +40,7 @@ int check_sha1(TestConnections* Test) Test->tprintf("ls after first FLUSH LOGS"); Test->tprintf("Maxscale"); Test->set_timeout(50); - Test->maxscales->ssh_node_f(0, true, "ls -la %s/mar-bin.0000*", Test->maxscales->maxscale_binlog_dir); + Test->maxscales->ssh_node_f(0, true, "ls -la %s/mar-bin.0000*", Test->maxscales->maxscale_binlog_dir[0]); Test->tprintf("Master"); Test->set_timeout(50); @@ -57,7 +57,7 @@ int check_sha1(TestConnections* Test) Test->tprintf("ls before FLUSH LOGS"); Test->tprintf("Maxscale"); - Test->maxscales->ssh_node_f(0, true, "ls -la %s/mar-bin.0000*", Test->maxscales->maxscale_binlog_dir); + Test->maxscales->ssh_node_f(0, true, "ls -la %s/mar-bin.0000*", Test->maxscales->maxscale_binlog_dir[0]); Test->tprintf("Master"); Test->set_timeout(50); @@ -69,7 +69,7 @@ int check_sha1(TestConnections* Test) Test->tprintf("FILE: 000000%d", i); Test->set_timeout(50); s_maxscale = Test->maxscales->ssh_node_output_f(0, true, &exit_code, "sha1sum %s/mar-bin.00000%d", - Test->maxscales->maxscale_binlog_dir, i); + Test->maxscales->maxscale_binlog_dir[0], i); if (s_maxscale != NULL) { x = strchr(s_maxscale, ' '); diff --git a/maxscale-system-test/test_binlog_fnc.h b/maxscale-system-test/test_binlog_fnc.h index 86a2ca411..44fde18f8 100644 --- a/maxscale-system-test/test_binlog_fnc.h +++ b/maxscale-system-test/test_binlog_fnc.h @@ -1,5 +1,4 @@ -#ifndef TEST_BINLOG_FNC_H -#define TEST_BINLOG_FNC_H +#pragma once #include #include "testconnections.h" @@ -26,5 +25,3 @@ int start_transaction(TestConnections* Test); * @param Test TestConnections object */ void test_binlog(TestConnections* Test); - -#endif // TEST_BINLOG_FNC_H diff --git a/maxscale-system-test/test_ctrl_c/start_killer.sh b/maxscale-system-test/test_ctrl_c/start_killer.sh index 76b6fe82f..697db3571 100755 --- a/maxscale-system-test/test_ctrl_c/start_killer.sh +++ b/maxscale-system-test/test_ctrl_c/start_killer.sh @@ -1,3 +1,3 @@ sleep 5 -$maxscale_access_sudo /usr/bin/killall maxscale -s INT +sudo /usr/bin/killall maxscale -s INT diff --git a/maxscale-system-test/test_ctrl_c/test_ctrl_c.sh b/maxscale-system-test/test_ctrl_c/test_ctrl_c.sh index a92f630b1..fafff6de3 100755 --- a/maxscale-system-test/test_ctrl_c/test_ctrl_c.sh +++ b/maxscale-system-test/test_ctrl_c/test_ctrl_c.sh @@ -1,6 +1,6 @@ #!/bin/bash -$maxscale_access_sudo service maxscale stop +sudo service maxscale stop hm=`pwd` $hm/start_killer.sh & @@ -10,7 +10,7 @@ fi T="$(date +%s)" -$maxscale_access_sudo maxscale -d -U root +sudo maxscale -d -U root if [ $? -ne 0 ] ; then exit 1 fi diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 7a6864540..1cd40ae8b 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -8,11 +8,16 @@ #include #include #include +#include +#include +#include #include "mariadb_func.h" #include "maxadmin_operations.h" #include "sql_t1.h" #include "testconnections.h" +#include "labels_table.h" +#include "envv.h" namespace maxscale { @@ -84,10 +89,12 @@ TestConnections::TestConnections(int argc, char *argv[]): backend_ssl(false), binlog_master_gtid(false), binlog_slave_gtid(false), + no_repl(false), no_galera(false), no_vm_revert(true), threads(4), use_ipv6(false), + reinstall_maxscale(false), use_valgrind(false) { signal_set(SIGSEGV, sigfatal_handler); @@ -99,31 +106,29 @@ TestConnections::TestConnections(int argc, char *argv[]): #endif gettimeofday(&start_time, NULL); - read_env(); + repl = NULL; + galera = NULL; + maxscales = NULL; - char * gal_env = getenv("galera_000_network"); - if ((gal_env == NULL) || (strcmp(gal_env, "") == 0 )) - { - no_galera = true; - tprintf("Galera backend variables are not defined, Galera won't be used\n"); - } + read_env(); bool maxscale_init = true; static struct option long_options[] = { - {"help", no_argument, 0, 'h'}, - {"verbose", no_argument, 0, 'v'}, - {"silent", no_argument, 0, 'n'}, - {"quiet", no_argument, 0, 'q'}, - {"no-maxscale-start", no_argument, 0, 's'}, - {"no-maxscale-init", no_argument, 0, 'i'}, - {"no-nodes-check", no_argument, 0, 'r'}, - {"restart-galera", no_argument, 0, 'g'}, - {"no-timeouts", no_argument, 0, 'z'}, - {"no-galera", no_argument, 0, 'y'}, - {"local-maxscale", no_argument, 0, 'l'}, + {"help", no_argument, 0, 'h'}, + {"verbose", no_argument, 0, 'v'}, + {"silent", no_argument, 0, 'n'}, + {"quiet", no_argument, 0, 'q'}, + {"no-maxscale-start", no_argument, 0, 's'}, + {"no-maxscale-init", no_argument, 0, 'i'}, + {"no-nodes-check", no_argument, 0, 'r'}, + {"restart-galera", no_argument, 0, 'g'}, + {"no-timeouts", no_argument, 0, 'z'}, + {"no-galera", no_argument, 0, 'y'}, + {"local-maxscale", no_argument, 0, 'l'}, + {"reinstall-maxscale", no_argument, 0, 'm'}, {0, 0, 0, 0} }; @@ -131,7 +136,7 @@ TestConnections::TestConnections(int argc, char *argv[]): int option_index = 0; bool restart_galera = false; - while ((c = getopt_long(argc, argv, "hvnqsirgzyl", long_options, &option_index)) != -1) + while ((c = getopt_long(argc, argv, "hvnqsirgzylm", long_options, &option_index)) != -1) { switch (c) { @@ -193,7 +198,7 @@ TestConnections::TestConnections(int argc, char *argv[]): break; case 'l': - printf("MaxScale assumed to be running locally; not started and logs not downloaded.\n"); + printf("MaxScale assumed to be running locally; not started and logs are not downloaded.\n"); maxscale_init = false; no_maxscale_log_copy = true; setenv("maxscale_IP", "127.0.0.1", true); @@ -201,46 +206,147 @@ TestConnections::TestConnections(int argc, char *argv[]): setenv("maxscale_private_ip", "127.0.0.1", true); break; + case 'm': + printf("Maxscale will be reinstalled"); + reinstall_maxscale = true; + break; + default: printf("UNKNOWN OPTION: %c\n", c); break; } } - if (optind < argc) + test_name = basename(argv[0]); + if (!strcmp(test_name, "non_native_setup")) { - test_name = argv[optind]; - } - else - { - test_name = basename(argv[0]); + test_name = argv[1]; } + const char * labels_string = NULL; + template_name = get_template_name(test_name, &labels_string); + labels = strstr(labels_string, "LABELS;"); + if (!labels) + { + labels = (char* ) "LABELS;REPL_BACKEND"; + } + + mdbci_labels = get_mdbci_lables(labels); + + std::string delimiter = std::string (","); + size_t pos_start = 0, pos_end, delim_len = delimiter.length(); + std::string label; + std::string mdbci_labels_c = mdbci_labels + delimiter; + + bool mdbci_call_needed = false; + + while ((pos_end = mdbci_labels_c.find (delimiter, pos_start)) != std::string::npos) + { + label = mdbci_labels_c.substr (pos_start, pos_end - pos_start); + pos_start = pos_end + delim_len; + if (configured_labels.find(label, 0) == std::string::npos) + { + mdbci_call_needed = true; + tprintf("Machines with label '%s' are not running, MDBCI UP call is needed", label.c_str()); + } + else + { + tprintf("Machines with label '%s' are running, MDBCI UP call is not needed", label.c_str()); + } + } + + if (mdbci_call_needed) + { + if (call_mdbci("")) + { + exit(MDBCI_FAUILT); + } + + } + + if (mdbci_labels.find(std::string("REPL_BACKEND")) == std::string::npos) + { + no_repl = true; + tprintf("No need to use Master/Slave"); + } + + if (mdbci_labels.find(std::string("GALERA_BACKEND")) == std::string::npos) + { + no_galera = true; + tprintf("No need to use Galera"); + } + + get_logs_command = (char *) malloc(strlen(test_dir) + 14); sprintf(get_logs_command, "%s/get_logs.sh", test_dir); sprintf(ssl_options, "--ssl-cert=%s/ssl-cert/client-cert.pem --ssl-key=%s/ssl-cert/client-key.pem", test_dir, test_dir); setenv("ssl_options", ssl_options, 1); - repl = new Mariadb_nodes("node", test_dir, verbose); + if (!no_repl) + { + repl = new Mariadb_nodes("node", test_dir, verbose, network_config); + repl->use_ipv6 = use_ipv6; + repl->take_snapshot_command = take_snapshot_command; + repl->revert_snapshot_command = revert_snapshot_command; + if (repl->check_nodes()) + { + if (call_mdbci("--recreate")) + { + exit(MDBCI_FAUILT); + } + } + } + else + { + repl = NULL; + } + if (!no_galera) { - galera = new Galera_nodes("galera", test_dir, verbose); + galera = new Galera_nodes("galera", test_dir, verbose, network_config); //galera->use_ipv6 = use_ipv6; galera->use_ipv6 = false; galera->take_snapshot_command = take_snapshot_command; galera->revert_snapshot_command = revert_snapshot_command; + if (galera->check_nodes()) + { + if (call_mdbci("--recreate")) + { + exit(MDBCI_FAUILT); + } + } } else { galera = NULL; } - repl->use_ipv6 = use_ipv6; - repl->take_snapshot_command = take_snapshot_command; - repl->revert_snapshot_command = revert_snapshot_command; + maxscales = new Maxscales("maxscale", test_dir, verbose, use_valgrind, network_config); + if (maxscales->check_nodes() || + ((maxscales->N < 2) && (mdbci_labels.find(std::string("SECOND_MAXSCALE")) != std::string::npos)) + ) + { + if (call_mdbci("--recreate")) + { + exit(MDBCI_FAUILT); + } + } + + if (reinstall_maxscale) + { + if (reinstall_maxscales()) + { + tprintf("Failed to install Maxscale: target is %s", target); + exit(MDBCI_FAUILT); + } + } + + std::string src = std::string(test_dir) + "/mdbci/add_core_cnf.sh"; + maxscales->copy_to_node(0, src.c_str(), maxscales->access_homedir[0]); + maxscales->ssh_node_f(0, true, "%s/add_core_cnf.sh %s", maxscales->access_homedir[0], + verbose ? "verbose" : ""); - maxscales = new Maxscales("maxscale", test_dir, verbose, use_valgrind); maxscales->use_ipv6 = use_ipv6; maxscales->ssl = ssl; @@ -254,60 +360,62 @@ TestConnections::TestConnections(int argc, char *argv[]): } } - if (maxscale::required_repl_version.length()) + if (repl) { - int ver_repl_required = get_int_version(maxscale::required_repl_version); - std::string ver_repl = repl->get_lowest_version(); - int int_ver_repl = get_int_version(ver_repl); - - if (int_ver_repl < ver_repl_required) + if (maxscale::required_repl_version.length()) { - tprintf("Test requires a higher version of backend servers, skipping test."); - tprintf("Required version: %s", maxscale::required_repl_version.c_str()); - tprintf("Master-slave version: %s", ver_repl.c_str()); - exit(0); + int ver_repl_required = get_int_version(maxscale::required_repl_version); + std::string ver_repl = repl->get_lowest_version(); + int int_ver_repl = get_int_version(ver_repl); + + if (int_ver_repl < ver_repl_required) + { + tprintf("Test requires a higher version of backend servers, skipping test."); + tprintf("Required version: %s", maxscale::required_repl_version.c_str()); + tprintf("Master-slave version: %s", ver_repl.c_str()); + exit(0); + } } } - if (maxscale::required_galera_version.length()) + if (galera) { - int ver_galera_required = get_int_version(maxscale::required_galera_version); - std::string ver_galera = galera->get_lowest_version(); - int int_ver_galera = get_int_version(ver_galera); - - if (int_ver_galera < ver_galera_required) + if (maxscale::required_galera_version.length()) { - tprintf("Test requires a higher version of backend servers, skipping test."); - tprintf("Required version: %s", maxscale::required_galera_version.c_str()); - tprintf("Galera version: %s", ver_galera.c_str()); - exit(0); + int ver_galera_required = get_int_version(maxscale::required_galera_version); + std::string ver_galera = galera->get_lowest_version(); + int int_ver_galera = get_int_version(ver_galera); + + if (int_ver_galera < ver_galera_required) + { + tprintf("Test requires a higher version of backend servers, skipping test."); + tprintf("Required version: %s", maxscale::required_galera_version.c_str()); + tprintf("Galera version: %s", ver_galera.c_str()); + exit(0); + } } } - if ((restart_galera) && (!no_galera)) + if ((restart_galera) && (galera)) { galera->stop_nodes(); galera->start_replication(); } - bool snapshot_reverted = false; - - if (use_snapshots) + if (maxscale::check_nodes) { - snapshot_reverted = revert_snapshot((char *) "clean"); - } - - if (!snapshot_reverted && maxscale::check_nodes) - { - if (!repl->fix_replication() ) + if (repl) { - exit(200); + if (!repl->fix_replication() ) + { + exit(BROKEN_VM_FAUILT); + } } - if (!no_galera) + if (galera) { if (!galera->fix_replication()) { - exit(200); + exit(BROKEN_VM_FAUILT); } } } @@ -321,7 +429,7 @@ TestConnections::TestConnections(int argc, char *argv[]): { tprintf("Configuring backends for ssl \n"); repl->configure_ssl(true); - if (!no_galera) + if (galera) { galera->configure_ssl(false); galera->start_replication(); @@ -375,8 +483,11 @@ TestConnections::~TestConnections() } */ - delete repl; - if (!no_galera) + if (repl) + { + delete repl; + } + if (galera) { delete galera; } @@ -429,123 +540,81 @@ void TestConnections::expect(bool result, const char *format, ...) } } +void TestConnections::read_mdbci_info() +{ + mdbci_vm_path = readenv("MDBCI_VM_PATH", "%s/vms/", getenv("HOME")); + + if (system((std::string("mkdir -p ") + + std::string(mdbci_vm_path)).c_str())) + { + tprintf("Unable to create MDBCI VMs direcory '%s', exiting", mdbci_vm_path); + exit(MDBCI_FAUILT); + } + mdbci_template = readenv("template", "default"); + target = readenv("target", "develop"); + + mdbci_config_name = readenv("mdbci_config_name", "local"); + vm_path = std::string(mdbci_vm_path) + std::string(mdbci_config_name); + if (mdbci_config_name != NULL) + { + std::ifstream nc_file; + nc_file.open(vm_path + "_network_config"); + std::stringstream strStream; + strStream << nc_file.rdbuf(); + network_config = strStream.str(); + nc_file.close(); + + nc_file.open(vm_path + "_configured_labels"); + std::stringstream strStream1; + strStream1 << nc_file.rdbuf(); + configured_labels = strStream1.str(); + nc_file.close(); + } + else + { + tprintf("The name of MDBCI configuration is not defined, exiting!"); + exit(1); + } + if (verbose) + { + tprintf(network_config.c_str()); + } +} + void TestConnections::read_env() { - char *env; + read_mdbci_info(); if (verbose) { printf("Reading test setup configuration from environmental variables\n"); } - //env = getenv("get_logs_command"); if (env != NULL) {sprintf(get_logs_command, "%s", env);} + ssl = readenv_bool("ssl", true); - //env = getenv("test_dir"); if (env != NULL) {sprintf(test_dir, "%s", env);} - - ssl = false; - env = getenv("ssl"); - if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) - { - ssl = true; - } - env = getenv("mysql51_only"); - if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) + if (readenv_bool("mysql51_only", false) || readenv_bool("no_nodes_check", false)) { maxscale::check_nodes = false; } - env = getenv("no_nodes_check"); - if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) - { - maxscale::check_nodes = false; - } - env = getenv("no_backend_log_copy"); - if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) - { - no_backend_log_copy = true; - } - env = getenv("no_maxscale_log_copy"); - if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) - { - no_maxscale_log_copy = true; - } - env = getenv("use_ipv6"); - if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) - { - use_ipv6 = true; - } - - env = getenv("backend_ssl"); - if (env != NULL && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) - { - backend_ssl = true; - } - else - { - backend_ssl = false; - } - - env = getenv("smoke"); - if (env) - { - smoke = strcasecmp(env, "yes") == 0 || strcasecmp(env, "true") == 0; - } - - env = getenv("threads"); - if ((env != NULL)) - { - sscanf(env, "%d", &threads); - } - else - { - threads = 4; - } - - env = getenv("use_snapshots"); - if (env != NULL && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) - { - use_snapshots = true; - } - else - { - use_snapshots = false; - } - env = getenv("take_snapshot_command"); - if (env != NULL) - { - sprintf(take_snapshot_command, "%s", env); - } - else - { - sprintf(take_snapshot_command, "exit 1"); - } - env = getenv("revert_snapshot_command"); - if (env != NULL) - { - sprintf(revert_snapshot_command, "%s", env); - } - else - { - sprintf(revert_snapshot_command, "exit 1"); - } - - env = getenv("no_maxscale_start"); - if (env != NULL && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) + if (readenv_bool("no_maxscale_start", false)) { maxscale::start = false; } - env = getenv("no_vm_revert"); - if ((env != NULL) && ((strcasecmp(env, "no") == 0) || (strcasecmp(env, "false") == 0) )) - { - no_vm_revert = false; - } - - env = getenv("use_valgrind"); - if ((env != NULL) && ((strcasecmp(env, "yes") == 0) || (strcasecmp(env, "true") == 0) )) - { - use_valgrind = true; - } + no_backend_log_copy = readenv_bool("no_backend_log_copy", false); + no_maxscale_log_copy = readenv_bool("no_maxscale_log_copy", false); + use_ipv6 = readenv_bool("use_ipv6", false); + backend_ssl = readenv_bool("backend_ssl", false); + smoke = readenv_bool("smoke", false); + threads = readenv_int("threads", 4); + use_snapshots = readenv_bool("use_snapshots", false); + take_snapshot_command = readenv("take_snapshot_command", + "mdbci snapshot take --path-to-nodes %s --snapshot-name ", mdbci_config_name); + revert_snapshot_command = readenv("revert_snapshot_command", + "mdbci snapshot revert --path-to-nodes %s --snapshot-name ", mdbci_config_name); + no_vm_revert = readenv_bool("no_vm_revert", true); + use_valgrind = readenv_bool("use_valgrind", false); } void TestConnections::print_env() @@ -560,9 +629,10 @@ void TestConnections::print_env() galera->print_env(); } -const char * get_template_name(char * test_name) +const char * get_template_name(char * test_name, const char ** labels) { int i = 0; + *labels = NULL; while (cnf_templates[i].test_name && strcmp(cnf_templates[i].test_name, test_name) != 0) { i++; @@ -570,6 +640,7 @@ const char * get_template_name(char * test_name) if (cnf_templates[i].test_name) { + *labels = (char *) cnf_templates[i].test_labels; return cnf_templates[i].test_template; } @@ -624,28 +695,31 @@ void TestConnections::process_template(int m, const char *template_name, const c for (j = 0; j < mdn_n; j++) { - for (i = 0; i < mdn[j]->N; i++) + if (mdn[j]) { - if (mdn[j]->use_ipv6) + for (i = 0; i < mdn[j]->N; i++) { - IPcnf = mdn[j]->IP6[i]; - } - else - { - IPcnf = mdn[j]->IP[i]; - } - sprintf(str, "sed -i \"s/###%s_server_IP_%0d###/%s/\" maxscale.cnf", - mdn[j]->prefix, i + 1, IPcnf); - system(str); + if (mdn[j]->use_ipv6) + { + IPcnf = mdn[j]->IP6[i]; + } + else + { + IPcnf = mdn[j]->IP[i]; + } + sprintf(str, "sed -i \"s/###%s_server_IP_%0d###/%s/\" maxscale.cnf", + mdn[j]->prefix, i + 1, IPcnf); + system(str); - sprintf(str, "sed -i \"s/###%s_server_port_%0d###/%d/\" maxscale.cnf", - mdn[j]->prefix, i + 1, mdn[j]->port[i]); - system(str); + sprintf(str, "sed -i \"s/###%s_server_port_%0d###/%d/\" maxscale.cnf", + mdn[j]->prefix, i + 1, mdn[j]->port[i]); + system(str); + } + + mdn[j]->connect(); + execute_query(mdn[j]->nodes[0], (char *) "CREATE DATABASE IF NOT EXISTS test"); + mdn[j]->close_connections(); } - - mdn[j]->connect(); - execute_query(mdn[j]->nodes[0], (char *) "CREATE DATABASE IF NOT EXISTS test"); - mdn[j]->close_connections(); } sprintf(str, "sed -i \"s/###access_user###/%s/g\" maxscale.cnf", maxscales->access_user[m]); @@ -654,7 +728,7 @@ void TestConnections::process_template(int m, const char *template_name, const c sprintf(str, "sed -i \"s|###access_homedir###|%s|g\" maxscale.cnf", maxscales->access_homedir[m]); system(str); - if (repl->v51) + if (repl && repl->v51) { system("sed -i \"s/###repl51###/mysql51_replication=true/g\" maxscale.cnf"); } @@ -677,8 +751,6 @@ void TestConnections::init_maxscales() void TestConnections::init_maxscale(int m) { - const char * template_name = get_template_name(test_name); - process_template(m, template_name, maxscales->access_homedir[m]); maxscales->ssh_node_f(m, true, "cp maxscale.cnf %s;rm -rf %s/certs;mkdir -m a+wrx %s/certs;", @@ -739,13 +811,17 @@ int TestConnections::copy_mariadb_logs(Mariadb_nodes * repl, char * prefix) char str[4096]; const int log_retrive_command_num = 3; - const char * log_retrive_command[log_retrive_command_num] = { + const char * log_retrive_command[log_retrive_command_num] = + { "cat /var/lib/mysql/*.err", "cat /var/log/syslog | grep mysql", "cat /var/log/messages | grep mysql" }; - if (repl == NULL) return local_result; + if (repl == NULL) + { + return local_result; + } sprintf(str, "mkdir -p LOGS/%s", test_name); system(str); @@ -856,11 +932,9 @@ int TestConnections::copy_all_logs_periodic() int TestConnections::prepare_binlog(int m) { char version_str[1024] = ""; - repl->connect(); find_field(repl->nodes[0], "SELECT @@version", "@@version", version_str); tprintf("Master server version '%s'", version_str); - if (*version_str && strstr(version_str, "10.0") == NULL && strstr(version_str, "10.1") == NULL && @@ -870,11 +944,9 @@ int TestConnections::prepare_binlog(int m) "sed -i \"s/,mariadb10-compatibility=1//\" %s", maxscales->maxscale_cnf[m]), "Error editing maxscale.cnf"); } - tprintf("Removing all binlog data from Maxscale node"); add_result(maxscales->ssh_node_f(m, true, "rm -rf %s", maxscales->maxscale_binlog_dir[m]), "Removing binlog data failed"); - tprintf("Creating binlog dir"); add_result(maxscales->ssh_node_f(m, true, "mkdir -p %s", maxscales->maxscale_binlog_dir[m]), "Creating binlog data dir failed"); @@ -939,9 +1011,7 @@ int TestConnections::start_binlog(int m) execute_query(repl->nodes[i], "reset slave all"); execute_query(repl->nodes[i], "reset master"); } - prepare_binlog(m); - tprintf("Testing binlog when MariaDB is started with '%s' option\n", cmd_opt); tprintf("ls binlog data dir on Maxscale node\n"); @@ -974,7 +1044,6 @@ int TestConnections::start_binlog(int m) tprintf("Configure first backend slave node to be slave of real master\n"); repl->set_slave(repl->nodes[1], repl->IP[0], repl->port[0], log_file, log_pos); } - tprintf("Starting back Maxscale\n"); add_result(maxscales->start_maxscale(m), "Maxscale start failed\n"); @@ -1896,7 +1965,9 @@ StringSet TestConnections::get_server_status(const char* name) char* p = tok; char *end = strchr(tok, '\n'); if (!end) + { end = strchr(tok, '\0'); + } // Trim leading whitespace while (p < end && isspace(*p)) @@ -1986,20 +2057,117 @@ bool TestConnections::test_bad_config(int m, const char *config) return maxscales->ssh_node_f(m, true, "cp maxscale.cnf /etc/maxscale.cnf; service maxscale stop; " "maxscale -U maxscale -lstdout &> /dev/null && sleep 1 && pkill -9 maxscale") == 0; } +int TestConnections::call_mdbci(const char * options) +{ + struct stat buf; + if (stat( + (mdbci_vm_path + std::string("/") + mdbci_config_name).c_str(), + &buf) + ) + { + if (process_mdbci_template()) + { + tprintf("Failed to generate MDBCI virtual machines template"); + return 1; + } + if (system((std::string("mdbci --override --template ") + + vm_path + + std::string(".json generate ") + + std::string(mdbci_config_name)).c_str() )) + { + tprintf("MDBCI failed to generate virtual machines description"); + return 1; + } + if (system((std::string("cp -r ") + + std::string(test_dir) + + std::string("/mdbci/cnf ") + + std::string(vm_path) + + std::string("/")).c_str())) + { + tprintf("Failed to copy my.cnf files"); + return 1; + } + } + + if (system((std::string("mdbci up ") + + std::string(mdbci_config_name) + + std::string(" --labels ") + + mdbci_labels + + std::string(" ") + + std::string(options)).c_str() )) + { + tprintf("MDBCI failed to bring up virtual machines"); + return 1; + } + read_env(); + if (repl) + { + repl->read_basic_env(); + } + if (galera) + { + galera->read_basic_env(); + } + if (maxscales) + { + maxscales->read_basic_env(); + } + return 0; +} + +int TestConnections::process_mdbci_template() +{ + char * product = readenv("product", "mariadb"); + char * box = readenv("box", "centos_7_libvirt"); + char * __attribute__((unused)) backend_box = readenv("backend_box", "%s", box); + char * version = readenv("version", "10.3"); + char * __attribute__((unused)) target = readenv("target", "develop"); + char * __attribute__((unused)) vm_memory = readenv("vm_memory", "2048"); + char * __attribute__((unused)) galera_version = readenv("galera_version", "%s", version); + + if (strcmp(product, "mysql") == 0 ) + { + setenv("cnf_path", + (vm_path + std::string("/cnf/mysql56/")).c_str(), + 1); + } + else + { + setenv("cnf_path", + (vm_path + std::string("/cnf/")).c_str(), + 1); + } + + std::string name = std::string(test_dir) + + std::string("/mdbci/templates/") + + std::string(mdbci_template) + + std::string(".json.template"); + + std::string sys = std::string("envsubst < ") + + name + + std::string(" > ") + + vm_path + + std::string(".json"); + if (verbose) + { + std::cout << sys << std::endl; + } + return system(sys.c_str()); +} std::string dump_status(const StringSet& current, const StringSet& expected) { std::stringstream ss; ss << "Current status: ("; - for (const auto& a: current) + for (const auto& a : current) { ss << a << ","; } ss << ") Expected status: ("; - for (const auto& a: expected) + for (const auto& a : expected) { ss << a << ","; } @@ -2008,3 +2176,31 @@ std::string dump_status(const StringSet& current, const StringSet& expected) return ss.str(); } +int TestConnections::reinstall_maxscales() +{ + char sys[strlen(target) + + strlen(mdbci_config_name) + + strlen(maxscales->prefix) + + 70]; + for (int i = 0; i < maxscales->N; i++) + { + printf("Installing Maxscale on node %d\n", i); + //TODO: make it via MDBCI and compatible with any distro + maxscales->ssh_node(i, "yum remove maxscale -y", true); + maxscales->ssh_node(i, "yum clean all", true); + + sprintf(sys, "mdbci setup_repo --product maxscale_ci --product-version %s %s/%s_%03d", + target, mdbci_config_name, maxscales->prefix, i); + if (system(sys)) + { + return 1; + } + sprintf(sys, "mdbci install_product --product maxscale_ci --product-version %s %s/%s_%03d", + target, mdbci_config_name, maxscales->prefix, i); + if (system(sys)) + { + return 1; + } + } + return 0; +} diff --git a/maxscale-system-test/testconnections.h b/maxscale-system-test/testconnections.h index 46dbc4a65..a6821fe8e 100644 --- a/maxscale-system-test/testconnections.h +++ b/maxscale-system-test/testconnections.h @@ -1,5 +1,4 @@ -#ifndef TESTCONNECTIONS_H -#define TESTCONNECTIONS_H +#pragma once #include "mariadb_nodes.h" #include "maxscales.h" @@ -12,6 +11,9 @@ typedef std::set StringSet; +#define MDBCI_FAUILT 200 // Exit code for the case when failure caused by MDBCI non-zero exit +#define BROKEN_VM_FAUILT 201 // Exit code for the case when failure caused by screwed VMs + /** * @brief Class contains references to Master/Slave and Galera test setups * Test setup should consist of two setups: one Master/Slave and one Galera. @@ -84,7 +86,7 @@ public: /** * @brief galera Mariadb_nodes object containing references to Galera setuo */ - Mariadb_nodes * galera; + Galera_nodes * galera; /** * @brief repl Mariadb_nodes object containing references to Master/Slave setuo @@ -96,20 +98,40 @@ public: */ Maxscales * maxscales; + /** + * @brief mdbci_config_name Name of MDBCI VMs set + */ + char * mdbci_config_name; + + /** + * @brief mdbci_vm_path Path to directory with MDBCI VMs descriptions + */ + char * mdbci_vm_path; + + /** + * @brief mdbci_temlate Name of mdbci VMs tempate file + */ + char * mdbci_template; + + /** + * @brief target Name of Maxscale repository in the CI + */ + char * target; + /** * @brief GetLogsCommand Command to copy log files from node virtual machines (should handle one parameter: IP address of virtual machine to kill) */ - char get_logs_command[4096]; + char * get_logs_command; /** * @brief make_snapshot_command Command line to create a snapshot of all VMs */ - char take_snapshot_command[4096]; + char * take_snapshot_command; /** * @brief revert_snapshot_command Command line to revert a snapshot of all VMs */ - char revert_snapshot_command[4096]; + char * revert_snapshot_command; /** * @brief use_snapshots if TRUE every test is trying to revert snapshot before running the test @@ -124,6 +146,11 @@ public: */ int copy_mariadb_logs(Mariadb_nodes *repl, char * prefix); + /** + * @brief network_config Content of MDBCI network_config file + */ + std::string network_config; + /** * @brief no_backend_log_copy if true logs from backends are not copied * (needed if case of Aurora RDS backend or similar) @@ -171,6 +198,11 @@ public: */ bool binlog_slave_gtid; + /** + * @brief no_repl Do not check, restart and use Maxster/Slave setup; + */ + bool no_repl; + /** * @brief no_galera Do not check, restart and use Galera setup; all Galera tests will fail */ @@ -228,6 +260,39 @@ public: */ bool use_ipv6; + /** + * @brief template_name Name of maxscale.cnf template + */ + const char * template_name; + + /** + * @brief labels 'LABELS' string from CMakeLists.txt + */ + const char * labels; + + /** + * @brief mdbci_labels labels to be passed to MDBCI + */ + std::string mdbci_labels; + + /** + * @brief configured_labels List of lables for which nodes are configured + */ + std::string configured_labels; + + /** + * @brief vm_path Path to the VM Vagrant directory + */ + std::string vm_path; + + /** + * @brief reinstall_maxscale Flag that is set when 'reinstall_maxscale' + * option is provided; + * if true Maxscale will be removed and re-installed on all Maxscale nodes + * Used for 'run_test_snapshot' + */ + bool reinstall_maxscale; + /** Check whether all nodes are in a valid state */ static void check_nodes(bool value); @@ -251,6 +316,11 @@ public: /** Same as add_result() but inverted */ void expect(bool result, const char *format, ...) __attribute__((format(printf, 3, 4))); + /** + * @brief read_mdbci_info Reads name of MDBCI config and tryes to load all network info + */ + void read_mdbci_info(); + /** * @brief ReadEnv Reads all Maxscale and Master/Slave and Galera setups info from environmental variables */ @@ -512,11 +582,31 @@ public: int start_maxscale(int m = 0); void process_template(const char *src, const char *dest = "/etc/maxscale.cnf"); + /** + * @brief process_mdbci_template Read template file from maxscale-system-test/mdbci/templates + * and replace all placeholders with acutal values + * @return 0 in case of success + */ + int process_mdbci_template(); + + /** + * @brief call_mdbci Execute MDBCI to bring up nodes + * @return 0 if success + */ + int call_mdbci(const char *options); + /** * @brief use_valrind if true Maxscale will be executed under Valgrind */ bool use_valgrind; + /** + * @brief resinstall_maxscales Remove Maxscale form all nodes and installs new ones + * (to be used for run_test_snapshot) + * @return 0 in case of success + */ + int reinstall_maxscales(); + private: void report_result(const char *format, va_list argp); }; @@ -545,4 +635,18 @@ void * log_copy_thread(void *ptr ); */ std::string dump_status(const StringSet& current, const StringSet& expected); -#endif // TESTCONNECTIONS_H +/** + * @brief get_template_name Returns the name of maxscale.cnf template to use for given test + * @param test_name Name of the test + * @param labels pointer to string for storing all test labels + * @return Name of maxscale.cnf file template + */ +const char *get_template_name(char * test_name, const char **labels); + +/** + * @brief readenv_and_set_default Read enviromental variable and set default values if + * variable is not defined + * @param name Name of the environmental variable + * @param defaultenv Default values to be set + * @return Envaronmental variable value + */ diff --git a/maxscale-system-test/utilities.cmake b/maxscale-system-test/utilities.cmake index bc885aeea..25e6805c6 100644 --- a/maxscale-system-test/utilities.cmake +++ b/maxscale-system-test/utilities.cmake @@ -1,7 +1,13 @@ # Helper function to add a configuration template -function(add_template name template) - set(CNF_TEMPLATES "${CNF_TEMPLATES}{\"${name}\",\"${template}\"}," CACHE INTERNAL "") +function(add_template name template labels) + set(CNF_TEMPLATES "${CNF_TEMPLATES}{\"${name}\",\"${template}\", \"${labels}\"}," CACHE INTERNAL "") +endfunction() + + +# Helper function to add a configuration template +function(add_template_manual name template) + add_template(${name} ${template} "${name}.cpp;${name};${template};LABELS;CONFIG") endfunction() # Default test timeout @@ -18,7 +24,7 @@ set(TIMEOUT 900) # test set, the function should be called as follows: # add_test_executable(simple_test.cpp simple_test simple_config LABELS some_label) function(add_test_executable source name template) - add_template(${name} ${template}) + add_template(${name} ${template} "${ARGV}") add_executable(${name} ${source}) target_link_libraries(${name} testcore) add_test(NAME ${name} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name} ${name} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) @@ -34,14 +40,14 @@ endfunction() # Same as add_test_executable, but do not add executable into tests list function(add_test_executable_notest source name template) - add_template(${name} ${template}) + add_template(${name} ${template} "${ARGV}") add_executable(${name} ${source}) target_link_libraries(${name} testcore) endfunction() # Add a test which uses another test as the executable function(add_test_derived name executable template) - add_template(${name} ${template}) + add_template(${name} ${template} "${ARGV}") add_test(NAME ${name} COMMAND ${CMAKE_BINARY_DIR}/${executable} ${name} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_property(TEST ${name} PROPERTY TIMEOUT ${TIMEOUT}) @@ -57,8 +63,8 @@ endfunction() # The naming of the templates follow the same principles as add_test_executable. # also suitable for symlinks function(add_test_script name script template labels) - add_template(${name} ${template}) - add_test(NAME ${name} COMMAND ${CMAKE_SOURCE_DIR}/${script} ${name} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + add_template(${name} ${template} "${ARGV}") + add_test(NAME ${name} COMMAND non_native_setup ${name} ${script} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) list(REMOVE_AT ARGV 0 1 2) From ffcdce5f7b4e0d00e49bf88e0e0addf86343b1b8 Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Fri, 29 Mar 2019 18:01:43 +0200 Subject: [PATCH 02/10] fix mdbci_cinfig_name in run_test.sh --- maxscale-system-test/mdbci/run_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maxscale-system-test/mdbci/run_test.sh b/maxscale-system-test/mdbci/run_test.sh index 68e3958d1..5ee29004e 100755 --- a/maxscale-system-test/mdbci/run_test.sh +++ b/maxscale-system-test/mdbci/run_test.sh @@ -63,7 +63,7 @@ mdbci destroy ${mdbci_config_name} ulimit -c unlimited cd ${script_dir}/.. mkdir build && cd build -cmake .. -DBUILDNAME={mdbci_config_name} -DCMAKE_BUILD_TYPE=Debug +cmake .. -DBUILDNAME=${mdbci_config_name} -DCMAKE_BUILD_TYPE=Debug -DBUILD_SYSTEM_TESTS=Y make echo ${test_set} | grep "NAME#" From 5cdea12ea69a753802898d3ac8b906c16af37d28 Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Fri, 5 Apr 2019 10:31:51 +0300 Subject: [PATCH 03/10] restore test_name processing --- maxscale-system-test/testconnections.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 1cd40ae8b..2e82d6b4d 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -217,10 +217,13 @@ TestConnections::TestConnections(int argc, char *argv[]): } } - test_name = basename(argv[0]); - if (!strcmp(test_name, "non_native_setup")) + if (optind < argc) { - test_name = argv[1]; + test_name = argv[optind]; + } + else + { + test_name = basename(argv[0]); } const char * labels_string = NULL; From 0ce5f87a91f478650b63eb1a5b7d19da84f651c1 Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Tue, 9 Apr 2019 13:57:25 +0300 Subject: [PATCH 04/10] Add support for RHEL8 repository creation --- BUILD/mdbci/copy_repos.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD/mdbci/copy_repos.sh b/BUILD/mdbci/copy_repos.sh index 60063fe1c..6175adf3f 100755 --- a/BUILD/mdbci/copy_repos.sh +++ b/BUILD/mdbci/copy_repos.sh @@ -8,7 +8,7 @@ if [ "$box_type" == "RPM" ] ; then # Build can be executed to check if it is possible to build # and to run install and upgrade tests # with thre real RHEL, but we use CentOS packages for production - if [ "$platform" != "rhel" ] ; then + if [[ "$platform" != "rhel" || ( "$platform" == "rhel" && "$platform_version" == "8" ) ]]; then export arch=`ssh $sshopt "arch"` . ${script_dir}/generate_build_info_path.sh From 4128937d3786769bc90f3639f8dabb4a5bee5ffb Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Tue, 9 Apr 2019 15:33:52 +0300 Subject: [PATCH 05/10] fix rhel repo copying --- BUILD/mdbci/copy_repos.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BUILD/mdbci/copy_repos.sh b/BUILD/mdbci/copy_repos.sh index 6175adf3f..71c3483ec 100755 --- a/BUILD/mdbci/copy_repos.sh +++ b/BUILD/mdbci/copy_repos.sh @@ -9,6 +9,9 @@ if [ "$box_type" == "RPM" ] ; then # and to run install and upgrade tests # with thre real RHEL, but we use CentOS packages for production if [[ "$platform" != "rhel" || ( "$platform" == "rhel" && "$platform_version" == "8" ) ]]; then + if [[ "$platform" == "rhel" && "$platform_version" == "8" ]]; then + export platform="centos" + fi export arch=`ssh $sshopt "arch"` . ${script_dir}/generate_build_info_path.sh From 7ecc70fd5d0088342ebf3d91f457ef2055e623d0 Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Mon, 15 Apr 2019 13:01:03 +0300 Subject: [PATCH 06/10] Move versions checks after nodes checks In case when nodes/servers/replication/etc in backend are broken test can not get proper version information and exits without doing anything. To avoid it, test first checks backend, call fix_replication() if needed and only after that tris to check if backend version is ok for this test --- maxscale-system-test/testconnections.cpp | 48 ++++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 2e82d6b4d..45659c4c7 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -363,6 +363,30 @@ TestConnections::TestConnections(int argc, char *argv[]): } } + if ((restart_galera) && (galera)) + { + galera->stop_nodes(); + galera->start_replication(); + } + + if (maxscale::check_nodes) + { + if (repl) + { + if (!repl->fix_replication() ) + { + exit(BROKEN_VM_FAUILT); + } + } + if (galera) + { + if (!galera->fix_replication()) + { + exit(BROKEN_VM_FAUILT); + } + } + } + if (repl) { if (maxscale::required_repl_version.length()) @@ -399,30 +423,6 @@ TestConnections::TestConnections(int argc, char *argv[]): } } - if ((restart_galera) && (galera)) - { - galera->stop_nodes(); - galera->start_replication(); - } - - if (maxscale::check_nodes) - { - if (repl) - { - if (!repl->fix_replication() ) - { - exit(BROKEN_VM_FAUILT); - } - } - if (galera) - { - if (!galera->fix_replication()) - { - exit(BROKEN_VM_FAUILT); - } - } - } - if (maxscale_init) { init_maxscales(); From a920534e9422c9b5def1c7e0e487afba52250edb Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Mon, 15 Apr 2019 13:45:18 +0300 Subject: [PATCH 07/10] add / to MDBCI_VM_PATH If case of MDBCI_VM_PATH variable does not have trailing slash full names of _network_config and _lables files are defined in the wrong way: MDBCI_VM_PATH is interpreted as a part of file name instead of direcoty name --- maxscale-system-test/testconnections.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 45659c4c7..a2847ab4f 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -557,7 +557,7 @@ void TestConnections::read_mdbci_info() target = readenv("target", "develop"); mdbci_config_name = readenv("mdbci_config_name", "local"); - vm_path = std::string(mdbci_vm_path) + std::string(mdbci_config_name); + vm_path = std::string(mdbci_vm_path) + std::string("/") + std::string(mdbci_config_name); if (mdbci_config_name != NULL) { std::ifstream nc_file; From 87741b7190b2b1f3df55c8ef1260da95c4c6d2ca Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Mon, 15 Apr 2019 13:48:19 +0300 Subject: [PATCH 08/10] Add copying of ssh public keys to test VMs mdbci public_keys command copies ssh public keys from given file to all created VMs --- maxscale-system-test/testconnections.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 45659c4c7..0eebbd2c0 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -2102,6 +2102,13 @@ int TestConnections::call_mdbci(const char * options) tprintf("MDBCI failed to bring up virtual machines"); return 1; } + + std::string team_keys = readenv("team_keys", "~/team_keys"); + system((std::string("mdbci public_keys --key ") + + team_keys + + std::string(" ") + + std::string(mdbci_config_name)).c_str() ); + read_env(); if (repl) { From 74ea0a844cf42d7138d5f92fcfdc9e24f362ffb2 Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Mon, 15 Apr 2019 14:56:07 +0300 Subject: [PATCH 09/10] remove whitespace at end of line --- maxscale-system-test/testconnections.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 0eebbd2c0..ec1fd05e4 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -2107,7 +2107,7 @@ int TestConnections::call_mdbci(const char * options) system((std::string("mdbci public_keys --key ") + team_keys + std::string(" ") + - std::string(mdbci_config_name)).c_str() ); + std::string(mdbci_config_name)).c_str()); read_env(); if (repl) From 2e7ef72e3a0a7793eba224f4b5f3f70ed9d73383 Mon Sep 17 00:00:00 2001 From: Timofey Turenko Date: Mon, 15 Apr 2019 14:59:39 +0300 Subject: [PATCH 10/10] make ~/.ssh/id_rsa.pub default key for loading into test VMs --- maxscale-system-test/testconnections.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index ec1fd05e4..41a7a4cc8 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -2103,7 +2103,7 @@ int TestConnections::call_mdbci(const char * options) return 1; } - std::string team_keys = readenv("team_keys", "~/team_keys"); + std::string team_keys = readenv("team_keys", "~/.ssh/id_rsa.pub"); system((std::string("mdbci public_keys --key ") + team_keys + std::string(" ") +