Skip to content

Commit

Permalink
codership/galera#501 Check cluster weight in galera_pc_weight test
Browse files Browse the repository at this point in the history
Check that cluster weight have proper values in galera_pc_weight
test. Removed sleeps from tests and added condition waits for
expected cluster sizes. Replaced galera suspend/resume with
gmcast.isolate in order to avoid breaking client connections
to server which is isolated from the cluster and to avoid
the need to reset wsrep_cluster_address.

Re-recorded galera_defaults.
  • Loading branch information
temeo authored and Jan Lindström committed Aug 3, 2018
1 parent 40f6bcb commit 1d414d9
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 32 deletions.
31 changes: 26 additions & 5 deletions mysql-test/suite/galera_3nodes/r/galera_pc_weight.result
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
VARIABLE_VALUE = 3
SET GLOBAL wsrep_provider_options = 'pc.weight=3';
Suspending node ...
SELECT VARIABLE_VALUE = 5 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
VARIABLE_VALUE = 5
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
SET SESSION wsrep_sync_wait=0;
SET SESSION wsrep_on=OFF;
SET SESSION wsrep_on=ON;
SHOW STATUS LIKE 'wsrep_cluster_size';
Variable_name Value
wsrep_cluster_size 2
SHOW STATUS LIKE 'wsrep_cluster_weight';
Variable_name Value
SHOW STATUS LIKE 'wsrep_cluster_status';
Variable_name Value
wsrep_cluster_status non-Primary
Expand All @@ -22,9 +28,13 @@ SHOW STATUS LIKE 'wsrep_local_state_comment';
Variable_name Value
wsrep_local_state_comment Initialized
SET SESSION wsrep_sync_wait=0;
SET SESSION wsrep_on=OFF;
SET SESSION wsrep_on=ON;
SHOW STATUS LIKE 'wsrep_cluster_size';
Variable_name Value
wsrep_cluster_size 2
SHOW STATUS LIKE 'wsrep_cluster_weight';
Variable_name Value
SHOW STATUS LIKE 'wsrep_cluster_status';
Variable_name Value
wsrep_cluster_status non-Primary
Expand All @@ -40,7 +50,8 @@ wsrep_local_state 0
SHOW STATUS LIKE 'wsrep_local_state_comment';
Variable_name Value
wsrep_local_state_comment Initialized
Resuming node ...
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
VARIABLE_VALUE = 3
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
VARIABLE_VALUE = 'Primary'
1
Expand All @@ -57,11 +68,14 @@ SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VAR
VARIABLE_VALUE = 'Synced'
1
SET GLOBAL wsrep_provider_options = 'pc.weight=1';
SET SESSION wsrep_sync_wait=0;
SET SESSION wsrep_sync_wait=0;
SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
VARIABLE_VALUE = 1
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
VARIABLE_VALUE = 3
1
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
VARIABLE_VALUE = 3
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
VARIABLE_VALUE = 'Primary'
1
Expand All @@ -80,6 +94,8 @@ VARIABLE_VALUE = 'Synced'
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
VARIABLE_VALUE = 3
1
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
VARIABLE_VALUE = 3
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
VARIABLE_VALUE = 'Primary'
1
Expand All @@ -98,6 +114,8 @@ VARIABLE_VALUE = 'Synced'
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
VARIABLE_VALUE = 3
1
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
VARIABLE_VALUE = 3
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
VARIABLE_VALUE = 'Primary'
1
Expand All @@ -116,6 +134,9 @@ VARIABLE_VALUE = 'Synced'
SET GLOBAL wsrep_provider_options = 'pc.weight=1';
CALL mtr.add_suppression('WSREP: gcs_caused\\(\\) returned -1');
CALL mtr.add_suppression('overriding reported weight for');
CALL mtr.add_suppression('SYNC message from member');
CALL mtr.add_suppression('user message in state LEAVING');
CALL mtr.add_suppression('sending install message failed: (Transport endpoint is not connected|Socket is not connected)');
CALL mtr.add_suppression('WSREP: user message in state LEAVING');
CALL mtr.add_suppression('sending install message failed: Transport endpoint is not connected');
CALL mtr.add_suppression('sending install message failed: (Transport endpoint is not connected|Socket is not connected)');
CALL mtr.add_suppression('overriding reported weight for');
58 changes: 31 additions & 27 deletions mysql-test/suite/galera_3nodes/t/galera_pc_weight.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
--source include/have_innodb.inc

