use of org.junit.jupiter.api.Timeout in project zookeeper by apache.
the class QuorumSSLTest method testHostnameVerificationWithValidIpAddressAndInvalidHostname.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
public void testHostnameVerificationWithValidIpAddressAndInvalidHostname() throws Exception {
String badhostnameKeystorePath = tmpDir + "/badhost.jks";
X509Certificate badHostCert = buildEndEntityCert(defaultKeyPair, rootCertificate, rootKeyPair.getPrivate(), "bleepbloop", "127.0.0.1", null, null);
writeKeystore(badHostCert, defaultKeyPair, badhostnameKeystorePath);
testHostnameVerification(badhostnameKeystorePath, true);
}
use of org.junit.jupiter.api.Timeout in project zookeeper by apache.
the class QuorumSSLTest method testRollingUpgrade.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
public void testRollingUpgrade() throws Exception {
// Form a quorum without ssl
q1 = new MainThread(1, clientPortQp1, quorumConfiguration);
q2 = new MainThread(2, clientPortQp2, quorumConfiguration);
q3 = new MainThread(3, clientPortQp3, quorumConfiguration);
Map<Integer, MainThread> members = new HashMap<>();
members.put(clientPortQp1, q1);
members.put(clientPortQp2, q2);
members.put(clientPortQp3, q3);
for (MainThread member : members.values()) {
member.start();
}
for (int clientPort : members.keySet()) {
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPort, CONNECTION_TIMEOUT));
}
// Set SSL system properties and port unification, begin restarting servers
setSSLSystemProperties();
stopAppendConfigRestartAll(members, PORT_UNIFICATION_ENABLED);
stopAppendConfigRestartAll(members, SSL_QUORUM_ENABLED);
stopAppendConfigRestartAll(members, PORT_UNIFICATION_DISABLED);
}
use of org.junit.jupiter.api.Timeout in project zookeeper by apache.
the class QuorumSSLTest method testCertificateRevocationList.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
public void testCertificateRevocationList() throws Exception {
q1 = new MainThread(1, clientPortQp1, quorumConfiguration, SSL_QUORUM_ENABLED);
q2 = new MainThread(2, clientPortQp2, quorumConfiguration, SSL_QUORUM_ENABLED);
q1.start();
q2.start();
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp1, CONNECTION_TIMEOUT));
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp2, CONNECTION_TIMEOUT));
String revokedInCRLKeystorePath = tmpDir + "/crl_revoked.jks";
String crlPath = tmpDir + "/crl.pem";
X509Certificate revokedInCRLCert = buildEndEntityCert(defaultKeyPair, rootCertificate, rootKeyPair.getPrivate(), HOSTNAME, null, crlPath, null);
writeKeystore(revokedInCRLCert, defaultKeyPair, revokedInCRLKeystorePath);
buildCRL(revokedInCRLCert, crlPath);
System.setProperty(quorumX509Util.getSslKeystoreLocationProperty(), revokedInCRLKeystorePath);
// This server should join successfully
q3 = new MainThread(3, clientPortQp3, quorumConfiguration, SSL_QUORUM_ENABLED);
q3.start();
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
q1.shutdown();
q2.shutdown();
q3.shutdown();
assertTrue(ClientBase.waitForServerDown("127.0.0.1:" + clientPortQp1, CONNECTION_TIMEOUT));
assertTrue(ClientBase.waitForServerDown("127.0.0.1:" + clientPortQp2, CONNECTION_TIMEOUT));
assertTrue(ClientBase.waitForServerDown("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
setSSLSystemProperties();
System.setProperty(quorumX509Util.getSslCrlEnabledProperty(), "true");
X509Certificate validCertificate = buildEndEntityCert(defaultKeyPair, rootCertificate, rootKeyPair.getPrivate(), HOSTNAME, null, crlPath, null);
writeKeystore(validCertificate, defaultKeyPair, validKeystorePath);
q1.start();
q2.start();
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp1, CONNECTION_TIMEOUT));
assertTrue(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp2, CONNECTION_TIMEOUT));
System.setProperty(quorumX509Util.getSslKeystoreLocationProperty(), revokedInCRLKeystorePath);
q3.start();
assertFalse(ClientBase.waitForServerUp("127.0.0.1:" + clientPortQp3, CONNECTION_TIMEOUT));
}
use of org.junit.jupiter.api.Timeout in project zookeeper by apache.
the class QuorumSSLTest method testHostnameVerificationWithInvalidHostname.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
public void testHostnameVerificationWithInvalidHostname() throws Exception {
String badhostnameKeystorePath = tmpDir + "/badhost.jks";
X509Certificate badHostCert = buildEndEntityCert(defaultKeyPair, rootCertificate, rootKeyPair.getPrivate(), "bleepbloop", null, null, null);
writeKeystore(badHostCert, defaultKeyPair, badhostnameKeystorePath);
testHostnameVerification(badhostnameKeystorePath, false);
}
use of org.junit.jupiter.api.Timeout in project zookeeper by apache.
the class StandaloneDisabledTest method startSingleServerTest.
/**
* Test normal quorum operations work cleanly
* with just a single server.
*/
@Test
@Timeout(value = 10, unit = TimeUnit.MINUTES)
public void startSingleServerTest() throws Exception {
setUpData();
// start one server
startServer(leaderId, serverStrings.get(leaderId) + "\n");
ReconfigTest.testServerHasConfig(zkHandles[leaderId], null, null);
LOG.info("Initial Configuration:\n{}", new String(zkHandles[leaderId].getConfig(this, new Stat())));
// start and add 2 followers
startFollowers();
testReconfig(leaderId, true, reconfigServers);
LOG.info("Configuration after adding 2 followers:\n{}", new String(zkHandles[leaderId].getConfig(this, new Stat())));
// shutdown leader- quorum should still exist
shutDownServer(leaderId);
ReconfigTest.testNormalOperation(zkHandles[follower1], zkHandles[follower2]);
// should not be able to remove follower 2
// No quorum in new config (1/2)
reconfigServers.clear();
reconfigServers.add(Integer.toString(follower2));
try {
ReconfigTest.reconfig(zkAdminHandles[follower1], null, reconfigServers, null, -1);
fail("reconfig completed successfully even though there is no quorum up in new config!");
} catch (KeeperException.NewConfigNoQuorum e) {
}
// reconfigure out leader and follower 1. Remaining follower
// 2 should elect itself as leader and run by itself
reconfigServers.clear();
reconfigServers.add(Integer.toString(leaderId));
reconfigServers.add(Integer.toString(follower1));
testReconfig(follower2, false, reconfigServers);
LOG.info("Configuration after removing leader and follower 1:\n{}", new String(zkHandles[follower2].getConfig(this, new Stat())));
// Kill server 1 to avoid it interferences with FLE of the quorum {2, 3, 4}.
shutDownServer(follower1);
// Try to remove follower2, which is the only remaining server. This should fail.
reconfigServers.clear();
reconfigServers.add(Integer.toString(follower2));
try {
zkAdminHandles[follower2].reconfigure(null, reconfigServers, null, -1, new Stat());
fail("reconfig completed successfully even though there is no quorum up in new config!");
} catch (KeeperException.BadArgumentsException e) {
// This is expected.
} catch (Exception e) {
fail("Should have been BadArgumentsException!");
}
// Add two participants and change them to observers to check
// that we can reconfigure down to one participant with observers.
ArrayList<String> observerStrings = new ArrayList<String>();
startObservers(observerStrings);
// add partcipants
testReconfig(follower2, true, reconfigServers);
// change to observers
testReconfig(follower2, true, observerStrings);
LOG.info("Configuration after adding two observers:\n{}", new String(zkHandles[follower2].getConfig(this, new Stat())));
shutDownData();
}
Aggregations