You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ni...@apache.org on 2021/09/06 16:14:42 UTC
[activemq-artemis] 05/08: ARTEMIS-3458 Reduce number of ZK nodes
for fast-tests runs
This is an automated email from the ASF dual-hosted git repository.
nigrofranz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit 082f06a095771b7f53e696258d3b18d669ad2e69
Author: franz1981 <ni...@gmail.com>
AuthorDate: Fri Sep 3 18:47:13 2021 +0200
ARTEMIS-3458 Reduce number of ZK nodes for fast-tests runs
---
artemis-quorum-ri/pom.xml | 9 ++++++
.../zookeeper/CuratorDistributedLockTest.java | 35 +++++++++++++---------
pom.xml | 2 ++
3 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/artemis-quorum-ri/pom.xml b/artemis-quorum-ri/pom.xml
index 0882899..3bc5b41 100644
--- a/artemis-quorum-ri/pom.xml
+++ b/artemis-quorum-ri/pom.xml
@@ -122,6 +122,15 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <fast-tests>${fast-tests}</fast-tests>
+ </systemProperties>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
\ No newline at end of file
diff --git a/artemis-quorum-ri/src/test/java/org/apache/activemq/artemis/quorum/zookeeper/CuratorDistributedLockTest.java b/artemis-quorum-ri/src/test/java/org/apache/activemq/artemis/quorum/zookeeper/CuratorDistributedLockTest.java
index 61502ae..aea635c 100644
--- a/artemis-quorum-ri/src/test/java/org/apache/activemq/artemis/quorum/zookeeper/CuratorDistributedLockTest.java
+++ b/artemis-quorum-ri/src/test/java/org/apache/activemq/artemis/quorum/zookeeper/CuratorDistributedLockTest.java
@@ -61,8 +61,10 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
private static final int RETRIES_MS = 100;
private static final int RETRIES = 1;
+ // fast-tests runs doesn't need to run 3 ZK nodes
+ private static final int ZK_NODES = Boolean.getBoolean("fast-tests") ? 1 : 3;
@Parameterized.Parameter
- public int nodes;
+ public int zkNodes;
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder();
private TestingCluster testingServer;
@@ -71,13 +73,13 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
@Parameterized.Parameters(name = "nodes={0}")
public static Iterable<Object[]> getTestParameters() {
- return Arrays.asList(new Object[][]{{3}, {5}});
+ return Arrays.asList(new Object[][]{{ZK_NODES}});
}
@Override
public void setupEnv() throws Throwable {
- clusterSpecs = new InstanceSpec[nodes];
- for (int i = 0; i < nodes; i++) {
+ clusterSpecs = new InstanceSpec[zkNodes];
+ for (int i = 0; i < zkNodes; i++) {
clusterSpecs[i] = new InstanceSpec(tmpFolder.newFolder(), BASE_SERVER_PORT + i, -1, -1, true, -1, SERVER_TICK_MS, -1);
}
testingServer = new TestingCluster(clusterSpecs);
@@ -181,6 +183,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
@Test
public void canAcquireLockOnMajorityRestart() throws Exception {
+ Assume.assumeThat(zkNodes, greaterThan(1));
final DistributedPrimitiveManager manager = createManagedDistributeManager();
manager.start();
final DistributedLock lock = manager.getDistributedLock("a");
@@ -203,7 +206,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
@Test
public void cannotStartManagerWithoutQuorum() throws Exception {
- Assume.assumeThat(nodes, greaterThan(1));
+ Assume.assumeThat(zkNodes, greaterThan(1));
DistributedPrimitiveManager manager = createManagedDistributeManager();
stopMajorityNotLeaderNodes(true);
Assert.assertFalse(manager.start(2, TimeUnit.SECONDS));
@@ -212,7 +215,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
@Test(expected = UnavailableStateException.class)
public void cannotAcquireLockWithoutQuorum() throws Exception {
- Assume.assumeThat(nodes, greaterThan(1));
+ Assume.assumeThat(zkNodes, greaterThan(1));
DistributedPrimitiveManager manager = createManagedDistributeManager();
manager.start();
stopMajorityNotLeaderNodes(true);
@@ -222,7 +225,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
@Test
public void cannotCheckLockWithoutQuorum() throws Exception {
- Assume.assumeThat(nodes, greaterThan(1));
+ Assume.assumeThat(zkNodes, greaterThan(1));
DistributedPrimitiveManager manager = createManagedDistributeManager();
manager.start();
stopMajorityNotLeaderNodes(true);
@@ -238,7 +241,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
@Test
public void canGetLockWithoutQuorum() throws Exception {
- Assume.assumeThat(nodes, greaterThan(1));
+ Assume.assumeThat(zkNodes, greaterThan(1));
DistributedPrimitiveManager manager = createManagedDistributeManager();
manager.start();
stopMajorityNotLeaderNodes(true);
@@ -248,7 +251,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
@Test
public void notifiedAsUnavailableWhileLoosingQuorum() throws Exception {
- Assume.assumeThat(nodes, greaterThan(1));
+ Assume.assumeThat(zkNodes, greaterThan(1));
DistributedPrimitiveManager manager = createManagedDistributeManager();
manager.start();
DistributedLock lock = manager.getDistributedLock("a");
@@ -260,7 +263,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
@Test
public void beNotifiedOnce() throws Exception {
- Assume.assumeThat(nodes, greaterThan(1));
+ Assume.assumeThat(zkNodes, greaterThan(1));
DistributedPrimitiveManager manager = createManagedDistributeManager();
manager.start();
DistributedLock lock = manager.getDistributedLock("a");
@@ -276,7 +279,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
@Test
public void beNotifiedOfUnavailabilityWhileBlockedOnTimedLock() throws Exception {
- Assume.assumeThat(nodes, greaterThan(1));
+ Assume.assumeThat(zkNodes, greaterThan(1));
DistributedPrimitiveManager manager = createManagedDistributeManager();
manager.start();
DistributedLock lock = manager.getDistributedLock("a");
@@ -312,6 +315,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
@Test
public void beNotifiedOfAlreadyUnavailableManagerAfterAddingListener() throws Exception {
+ Assume.assumeThat(zkNodes, greaterThan(1));
DistributedPrimitiveManager manager = createManagedDistributeManager();
manager.start();
final AtomicBoolean unavailable = new AtomicBoolean(false);
@@ -338,6 +342,9 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
}
private static boolean isLeader(TestingZooKeeperServer server) {
+ if (server.getInstanceSpecs().size() == 1) {
+ return true;
+ }
long leaderId = server.getQuorumPeer().getLeaderId();
long id = server.getQuorumPeer().getId();
return id == leaderId;
@@ -345,7 +352,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
private void stopMajorityNotLeaderNodes(boolean fromLast) throws Exception {
List<TestingZooKeeperServer> followers = testingServer.getServers().stream().filter(Predicates.not(CuratorDistributedLockTest::isLeader)).collect(Collectors.toList());
- final int quorum = (nodes / 2) + 1;
+ final int quorum = (zkNodes / 2) + 1;
for (int i = 0; i < quorum; i++) {
final int nodeIndex = fromLast ? (followers.size() - 1) - i : i;
followers.get(nodeIndex).stop();
@@ -353,9 +360,9 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
}
private void restartMajorityNodes(boolean startFromLast) throws Exception {
- final int quorum = (nodes / 2) + 1;
+ final int quorum = (zkNodes / 2) + 1;
for (int i = 0; i < quorum; i++) {
- final int nodeIndex = startFromLast ? (nodes - 1) - i : i;
+ final int nodeIndex = startFromLast ? (zkNodes - 1) - i : i;
if (!testingServer.restartServer(clusterSpecs[nodeIndex])) {
throw new IllegalStateException("errored while restarting " + clusterSpecs[nodeIndex]);
}
diff --git a/pom.xml b/pom.xml
index 361c0c3..ffecb33 100644
--- a/pom.xml
+++ b/pom.xml
@@ -219,6 +219,7 @@
<!-- Ignore failed tests by default because there are "known" failures in the full test-suite.
This will be set to false for the "fast-tests" profile as none of those tests should fail. -->
<testFailureIgnore>true</testFailureIgnore>
+ <fast-tests>false</fast-tests>
</properties>
<scm>
@@ -1206,6 +1207,7 @@
This is used on PR checks -->
<id>fast-tests</id>
<properties>
+ <fast-tests>true</fast-tests>
<skipUnitTests>false</skipUnitTests>
<skipJmsTests>false</skipJmsTests>
<skipJoramTests>false</skipJoramTests>