ARTEMIS-3458 Reduce number of ZK nodes for fast-tests runs
This commit is contained in:
parent
ce3b50c1a6
commit
082f06a095
|
@ -122,6 +122,15 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
|
@ -61,8 +61,10 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
private static final int RETRIES_MS = 100;
|
private static final int RETRIES_MS = 100;
|
||||||
private static final int RETRIES = 1;
|
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
|
@Parameterized.Parameter
|
||||||
public int nodes;
|
public int zkNodes;
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder tmpFolder = new TemporaryFolder();
|
public TemporaryFolder tmpFolder = new TemporaryFolder();
|
||||||
private TestingCluster testingServer;
|
private TestingCluster testingServer;
|
||||||
|
@ -71,13 +73,13 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
|
|
||||||
@Parameterized.Parameters(name = "nodes={0}")
|
@Parameterized.Parameters(name = "nodes={0}")
|
||||||
public static Iterable<Object[]> getTestParameters() {
|
public static Iterable<Object[]> getTestParameters() {
|
||||||
return Arrays.asList(new Object[][]{{3}, {5}});
|
return Arrays.asList(new Object[][]{{ZK_NODES}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupEnv() throws Throwable {
|
public void setupEnv() throws Throwable {
|
||||||
clusterSpecs = new InstanceSpec[nodes];
|
clusterSpecs = new InstanceSpec[zkNodes];
|
||||||
for (int i = 0; i < nodes; i++) {
|
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);
|
clusterSpecs[i] = new InstanceSpec(tmpFolder.newFolder(), BASE_SERVER_PORT + i, -1, -1, true, -1, SERVER_TICK_MS, -1);
|
||||||
}
|
}
|
||||||
testingServer = new TestingCluster(clusterSpecs);
|
testingServer = new TestingCluster(clusterSpecs);
|
||||||
|
@ -181,6 +183,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canAcquireLockOnMajorityRestart() throws Exception {
|
public void canAcquireLockOnMajorityRestart() throws Exception {
|
||||||
|
Assume.assumeThat(zkNodes, greaterThan(1));
|
||||||
final DistributedPrimitiveManager manager = createManagedDistributeManager();
|
final DistributedPrimitiveManager manager = createManagedDistributeManager();
|
||||||
manager.start();
|
manager.start();
|
||||||
final DistributedLock lock = manager.getDistributedLock("a");
|
final DistributedLock lock = manager.getDistributedLock("a");
|
||||||
|
@ -203,7 +206,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cannotStartManagerWithoutQuorum() throws Exception {
|
public void cannotStartManagerWithoutQuorum() throws Exception {
|
||||||
Assume.assumeThat(nodes, greaterThan(1));
|
Assume.assumeThat(zkNodes, greaterThan(1));
|
||||||
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
||||||
stopMajorityNotLeaderNodes(true);
|
stopMajorityNotLeaderNodes(true);
|
||||||
Assert.assertFalse(manager.start(2, TimeUnit.SECONDS));
|
Assert.assertFalse(manager.start(2, TimeUnit.SECONDS));
|
||||||
|
@ -212,7 +215,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
|
|
||||||
@Test(expected = UnavailableStateException.class)
|
@Test(expected = UnavailableStateException.class)
|
||||||
public void cannotAcquireLockWithoutQuorum() throws Exception {
|
public void cannotAcquireLockWithoutQuorum() throws Exception {
|
||||||
Assume.assumeThat(nodes, greaterThan(1));
|
Assume.assumeThat(zkNodes, greaterThan(1));
|
||||||
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
||||||
manager.start();
|
manager.start();
|
||||||
stopMajorityNotLeaderNodes(true);
|
stopMajorityNotLeaderNodes(true);
|
||||||
|
@ -222,7 +225,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cannotCheckLockWithoutQuorum() throws Exception {
|
public void cannotCheckLockWithoutQuorum() throws Exception {
|
||||||
Assume.assumeThat(nodes, greaterThan(1));
|
Assume.assumeThat(zkNodes, greaterThan(1));
|
||||||
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
||||||
manager.start();
|
manager.start();
|
||||||
stopMajorityNotLeaderNodes(true);
|
stopMajorityNotLeaderNodes(true);
|
||||||
|
@ -238,7 +241,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canGetLockWithoutQuorum() throws Exception {
|
public void canGetLockWithoutQuorum() throws Exception {
|
||||||
Assume.assumeThat(nodes, greaterThan(1));
|
Assume.assumeThat(zkNodes, greaterThan(1));
|
||||||
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
||||||
manager.start();
|
manager.start();
|
||||||
stopMajorityNotLeaderNodes(true);
|
stopMajorityNotLeaderNodes(true);
|
||||||
|
@ -248,7 +251,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void notifiedAsUnavailableWhileLoosingQuorum() throws Exception {
|
public void notifiedAsUnavailableWhileLoosingQuorum() throws Exception {
|
||||||
Assume.assumeThat(nodes, greaterThan(1));
|
Assume.assumeThat(zkNodes, greaterThan(1));
|
||||||
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
||||||
manager.start();
|
manager.start();
|
||||||
DistributedLock lock = manager.getDistributedLock("a");
|
DistributedLock lock = manager.getDistributedLock("a");
|
||||||
|
@ -260,7 +263,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void beNotifiedOnce() throws Exception {
|
public void beNotifiedOnce() throws Exception {
|
||||||
Assume.assumeThat(nodes, greaterThan(1));
|
Assume.assumeThat(zkNodes, greaterThan(1));
|
||||||
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
||||||
manager.start();
|
manager.start();
|
||||||
DistributedLock lock = manager.getDistributedLock("a");
|
DistributedLock lock = manager.getDistributedLock("a");
|
||||||
|
@ -276,7 +279,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void beNotifiedOfUnavailabilityWhileBlockedOnTimedLock() throws Exception {
|
public void beNotifiedOfUnavailabilityWhileBlockedOnTimedLock() throws Exception {
|
||||||
Assume.assumeThat(nodes, greaterThan(1));
|
Assume.assumeThat(zkNodes, greaterThan(1));
|
||||||
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
||||||
manager.start();
|
manager.start();
|
||||||
DistributedLock lock = manager.getDistributedLock("a");
|
DistributedLock lock = manager.getDistributedLock("a");
|
||||||
|
@ -312,6 +315,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void beNotifiedOfAlreadyUnavailableManagerAfterAddingListener() throws Exception {
|
public void beNotifiedOfAlreadyUnavailableManagerAfterAddingListener() throws Exception {
|
||||||
|
Assume.assumeThat(zkNodes, greaterThan(1));
|
||||||
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
DistributedPrimitiveManager manager = createManagedDistributeManager();
|
||||||
manager.start();
|
manager.start();
|
||||||
final AtomicBoolean unavailable = new AtomicBoolean(false);
|
final AtomicBoolean unavailable = new AtomicBoolean(false);
|
||||||
|
@ -338,6 +342,9 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isLeader(TestingZooKeeperServer server) {
|
private static boolean isLeader(TestingZooKeeperServer server) {
|
||||||
|
if (server.getInstanceSpecs().size() == 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
long leaderId = server.getQuorumPeer().getLeaderId();
|
long leaderId = server.getQuorumPeer().getLeaderId();
|
||||||
long id = server.getQuorumPeer().getId();
|
long id = server.getQuorumPeer().getId();
|
||||||
return id == leaderId;
|
return id == leaderId;
|
||||||
|
@ -345,7 +352,7 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
|
|
||||||
private void stopMajorityNotLeaderNodes(boolean fromLast) throws Exception {
|
private void stopMajorityNotLeaderNodes(boolean fromLast) throws Exception {
|
||||||
List<TestingZooKeeperServer> followers = testingServer.getServers().stream().filter(Predicates.not(CuratorDistributedLockTest::isLeader)).collect(Collectors.toList());
|
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++) {
|
for (int i = 0; i < quorum; i++) {
|
||||||
final int nodeIndex = fromLast ? (followers.size() - 1) - i : i;
|
final int nodeIndex = fromLast ? (followers.size() - 1) - i : i;
|
||||||
followers.get(nodeIndex).stop();
|
followers.get(nodeIndex).stop();
|
||||||
|
@ -353,9 +360,9 @@ public class CuratorDistributedLockTest extends DistributedLockTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restartMajorityNodes(boolean startFromLast) throws Exception {
|
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++) {
|
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])) {
|
if (!testingServer.restartServer(clusterSpecs[nodeIndex])) {
|
||||||
throw new IllegalStateException("errored while restarting " + clusterSpecs[nodeIndex]);
|
throw new IllegalStateException("errored while restarting " + clusterSpecs[nodeIndex]);
|
||||||
}
|
}
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -219,6 +219,7 @@
|
||||||
<!-- Ignore failed tests by default because there are "known" failures in the full test-suite.
|
<!-- 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. -->
|
This will be set to false for the "fast-tests" profile as none of those tests should fail. -->
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
<testFailureIgnore>true</testFailureIgnore>
|
||||||
|
<fast-tests>false</fast-tests>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
|
@ -1206,6 +1207,7 @@
|
||||||
This is used on PR checks -->
|
This is used on PR checks -->
|
||||||
<id>fast-tests</id>
|
<id>fast-tests</id>
|
||||||
<properties>
|
<properties>
|
||||||
|
<fast-tests>true</fast-tests>
|
||||||
<skipUnitTests>false</skipUnitTests>
|
<skipUnitTests>false</skipUnitTests>
|
||||||
<skipJmsTests>false</skipJmsTests>
|
<skipJmsTests>false</skipJmsTests>
|
||||||
<skipJoramTests>false</skipJoramTests>
|
<skipJoramTests>false</skipJoramTests>
|
||||||
|
|
Loading…
Reference in New Issue