--connection node_1
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
SET GLOBAL wsrep_provider_options = 'pc.weight=3';
SELECT VARIABLE_VALUE = 5 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';

--source include/wait_until_connected_again.inc
--source include/galera_suspend.inc
--sleep 10
# Isolate node_1 from the cluster.
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';

--connection node_2
# Do not wait for causality as we are no longer in the primary component
SET SESSION wsrep_sync_wait=0;
--source include/wait_until_connected_again.inc

SET SESSION wsrep_on=OFF;
--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'
--source include/wait_condition.inc
SET SESSION wsrep_on=ON;

# We can not use SELECT queries here, as only SHOW is allowed to run.
# For nodes #2 and #3, we expect a non-primary component of size 2

# and cluster weight 0
SHOW STATUS LIKE 'wsrep_cluster_size';
SHOW STATUS LIKE 'wsrep_cluster_weight';
SHOW STATUS LIKE 'wsrep_cluster_status';
SHOW STATUS LIKE 'wsrep_connected';
SHOW STATUS LIKE 'wsrep_ready';
Expand All @@ -39,56 +39,55 @@ SHOW STATUS LIKE 'wsrep_local_state_comment';
--source include/galera_connect.inc
--connection node_3
SET SESSION wsrep_sync_wait=0;
--source include/wait_until_connected_again.inc
SET SESSION wsrep_on=OFF;
--let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'
--source include/wait_condition.inc
SET SESSION wsrep_on=ON;

SHOW STATUS LIKE 'wsrep_cluster_size';
SHOW STATUS LIKE 'wsrep_cluster_weight';
SHOW STATUS LIKE 'wsrep_cluster_status';
SHOW STATUS LIKE 'wsrep_connected';
SHOW STATUS LIKE 'wsrep_ready';
SHOW STATUS LIKE 'wsrep_local_state';
SHOW STATUS LIKE 'wsrep_local_state_comment';

--connection node_1
--source include/galera_resume.inc
--sleep 10
--source include/wait_until_connected_again.inc

# For Node #1, we expect a primary component of size 1

--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc

SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state';
SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';

SET GLOBAL wsrep_provider_options = 'pc.weight=1';
SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';

# Restore the cluster by resetting wsrep_cluster_address on nodes #1 and #2
# Resume cluster connectivity on node_1
--connection node_1
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';

--connection node_2
--disable_query_log
--eval SET GLOBAL wsrep_cluster_address = @@wsrep_cluster_address;
--enable_query_log
--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc

SET SESSION wsrep_sync_wait=0;
--source include/wait_until_connected_again.inc
--connection node_2
--source include/wait_condition.inc

--connection node_3
--disable_query_log
--eval SET GLOBAL wsrep_cluster_address = @@wsrep_cluster_address;
--enable_query_log

SET SESSION wsrep_sync_wait=0;
--source include/wait_until_connected_again.inc

# On all nodes, we now expect a Primary component of size 3, Synced and ready
--source include/wait_condition.inc

--connection node_1
--source include/wait_until_connected_again.inc
--source include/wait_condition.inc

# On all nodes, we now expect a Primary component of size 3, weight 3, Synced and ready
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
Expand All @@ -97,6 +96,7 @@ SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VAR

--connection node_2
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
Expand All @@ -105,6 +105,7 @@ SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VAR

--connection node_3
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_weight';
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected';
SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
Expand All @@ -121,8 +122,11 @@ CALL mtr.add_suppression('WSREP: gcs_caused\\(\\) returned -1');

--connection node_2
CALL mtr.add_suppression('overriding reported weight for');
CALL mtr.add_suppression('SYNC message from member');
CALL mtr.add_suppression('user message in state LEAVING');
CALL mtr.add_suppression('sending install message failed: (Transport endpoint is not connected|Socket is not connected)');

--connection node_3
CALL mtr.add_suppression('WSREP: user message in state LEAVING');
CALL mtr.add_suppression('sending install message failed: Transport endpoint is not connected');
CALL mtr.add_suppression('sending install message failed: (Transport endpoint is not connected|Socket is not connected)');
CALL mtr.add_suppression('overriding reported weight for');

0 comments on commit 1d414d9

Please sign in to comment.