Search in sources :

Example 6 with MainThread

use of org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread in project zookeeper by apache.

the class QuorumKerberosAuthTest method tearDown.

@After
public void tearDown() throws Exception {
    for (MainThread mainThread : mt) {
        mainThread.shutdown();
        mainThread.deleteBaseDir();
    }
}
Also used : MainThread(org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread) After(org.junit.After)

Example 7 with MainThread

use of org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread in project zookeeper by apache.

the class QuorumKerberosHostBasedAuthTest method tearDown.

@After
public void tearDown() throws Exception {
    for (MainThread mainThread : mt) {
        mainThread.shutdown();
        mainThread.deleteBaseDir();
    }
}
Also used : MainThread(org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread) After(org.junit.After)

Example 8 with MainThread

use of org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread in project zookeeper by apache.

the class QuorumAuthTestBase method shutdown.

MainThread shutdown(int index) {
    MainThread mainThread = mt.get(index);
    try {
        mainThread.shutdown();
    } catch (InterruptedException e) {
    } finally {
        mt.remove(index);
    }
    mainThread.deleteBaseDir();
    return mainThread;
}
Also used : MainThread(org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread)

Example 9 with MainThread

use of org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread in project zookeeper by apache.

the class QuorumAuthUpgradeTest method testRollingUpgrade.

/**
 * Rolling upgrade should do in three steps:
 *
 * step-1) Stop the server and set the flags and restart the server.
 * quorum.auth.enableSasl=true, quorum.auth.learnerRequireSasl=false and quorum.auth.serverRequireSasl=false
 * Ensure that all the servers should complete this step. Now, move to next step.
 *
 * step-2) Stop the server one by one and change the flags and restart the server.
 * quorum.auth.enableSasl=true, quorum.auth.learnerRequireSasl=true and quorum.auth.serverRequireSasl=false
 * Ensure that all the servers should complete this step. Now, move to next step.
 *
 * step-3) Stop the server one by one and change the flags and restart the server.
 * quorum.auth.enableSasl=true, quorum.auth.learnerRequireSasl=true and quorum.auth.serverRequireSasl=true
 * Now, all the servers are fully upgraded and running in secured mode.
 */
@Test(timeout = 90000)
public void testRollingUpgrade() throws Exception {
    // Start peer0,1,2 servers with quorum.auth.enableSasl=false and
    // quorum.auth.learnerRequireSasl=false, quorum.auth.serverRequireSasl=false
    // Assume this is an existing cluster.
    Map<String, String> authConfigs = new HashMap<String, String>();
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "false");
    String connectStr = startQuorum(3, authConfigs, 0);
    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zk = new ZooKeeper(connectStr, ClientBase.CONNECTION_TIMEOUT, watcher);
    watcher.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
    zk.create("/foo", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
    // 1. Upgrade peer0,1,2 with quorum.auth.enableSasl=true and
    // quorum.auth.learnerRequireSasl=false, quorum.auth.serverRequireSasl=false
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "true");
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "false");
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED, "false");
    restartServer(authConfigs, 0, zk, watcher);
    restartServer(authConfigs, 1, zk, watcher);
    restartServer(authConfigs, 2, zk, watcher);
    // 2. Upgrade peer0,1,2 with quorum.auth.enableSasl=true and
    // quorum.auth.learnerRequireSasl=true, quorum.auth.serverRequireSasl=false
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "true");
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED, "true");
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "false");
    restartServer(authConfigs, 0, zk, watcher);
    restartServer(authConfigs, 1, zk, watcher);
    restartServer(authConfigs, 2, zk, watcher);
    // 3. Upgrade peer0,1,2 with quorum.auth.enableSasl=true and
    // quorum.auth.learnerRequireSasl=true, quorum.auth.serverRequireSasl=true
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "true");
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED, "true");
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "true");
    restartServer(authConfigs, 0, zk, watcher);
    restartServer(authConfigs, 1, zk, watcher);
    restartServer(authConfigs, 2, zk, watcher);
    // 4. Restart peer2 with quorum.auth.learnerEnableSasl=false and
    // quorum.auth.serverRequireSasl=false. It should fail to join the
    // quorum as this needs auth.
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "false");
    MainThread m = shutdown(2);
    startServer(m, authConfigs);
    Assert.assertFalse("waiting for server 2 being up", ClientBase.waitForServerUp("127.0.0.1:" + m.getClientPort(), 5000));
}
Also used : MainThread(org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread) ZooKeeper(org.apache.zookeeper.ZooKeeper) HashMap(java.util.HashMap) CountdownWatcher(org.apache.zookeeper.test.ClientBase.CountdownWatcher) ClientTest(org.apache.zookeeper.test.ClientTest) Test(org.junit.Test)

Example 10 with MainThread

use of org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread in project zookeeper by apache.

the class QuorumDigestAuthTest method tearDown.

@After
public void tearDown() throws Exception {
    for (MainThread mainThread : mt) {
        mainThread.shutdown();
        mainThread.deleteBaseDir();
    }
}
Also used : MainThread(org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread) After(org.junit.After)

Aggregations

MainThread (org.apache.zookeeper.server.quorum.QuorumPeerTestBase.MainThread)12 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 After (org.junit.After)3 IOException (java.io.IOException)2 ZooKeeper (org.apache.zookeeper.ZooKeeper)2 ConfigException (org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException)2 QuorumPeerMain (org.apache.zookeeper.server.quorum.QuorumPeerMain)2 CountdownWatcher (org.apache.zookeeper.test.ClientBase.CountdownWatcher)2 TimeoutException (java.util.concurrent.TimeoutException)1 ClientTest (org.apache.zookeeper.test.ClientTest)1