This is an automated email from the ASF dual-hosted git repository.
zghao pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new b9b7b6e HBASE-21426 TestEncryptionKeyRotation.testCFKeyRotation is
flaky (#375)
b9b7b6e is described below
commit b9b7b6e734442d113e079c4786789bd3b4071207
Author: linkaline <[email protected]>
AuthorDate: Thu Jul 18 09:02:17 2019 +0800
HBASE-21426 TestEncryptionKeyRotation.testCFKeyRotation is flaky (#375)
Signed-off-by: Guanghao Zhang <[email protected]>
---
.../regionserver/TestEncryptionKeyRotation.java | 53 +++-------------------
1 file changed, 7 insertions(+), 46 deletions(-)
diff --git
a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEncryptionKeyRotation.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEncryptionKeyRotation.java
index 3a212f8..230e749 100644
---
a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEncryptionKeyRotation.java
+++
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEncryptionKeyRotation.java
@@ -35,7 +35,8 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.Waiter.Predicate;
+import org.apache.hadoop.hbase.Waiter;
+import org.apache.hadoop.hbase.client.CompactionState;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.io.crypto.Encryption;
@@ -133,27 +134,14 @@ public class TestEncryptionKeyRotation {
// And major compact
TEST_UTIL.getAdmin().majorCompact(htd.getTableName());
- final List<Path> updatePaths =
findCompactedStorefilePaths(htd.getTableName());
- TEST_UTIL.waitFor(30000, 1000, true, new Predicate<Exception>() {
+ // waiting for the major compaction to complete
+ TEST_UTIL.waitFor(30000, new Waiter.Predicate<IOException>() {
@Override
- public boolean evaluate() throws Exception {
- // When compaction has finished, all of the original files will be
- // gone
- boolean found = false;
- for (Path path: updatePaths) {
- found = TEST_UTIL.getTestFileSystem().exists(path);
- if (found) {
- LOG.info("Found " + path);
- break;
- }
- }
- return !found;
+ public boolean evaluate() throws IOException {
+ return TEST_UTIL.getAdmin().getCompactionState(htd.getTableName()) ==
+ CompactionState.NONE;
}
});
-
- // Verify we have store file(s) with only the new key
- Thread.sleep(1000);
- waitForCompaction(htd.getTableName());
List<Path> pathsAfterCompaction = findStorefilePaths(htd.getTableName());
assertTrue(pathsAfterCompaction.size() > 0);
for (Path path: pathsAfterCompaction) {
@@ -210,33 +198,6 @@ public class TestEncryptionKeyRotation {
}
}
- private static void waitForCompaction(TableName tableName)
- throws IOException, InterruptedException {
- boolean compacted = false;
- for (Region region : TEST_UTIL.getRSForFirstRegionInTable(tableName)
- .getRegions(tableName)) {
- for (HStore store : ((HRegion) region).getStores()) {
- compacted = false;
- while (!compacted) {
- if (store.getStorefiles() != null) {
- while (store.getStorefilesCount() != 1) {
- Thread.sleep(100);
- }
- for (HStoreFile storefile : store.getStorefiles()) {
- if (!storefile.isCompactedAway()) {
- compacted = true;
- break;
- }
- Thread.sleep(100);
- }
- } else {
- break;
- }
- }
- }
- }
- }
-
private static List<Path> findStorefilePaths(TableName tableName) throws
Exception {
List<Path> paths = new ArrayList<>();
for (Region region : TEST_UTIL.getRSForFirstRegionInTable(tableName)