From 048f46bd4f4b24109dd186f585730f6b14d05187 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Tue, 10 Jul 2018 21:59:30 -0400 Subject: [PATCH] ARTEMIS-1866 Fixing QuorumResultWaitTest --- .../ha/ReplicatedPolicyConfiguration.java | 19 +++++++++++++------ .../failover/QuorumResultWaitTest.java | 19 ++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ha/ReplicatedPolicyConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ha/ReplicatedPolicyConfiguration.java index e27bb4009f..de1de4f17e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ha/ReplicatedPolicyConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ha/ReplicatedPolicyConfiguration.java @@ -79,24 +79,27 @@ public class ReplicatedPolicyConfiguration implements HAPolicyConfiguration { return initialReplicationSyncTimeout; } - public void setInitialReplicationSyncTimeout(long initialReplicationSyncTimeout) { + public ReplicatedPolicyConfiguration setInitialReplicationSyncTimeout(long initialReplicationSyncTimeout) { this.initialReplicationSyncTimeout = initialReplicationSyncTimeout; + return this; } public boolean getVoteOnReplicationFailure() { return voteOnReplicationFailure; } - public void setVoteOnReplicationFailure(boolean voteOnReplicationFailure) { + public ReplicatedPolicyConfiguration setVoteOnReplicationFailure(boolean voteOnReplicationFailure) { this.voteOnReplicationFailure = voteOnReplicationFailure; + return this; } public int getQuorumSize() { return quorumSize; } - public void setQuorumSize(int quorumSize) { + public ReplicatedPolicyConfiguration setQuorumSize(int quorumSize) { this.quorumSize = quorumSize; + return this; } @@ -104,12 +107,14 @@ public class ReplicatedPolicyConfiguration implements HAPolicyConfiguration { return voteRetries; } - public void setVoteRetries(int voteRetries) { + public ReplicatedPolicyConfiguration setVoteRetries(int voteRetries) { this.voteRetries = voteRetries; + return this; } - public void setVoteRetryWait(long voteRetryWait) { + public ReplicatedPolicyConfiguration setVoteRetryWait(long voteRetryWait) { this.voteRetryWait = voteRetryWait; + return this; } public long getVoteRetryWait() { @@ -120,7 +125,9 @@ public class ReplicatedPolicyConfiguration implements HAPolicyConfiguration { return quorumVoteWait; } - public void setQuorumVoteWait(int quorumVoteWait) { + public ReplicatedPolicyConfiguration setQuorumVoteWait(int quorumVoteWait) { + new Exception("here").printStackTrace(); this.quorumVoteWait = quorumVoteWait; + return this; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumResultWaitTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumResultWaitTest.java index f481dbc0dc..db3aed383f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumResultWaitTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/QuorumResultWaitTest.java @@ -21,6 +21,7 @@ import org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration; import org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration; import org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy; import org.junit.Test; + public class QuorumResultWaitTest extends StaticClusterWithBackupFailoverTest { public static final int QUORUM_VOTE_WAIT_CONFIGURED_TIME_SEC = 12; @@ -33,7 +34,7 @@ public class QuorumResultWaitTest extends StaticClusterWithBackupFailoverTest { ((ReplicatedPolicyConfiguration) servers[2].getConfiguration().getHAPolicyConfiguration()).setGroupName("group2"); ((ReplicaPolicyConfiguration) servers[4].getConfiguration().getHAPolicyConfiguration()).setGroupName("group1"); ((ReplicaPolicyConfiguration) servers[5].getConfiguration().getHAPolicyConfiguration()).setGroupName("group2"); - ReplicatedPolicyConfiguration replicatedPolicyConf = new ReplicatedPolicyConfiguration(); + ReplicatedPolicyConfiguration replicatedPolicyConf = new ReplicatedPolicyConfiguration().setQuorumVoteWait(QUORUM_VOTE_WAIT_CONFIGURED_TIME_SEC); replicatedPolicyConf.setGroupName("group0"); replicatedPolicyConf.setVoteRetries(5); replicatedPolicyConf.setVoteRetryWait(100); @@ -43,12 +44,16 @@ public class QuorumResultWaitTest extends StaticClusterWithBackupFailoverTest { @Test public void testQuorumVotingResultWait() throws Exception { setupCluster(); - startServers(0, 1, 2); - startServers(3, 4, 5); - //Assert if the default time 30 sec is used - assertEquals(ActiveMQDefaultConfiguration.getDefaultQuorumVoteWait(), ((ReplicatedPolicy)(servers[0].getHAPolicy())).getQuorumVoteWait()); - //Assert if the configured time is used. - assertEquals(QUORUM_VOTE_WAIT_CONFIGURED_TIME_SEC, ((ReplicatedPolicy)(servers[3].getHAPolicy())).getQuorumVoteWait()); + try { + startServers(0, 1, 2); + startServers(3, 4, 5); + //Assert if the default time 30 sec is used + assertEquals(ActiveMQDefaultConfiguration.getDefaultQuorumVoteWait(), ((ReplicatedPolicy) (servers[0].getHAPolicy())).getQuorumVoteWait()); + //Assert if the configured time is used. + assertEquals(QUORUM_VOTE_WAIT_CONFIGURED_TIME_SEC, ((ReplicatedPolicy) (servers[3].getHAPolicy())).getQuorumVoteWait()); + } finally { + stopServers(0, 1, 2, 3, 4, 5); + } } @Override