############################################################################## # # This test checks the basic functionality of group replication plugin along # with mysqlx plugin (x mode). # # NOTE : All the queries through mysqlx plugin is passed using mysqlxtest. # # Steps involved in this test : # 0. This test requires 3 servers. # 1. Start 3 servers loaded with both mysqlx and group replication plugin. # 2. Start group replication on server1 as bootstrap server through mysqlx. # 3. Start group replication on other two servers as non bootstrap servers through mysqlx. # 4. Wait until all three servers come online. # 5. Perform ddl and dml operations on all the three servers. # a) server1 : Create table T1 and perform ddl on T1 using x protocol. # b) server2 : Create table T2 and perform ddl on T1 & T2 using x protocol. # c) server3 : Create table T3 and perform ddl on T1,T2 & T3 using x protocol. # 6. Assert for values on three tables from different servers. # 7. Stop group replication on all the servers through mysqlx # 8. Uninstall mysqlx on the servers. # 9. Clean-Up ############################################################################## --source include/big_test.inc --source include/have_mysqlx_plugin.inc --source include/have_group_replication_plugin_base.inc --let plugins= GROUP_REPLICATION --source include/check_plugin_dir.inc # This initial setup starts three servers with all the prerequisites required # for GR to start --source include/have_group_replication_plugin.inc --let $rpl_skip_group_replication_start= 1 --let $rpl_server_count= 3 --source include/group_replication.inc # Install Mysqlx plugin on all servers. --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source include/xplugin_wait_for_interfaces.inc --let $rpl_connection_name= server2 --source include/rpl_connection.inc --source include/xplugin_wait_for_interfaces.inc --let $rpl_connection_name= server3 --source include/rpl_connection.inc --source include/xplugin_wait_for_interfaces.inc # File for starting GR through X-protocol # Bootstrap-server --write_file $MYSQL_TMP_DIR/bootstrap_server.tmp -->sql SET GLOBAL GROUP_REPLICATION_GROUP_NAME = 'aaaaaaaa-cccc-aaaa-aaaa-aaaaaaaaaaaa'; SET GLOBAL GROUP_REPLICATION_BOOTSTRAP_GROUP=1; START GROUP_REPLICATION; SET GLOBAL GROUP_REPLICATION_BOOTSTRAP_GROUP=0; -->endsql EOF # Temp file for starting group replication as non bootstrap server. --write_file $MYSQL_TMP_DIR/non_bootstrap_server.tmp -->sql SET GLOBAL GROUP_REPLICATION_GROUP_NAME = 'aaaaaaaa-cccc-aaaa-aaaa-aaaaaaaaaaaa'; CHANGE MASTER TO MASTER_USER='root' FOR CHANNEL 'group_replication_recovery'; START GROUP_REPLICATION; -->endsql EOF # Starting GR on all the servers through mysqlx --echo Starting GR on server 1 --exec $MYSQLXTEST --ssl-cipher='DHE-RSA-AES256-SHA' -u root --port=$MASTER_X_MYPORT_1 --file=$MYSQL_TMP_DIR/bootstrap_server.tmp 2>&1 --echo Starting GR on server 2 --exec $MYSQLXTEST --ssl-cipher='DHE-RSA-AES256-SHA' -u root --port=$MASTER_X_MYPORT_2 --file=$MYSQL_TMP_DIR/non_bootstrap_server.tmp 2>&1 --echo Starting GR on server 3 --exec $MYSQLXTEST --ssl-cipher='DHE-RSA-AES256-SHA' -u root --port=$MASTER_X_MYPORT_3 --file=$MYSQL_TMP_DIR/non_bootstrap_server.tmp 2>&1 --echo Waiting for GR members to come online. --let $wait_condition=SELECT COUNT(*)=3 FROM performance_schema.replication_group_members where MEMBER_STATE="ONLINE" --source include/wait_condition.inc # creating some macros in this file. --write_file $MYSQL_TMP_DIR/macro.tmp # Macro to insert values into Table T1 -->macro insert_t1 %VALUE1% %VALUE2% Mysqlx.Crud.Insert { collection { name: "T1" schema: "test" } data_model: TABLE projection { name: "C1" } projection { name: "C2" } row { field { type: LITERAL literal { type: V_SINT v_signed_int: %VALUE1% } } field { type: LITERAL literal { type: V_SINT v_signed_int: %VALUE2% } } } } -->endmacro # Macro to insert values into Table T2 -->macro insert_t2 %VALUE1% %VALUE2% Mysqlx.Crud.Insert { collection { name: "T2" schema: "test" } data_model: TABLE projection { name: "C1" } projection { name: "C2" } row { field { type: LITERAL literal { type: V_STRING v_string { value: "%VALUE1%" } } } field { type: LITERAL literal { type: V_SINT v_signed_int: %VALUE2% } } } } -->endmacro # Macro to insert values into Table T3 -->macro insert_t3 %VALUE1% %VALUE2% Mysqlx.Crud.Insert { collection { name: "T3" schema: "test" } data_model: TABLE projection { name: "C1" } projection { name: "C2" } row { field { type: LITERAL literal { type: V_SINT v_signed_int: %VALUE1% } } field { type: LITERAL literal { type:V_STRING v_string { value: "%VALUE1%" } } } } } -->endmacro EOF # Temp file for performing ddl and dml on server1. # Copying the contents of the "macro.tmp" so that the macros available can be # reused --copy_file $MYSQL_TMP_DIR/macro.tmp $MYSQL_TMP_DIR/ddl_dml_on_server1.tmp --append_file $MYSQL_TMP_DIR/ddl_dml_on_server1.tmp -->stmtsql USE test -->recvresult -->stmtsql CREATE TABLE T1 (C1 INT PRIMARY KEY, C2 INT ); -->recvresult -->callmacro insert_t1 1 12 -->recvresult -->callmacro insert_t1 2 1234 -->recvresult -->callmacro insert_t1 3 98765 -->recvresult Mysqlx.Crud.Update { collection { name: "T1" schema: "test" } data_model: TABLE operation { source { name: "c1" } operation: SET value { type: OPERATOR operator { name: "+" param { type: IDENT identifier { name: "c1" } } param { type: LITERAL literal { type: V_UINT v_unsigned_int: 10 } } } } } } -->recvresult Mysqlx.Crud.Delete { collection { name: "T1" schema: "test" } data_model: TABLE criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { name: "C2" } } param { type: LITERAL literal { type: V_UINT v_unsigned_int: 0 } } } } } -->recvresult EOF --echo Performing DDL/DML operations on server 1 --exec $MYSQLXTEST --ssl-cipher='DHE-RSA-AES256-SHA' -u root --port=$MASTER_X_MYPORT_1 --file=$MYSQL_TMP_DIR/ddl_dml_on_server1.tmp 2>&1 --source include/rpl_sync.inc # Temp file for performing ddl and dml on server2 # Copying the contents of the "macro.tmp" so that the macros available can be # reused --copy_file $MYSQL_TMP_DIR/macro.tmp $MYSQL_TMP_DIR/ddl_dml_on_server2.tmp --append_file $MYSQL_TMP_DIR/ddl_dml_on_server2.tmp -->stmtsql USE test -->recvresult -->stmtsql CREATE TABLE T2 (C1 CHAR(20) PRIMARY KEY, C2 INT ); -->recvresult -->callmacro insert_t2 ABC 23 -->recvresult Mysqlx.Crud.Update { collection { name: "T2" schema: "test" } data_model: TABLE operation { source { name: "C2" } operation: SET value { type: OPERATOR operator { name: "+" param { type: IDENT identifier { name: "C2" } } param { type: LITERAL literal { type: V_UINT v_unsigned_int: 27 } } } } } } -->recvresult -->callmacro insert_t1 4 34 -->recvresult -->callmacro insert_t2 ABCDEF 23 -->recvresult -->callmacro insert_t1 5 1234 -->recvresult -->callmacro insert_t2 ABCDEFGHIJ 23 -->recvresult Mysqlx.Crud.Delete { collection { name: "T2" schema: "test" } data_model: TABLE criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { name: "C1" } } param { type: LITERAL literal { type: V_OCTETS v_octets { value: "ABC" } } } } } } -->recvresult EOF --echo Performing DDL/DML operations on server 2 --exec $MYSQLXTEST --ssl-cipher='DHE-RSA-AES256-SHA' -u root --port=$MASTER_X_MYPORT_2 --file=$MYSQL_TMP_DIR/ddl_dml_on_server2.tmp 2>&1 --source include/rpl_sync.inc # Temp file for performing ddl and dml on server3 # Copying the contents of the "macro.tmp" so that the macros available can be # reused --copy_file $MYSQL_TMP_DIR/macro.tmp $MYSQL_TMP_DIR/ddl_dml_on_server3.tmp --append_file $MYSQL_TMP_DIR/ddl_dml_on_server3.tmp -->stmtsql USE test; -->recvresult -->stmtsql CREATE TABLE T3 (C1 INT PRIMARY KEY, C2 VARCHAR(20) ); -->recvresult Mysqlx.Crud.Delete { collection { name: "T1" schema: "test" } data_model: TABLE } -->recvresult -->callmacro insert_t1 1 12345 -->recvresult -->callmacro insert_t3 1 1234 -->recvresult -->callmacro insert_t2 1234 1234 -->recvresult -->callmacro insert_t1 7 98765 -->recvresult -->callmacro insert_t2 XYZ 23 -->recvresult Mysqlx.Crud.Update { collection { name: "T2" schema: "test" } data_model: TABLE criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { name: "C1" } } param { type: LITERAL literal { type: V_OCTETS v_octets { value: "XYZ" } } } } } operation { source { name: "C1" } operation: SET value { type: LITERAL literal { type: V_STRING v_string { value: "ABC" } } } } } -->recvresult -->callmacro insert_t3 2 23 -->recvresult -->callmacro insert_t3 3 234 -->recvresult Mysqlx.Crud.Delete { collection { name: "T3" schema: "test" } data_model: TABLE criteria { type: OPERATOR operator { name: ">" param { type: IDENT identifier { name: "C1" } } param { type: LITERAL literal { type: V_UINT v_unsigned_int: 0 } } } } } -->recvresult EOF --echo Performing DDL/DML operations on server 3 --exec $MYSQLXTEST --ssl-cipher='DHE-RSA-AES256-SHA' -u root --port=$MASTER_X_MYPORT_3 --file=$MYSQL_TMP_DIR/ddl_dml_on_server3.tmp 2>&1 # Wait for synchronization between the nodes. --source include/rpl_sync.inc # Asserts for values on each table. --let $rpl_connection_name= server2 --source include/rpl_connection.inc --let $assert_text= 'Checking the Value on T1' --let $assert_cond= [SELECT C2 FROM test.T1 WHERE C1=1, C2, 1] = 12345 --source include/assert.inc --let $assert_text= 'Checking the Value on T2' --let $assert_cond= [SELECT C2 FROM test.T2 WHERE C1="ABC", C2, 1] = 23 --source include/assert.inc --let $wait_condition=SELECT COUNT(*)=0 FROM test.T3 --source include/wait_condition.inc # Creating temp file to delete tables --copy_file $MYSQL_TMP_DIR/macro.tmp $MYSQL_TMP_DIR/delete_tables.tmp --append_file $MYSQL_TMP_DIR/delete_tables.tmp -->stmtsql USE test; -->recvresult -->stmtsql DROP TABLE T1; -->recvresult -->stmtsql DROP TABLE T2; -->recvresult -->stmtsql DROP TABLE T3; -->recvresult EOF # Deleting tables --echo Deleting all the tables. --exec $MYSQLXTEST --ssl-cipher='DHE-RSA-AES256-SHA' -u root --port=$MASTER_X_MYPORT_3 --file=$MYSQL_TMP_DIR/delete_tables.tmp 2>&1 --source include/rpl_sync.inc # Creating temp file to stop GR. --write_file $MYSQL_TMP_DIR/stop_group_replication.tmp -->stmtsql STOP GROUP_REPLICATION; -->recvresult EOF # Stopping GR on all the servers --echo Stopping GR on server 1 --exec $MYSQLXTEST --ssl-cipher='DHE-RSA-AES256-SHA' -u root --port=$MASTER_X_MYPORT_1 --file=$MYSQL_TMP_DIR/stop_group_replication.tmp 2>&1 --echo Stopping GR on server 2 --exec $MYSQLXTEST --ssl-cipher='DHE-RSA-AES256-SHA' -u root --port=$MASTER_X_MYPORT_2 --file=$MYSQL_TMP_DIR/stop_group_replication.tmp 2>&1 --echo Stopping GR on server 3 --exec $MYSQLXTEST --ssl-cipher='DHE-RSA-AES256-SHA' -u root --port=$MASTER_X_MYPORT_3 --file=$MYSQL_TMP_DIR/stop_group_replication.tmp 2>&1 # Uninstall mysqlx on all servers --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source include/stop_group_replication.inc --let $rpl_connection_name= server2 --source include/rpl_connection.inc --source include/stop_group_replication.inc --let $rpl_connection_name= server3 --source include/rpl_connection.inc --source include/stop_group_replication.inc # clean-up --remove_file $MYSQL_TMP_DIR/bootstrap_server.tmp --remove_file $MYSQL_TMP_DIR/non_bootstrap_server.tmp --remove_file $MYSQL_TMP_DIR/ddl_dml_on_server1.tmp --remove_file $MYSQL_TMP_DIR/ddl_dml_on_server2.tmp --remove_file $MYSQL_TMP_DIR/ddl_dml_on_server3.tmp --remove_file $MYSQL_TMP_DIR/delete_tables.tmp --remove_file $MYSQL_TMP_DIR/macro.tmp --remove_file $MYSQL_TMP_DIR/stop_group_replication.tmp --source include/group_replication_end.inc