use of org.apache.zookeeper.TestableZooKeeper in project zookeeper by apache.
the class FourLetterWordsWhiteListTest method testFourLetterWordsAllDisabledByDefault.
/*
* ZOOKEEPER-2693: test white list of four letter words.
* For 3.5.x default white list is empty. Verify that is
* the case (except 'stat' command which is enabled in ClientBase
* which other tests depend on.).
*/
@Test(timeout = 30000)
public void testFourLetterWordsAllDisabledByDefault() throws Exception {
stopServer();
FourLetterCommands.resetWhiteList();
System.setProperty("zookeeper.4lw.commands.whitelist", "stat");
startServer();
// Default white list for 3.5.x is empty, so all command should fail.
verifyAllCommandsFail();
TestableZooKeeper zk = createClient();
verifyAllCommandsFail();
zk.getData("/", true, null);
verifyAllCommandsFail();
zk.close();
verifyFuzzyMatch("stat", "Outstanding");
verifyAllCommandsFail();
}
use of org.apache.zookeeper.TestableZooKeeper in project zookeeper by apache.
the class FourLetterWordsWhiteListTest method verifyAllCommandsSuccess.
private void verifyAllCommandsSuccess() throws Exception {
verifyExactMatch("ruok", "imok");
verifyFuzzyMatch("envi", "java.version");
verifyFuzzyMatch("conf", "clientPort");
verifyFuzzyMatch("stat", "Outstanding");
verifyFuzzyMatch("srvr", "Outstanding");
verifyFuzzyMatch("cons", "queued");
verifyFuzzyMatch("dump", "Session");
verifyFuzzyMatch("wchs", "watches");
verifyFuzzyMatch("wchp", "");
verifyFuzzyMatch("wchc", "");
verifyFuzzyMatch("srst", "reset");
verifyFuzzyMatch("crst", "reset");
verifyFuzzyMatch("stat", "Outstanding");
verifyFuzzyMatch("srvr", "Outstanding");
verifyFuzzyMatch("cons", "queued");
verifyFuzzyMatch("gtmk", "306");
verifyFuzzyMatch("isro", "rw");
TestableZooKeeper zk = createClient();
String sid = getHexSessionId(zk.getSessionId());
verifyFuzzyMatch("stat", "queued");
verifyFuzzyMatch("srvr", "Outstanding");
verifyFuzzyMatch("cons", sid);
verifyFuzzyMatch("dump", sid);
verifyFuzzyMatch("dirs", "size");
zk.getData("/", true, null);
verifyFuzzyMatch("stat", "queued");
verifyFuzzyMatch("srvr", "Outstanding");
verifyFuzzyMatch("cons", sid);
verifyFuzzyMatch("dump", sid);
verifyFuzzyMatch("wchs", "watching 1");
verifyFuzzyMatch("wchp", sid);
verifyFuzzyMatch("wchc", sid);
verifyFuzzyMatch("dirs", "size");
zk.close();
verifyExactMatch("ruok", "imok");
verifyFuzzyMatch("envi", "java.version");
verifyFuzzyMatch("conf", "clientPort");
verifyFuzzyMatch("stat", "Outstanding");
verifyFuzzyMatch("srvr", "Outstanding");
verifyFuzzyMatch("cons", "queued");
verifyFuzzyMatch("dump", "Session");
verifyFuzzyMatch("wchs", "watch");
verifyFuzzyMatch("wchp", "");
verifyFuzzyMatch("wchc", "");
verifyFuzzyMatch("srst", "reset");
verifyFuzzyMatch("crst", "reset");
verifyFuzzyMatch("stat", "Outstanding");
verifyFuzzyMatch("srvr", "Outstanding");
verifyFuzzyMatch("cons", "queued");
verifyFuzzyMatch("mntr", "zk_server_state\tstandalone");
verifyFuzzyMatch("mntr", "num_alive_connections");
verifyFuzzyMatch("stat", "Connections");
verifyFuzzyMatch("srvr", "Connections");
verifyFuzzyMatch("dirs", "size");
}
use of org.apache.zookeeper.TestableZooKeeper in project zookeeper by apache.
the class FollowerResyncConcurrencyTest method testFollowerWatcherResync.
/**
* Verify that the server is sending the proper zxid, and as a result
* the watch doesn't fire. See ZOOKEEPER-1412.
*/
@Test
public void testFollowerWatcherResync() throws Exception {
QuorumUtil qu = new QuorumUtil(1);
qu.startAll();
int index = 1;
while (qu.getPeer(index).peer.follower == null) {
index++;
}
LOG.info("Connecting to follower: {}", index);
TestableZooKeeper zk1 = createTestableClient("localhost:" + qu.getPeer(index).peer.getClientPort());
zk1.create("/foo", "foo".getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
MyWatcher watcher = new MyWatcher();
TestableZooKeeper zk2 = createTestableClient(watcher, "localhost:" + qu.getPeer(index).peer.getClientPort());
zk2.exists("/foo", true);
watcher.reset();
zk2.testableConnloss();
if (!watcher.clientConnected.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)) {
fail("Unable to connect to server");
}
assertArrayEquals("foo".getBytes(), zk2.getData("/foo", false, null));
assertNull(watcher.events.poll(5, TimeUnit.SECONDS));
zk1.close();
zk2.close();
qu.shutdownAll();
}
use of org.apache.zookeeper.TestableZooKeeper in project zookeeper by apache.
the class FollowerResyncConcurrencyTest method testFollowerSendsLastZxid.
/**
* Verify that the server is sending the proper zxid. See ZOOKEEPER-1412.
*/
@Test
public void testFollowerSendsLastZxid() throws Exception {
QuorumUtil qu = new QuorumUtil(1);
qu.startAll();
int index = 1;
while (qu.getPeer(index).peer.follower == null) {
index++;
}
LOG.info("Connecting to follower: {}", index);
TestableZooKeeper zk = createTestableClient("localhost:" + qu.getPeer(index).peer.getClientPort());
assertEquals(0L, zk.testableLastZxid());
zk.exists("/", false);
long lzxid = zk.testableLastZxid();
assertTrue("lzxid:" + lzxid + " > 0", lzxid > 0);
zk.close();
qu.shutdownAll();
}
use of org.apache.zookeeper.TestableZooKeeper in project zookeeper by apache.
the class FollowerResyncConcurrencyTest method createTestableClient.
private static TestableZooKeeper createTestableClient(CountdownWatcher watcher, String hp) throws IOException, TimeoutException, InterruptedException {
TestableZooKeeper zk = new TestableZooKeeper(hp, ClientBase.CONNECTION_TIMEOUT, watcher);
watcher.waitForConnected(CONNECTION_TIMEOUT);
return zk;
}
Aggregations