Skip to content

Commit

Permalink
Fixes SplitBrainTest start issues (hazelcast#19191)
Browse files Browse the repository at this point in the history
SplitBrainStatus is set by a single thread at the hazelcast instance
start in an async manner. Therefore, we are not sure that a the
status is set when the test starts.

Adding an eventually check at the start so that we make sure we
have the min-size cluster for all split brain protections before
we actually split the cluster

fixes hazelcast#18950
fixes hazelcast#18777
fixes hazelcast#18766
fixes hazelcast#18765
fixes hazelcast#18764
fixes hazelcast#18930

(cherry picked from commit a33a1a7)
  • Loading branch information
sancar committed Jul 28, 2021
1 parent 544be06 commit bc678a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected static void initCluster(Config config, TestHazelcastInstanceFactory fa
config.addPNCounterConfig(newPNCounterConfig(splitBrainProtectionOn, splitBrainProtectionName));
}

cluster.createFiveMemberCluster(config);
cluster.createFiveMemberCluster(config, splitBrainProtectionNames);
initData(types);
cluster.splitFiveMembersThreeAndTwo(splitBrainProtectionNames);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ public HazelcastInstance getInstance(int index) {
return instance[index];
}

public void createFiveMemberCluster(Config config) {
public void createFiveMemberCluster(Config config, String[] splitBrainProtectionIds) {
createInstances(config);
verifySplitBrainProtectionsPresentEventually(SUCCESSFUL_SPLIT_BRAIN_PROTECTION_TEST_NAME);
for (String splitBrainProtectionId : splitBrainProtectionIds) {
verifySplitBrainProtectionsPresentEventually(splitBrainProtectionId);
}
}

public void splitFiveMembersThreeAndTwo(String... splitBrainProtectionIds) {
Expand Down Expand Up @@ -133,6 +137,14 @@ private void splitCluster() {
closeConnectionBetween(instance[4], instance[0]);
}

private void verifySplitBrainProtectionsPresentEventually(String splitBrainProtectionId) {
assertSplitBrainProtectionIsPresentEventually(instance[0], splitBrainProtectionId);
assertSplitBrainProtectionIsPresentEventually(instance[1], splitBrainProtectionId);
assertSplitBrainProtectionIsPresentEventually(instance[2], splitBrainProtectionId);
assertSplitBrainProtectionIsPresentEventually(instance[3], splitBrainProtectionId);
assertSplitBrainProtectionIsPresentEventually(instance[4], splitBrainProtectionId);
}

private void verifySplitBrainProtections(String splitBrainProtectionId) {
assertSplitBrainProtectionIsPresentEventually(instance[0], splitBrainProtectionId);
assertSplitBrainProtectionIsPresentEventually(instance[1], splitBrainProtectionId);
Expand Down

0 comments on commit bc678a5

Please sign in to comment.