You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ps...@apache.org on 2021/02/26 18:47:00 UTC
[hbase] branch branch-2.2 updated: HBASE-25599 Backport
TestZKSecretWatcher improvement to branch-2.2 (#2979)
This is an automated email from the ASF dual-hosted git repository.
psomogyi pushed a commit to branch branch-2.2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.2 by this push:
new f4d771b HBASE-25599 Backport TestZKSecretWatcher improvement to branch-2.2 (#2979)
f4d771b is described below
commit f4d771b7a74018613885c417e8dc1e25b16e4c3b
Author: Peter Somogyi <ps...@apache.org>
AuthorDate: Fri Feb 26 19:46:23 2021 +0100
HBASE-25599 Backport TestZKSecretWatcher improvement to branch-2.2 (#2979)
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../hbase/security/token/TestZKSecretWatcher.java | 30 +++++++++++++---------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcher.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcher.java
index 6d5ad26..9620d22 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcher.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestZKSecretWatcher.java
@@ -29,7 +29,8 @@ import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.Waiter;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.SecurityTests;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
@@ -45,7 +46,7 @@ import org.slf4j.LoggerFactory;
* Test the synchronization of token authentication master keys through
* ZKSecretWatcher
*/
-@Category({SecurityTests.class, LargeTests.class})
+@Category({SecurityTests.class, MediumTests.class})
public class TestZKSecretWatcher {
@ClassRule
@@ -76,7 +77,7 @@ public class TestZKSecretWatcher {
// We subclass AuthenticationTokenSecretManager so that testKeyUpdate can receive
// notification on the removal of keyId
private static class AuthenticationTokenSecretManagerForTest
- extends AuthenticationTokenSecretManager {
+ extends AuthenticationTokenSecretManager {
private CountDownLatch latch = new CountDownLatch(1);
public AuthenticationTokenSecretManagerForTest(Configuration conf,
@@ -140,35 +141,35 @@ public class TestZKSecretWatcher {
// sanity check
assertTrue(KEY_MASTER.isMaster());
assertFalse(KEY_SLAVE.isMaster());
- int maxKeyId = 0;
KEY_MASTER.rollCurrentKey();
AuthenticationKey key1 = KEY_MASTER.getCurrentKey();
assertNotNull(key1);
- LOG.debug("Master current key: "+key1.getKeyId());
+ LOG.debug("Master current key (key1) {}", key1);
// wait for slave to update
Thread.sleep(1000);
AuthenticationKey slaveCurrent = KEY_SLAVE.getCurrentKey();
assertNotNull(slaveCurrent);
assertEquals(key1, slaveCurrent);
- LOG.debug("Slave current key: "+slaveCurrent.getKeyId());
+ LOG.debug("Slave current key (key1) {}", slaveCurrent);
// generate two more keys then expire the original
KEY_MASTER.rollCurrentKey();
AuthenticationKey key2 = KEY_MASTER.getCurrentKey();
- LOG.debug("Master new current key: "+key2.getKeyId());
+ LOG.debug("Master new current key (key2) {}", key2);
KEY_MASTER.rollCurrentKey();
AuthenticationKey key3 = KEY_MASTER.getCurrentKey();
- LOG.debug("Master new current key: "+key3.getKeyId());
+ LOG.debug("Master new current key (key3) {}", key3);
// force expire the original key
- key1.setExpiration(EnvironmentEdgeManager.currentTime() - 1000);
+ key1.setExpiration(EnvironmentEdgeManager.currentTime() - 100000);
KEY_MASTER.removeExpiredKeys();
// verify removed from master
assertNull(KEY_MASTER.getKey(key1.getKeyId()));
- // wait for slave to catch up
+ // Wait for slave to catch up. When remove hits KEY_SLAVE, we'll clear
+ // the latch and will progress beyond the await.
KEY_SLAVE.getLatch().await();
// make sure the slave has both new keys
AuthenticationKey slave2 = KEY_SLAVE.getKey(key2.getKeyId());
@@ -179,10 +180,15 @@ public class TestZKSecretWatcher {
assertEquals(key3, slave3);
slaveCurrent = KEY_SLAVE.getCurrentKey();
assertEquals(key3, slaveCurrent);
- LOG.debug("Slave current key: "+slaveCurrent.getKeyId());
+ LOG.debug("Slave current key (key3) {}", slaveCurrent);
// verify that the expired key has been removed
- assertNull(KEY_SLAVE.getKey(key1.getKeyId()));
+ Waiter.waitFor(TEST_UTIL.getConfiguration(), 30000,
+ () -> {
+ AuthenticationKey k = KEY_SLAVE.getKey(key1.getKeyId());
+ LOG.info("AuthKey1={}", k);
+ return k == null;});
+ assertNull("key1=" + KEY_SLAVE.getKey(key1.getKeyId()), KEY_SLAVE.getKey(key1.getKeyId()));
// bring up a new slave
Configuration conf = TEST_UTIL.getConfiguration();