HBASE-7554 TestZooKeeper depends on the execution order

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1432970 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
nkeywal 2013-01-14 16:06:16 +00:00
parent 90ed67dc9a
commit cfb6fbefe2

View File

@ -57,6 +57,8 @@ import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs; import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.ZooKeeper.States; import org.apache.zookeeper.ZooKeeper.States;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Stat;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
@ -121,7 +123,7 @@ public class TestZooKeeper {
* @throws InterruptedException * @throws InterruptedException
*/ */
// fails frequently, disabled for now, see HBASE-6406 // fails frequently, disabled for now, see HBASE-6406
// @Test //@Test
public void testClientSessionExpired() throws Exception { public void testClientSessionExpired() throws Exception {
Configuration c = new Configuration(TEST_UTIL.getConfiguration()); Configuration c = new Configuration(TEST_UTIL.getConfiguration());
@ -229,7 +231,7 @@ public class TestZooKeeper {
* Make sure we can use the cluster * Make sure we can use the cluster
* @throws Exception * @throws Exception
*/ */
public void testSanity() throws Exception{ private void testSanity() throws Exception{
HBaseAdmin admin = HBaseAdmin admin =
new HBaseAdmin(TEST_UTIL.getConfiguration()); new HBaseAdmin(TEST_UTIL.getConfiguration());
String tableName = "test"+System.currentTimeMillis(); String tableName = "test"+System.currentTimeMillis();
@ -356,6 +358,10 @@ public class TestZooKeeper {
ZooKeeperWatcher zk2 = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(), ZooKeeperWatcher zk2 = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
"testMasterAddressManagerFromZK", null); "testMasterAddressManagerFromZK", null);
// Save the previous ACL
Stat s = new Stat();
List<ACL> oldACL = zk.getACL("/", s);
// I set this acl after the attempted creation of the cluster home node. // I set this acl after the attempted creation of the cluster home node.
// Add retries in case of retryable zk exceptions. // Add retries in case of retryable zk exceptions.
while (true) { while (true) {
@ -395,6 +401,12 @@ public class TestZooKeeper {
} }
zk.close(); zk.close();
ZKUtil.createAndFailSilent(zk2, aclZnode); ZKUtil.createAndFailSilent(zk2, aclZnode);
// Restore the ACL
ZooKeeper zk3 = new ZooKeeper(quorumServers, sessionTimeout, EmptyWatcher.instance);
zk3.addAuthInfo("digest", "hbase:rox".getBytes());
zk3.setACL("/", oldACL, -1);
zk3.close();
} }
/** /**
@ -463,8 +475,8 @@ public class TestZooKeeper {
ZKAssign.blockUntilNoRIT(zooKeeperWatcher); ZKAssign.blockUntilNoRIT(zooKeeperWatcher);
HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName); HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName);
Put p = null; Put p;
int numberOfPuts = 0; int numberOfPuts;
for (numberOfPuts = 0; numberOfPuts < 6; numberOfPuts++) { for (numberOfPuts = 0; numberOfPuts < 6; numberOfPuts++) {
p = new Put(Bytes.toBytes(numberOfPuts)); p = new Put(Bytes.toBytes(numberOfPuts));
p.add(Bytes.toBytes("col"), Bytes.toBytes("ql"), Bytes.toBytes("value" + numberOfPuts)); p.add(Bytes.toBytes("col"), Bytes.toBytes("ql"), Bytes.toBytes("value" + numberOfPuts));