diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneSnapshotRestore.java b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneSnapshotRestore.java index d61efd7d8bdb..55db121ab2eb 100644 --- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneSnapshotRestore.java +++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/snapshot/TestOzoneSnapshotRestore.java @@ -220,8 +220,9 @@ public void testRestoreSnapshot(BucketLayout bucketLayoutTest) Assertions.assertEquals(0, delKeyCount); String sourcePath = OM_KEY_PREFIX + volume + OM_KEY_PREFIX + bucket - + OM_KEY_PREFIX + snapshotKeyPrefix; - String destPath = OM_KEY_PREFIX + volume + OM_KEY_PREFIX + bucket; + + OM_KEY_PREFIX + snapshotKeyPrefix; + String destPath = OM_KEY_PREFIX + volume + OM_KEY_PREFIX + bucket + + OM_KEY_PREFIX; for (int i = 0; i < 5; i++) { keyCopy(sourcePath + keyPrefix + i, destPath); @@ -258,9 +259,25 @@ public void testRestoreSnapshotDifferentBucket(BucketLayout bucketLayoutTest) int volBucketKeyCount = keyCount(buck, snapshotKeyPrefix + keyPrefix); Assertions.assertEquals(5, volBucketKeyCount); + // Delete keys from the source bucket. + // This is temporary fix to make sure that test passes all the time. + // If we don't delete keys from the source bucket, copy command + // will fail. In copy command, there is a check to make sure that key + // doesn't exist in the destination bucket. + // Problem is that RocksDB's seek operation doesn't 100% guarantee that + // item key is available. Tho we believe that it is in + // `createFakeDirIfShould` function. When we seek if there is a directory + // for the key name, sometime it returns non-null response but in reality + // item doesn't exist. + // In the case when seek returns non-null response, "key doesn't exist in + // the destination bucket" check fails because getFileStatus returns + // dir with key name exists. + deleteKeys(buck); + String sourcePath = OM_KEY_PREFIX + volume + OM_KEY_PREFIX + bucket - + OM_KEY_PREFIX + snapshotKeyPrefix; - String destPath = OM_KEY_PREFIX + volume + OM_KEY_PREFIX + bucket2; + + OM_KEY_PREFIX + snapshotKeyPrefix; + String destPath = OM_KEY_PREFIX + volume + OM_KEY_PREFIX + bucket2 + + OM_KEY_PREFIX; for (int i = 0; i < 5; i++) { keyCopy(sourcePath + keyPrefix + i, destPath); @@ -302,8 +319,9 @@ public void testRestoreSnapshotDifferentBucketLayout( Assertions.assertEquals(5, volBucketKeyCount); String sourcePath = OM_KEY_PREFIX + volume + OM_KEY_PREFIX + bucket - + OM_KEY_PREFIX + snapshotKeyPrefix; - String destPath = OM_KEY_PREFIX + volume + OM_KEY_PREFIX + bucket2; + + OM_KEY_PREFIX + snapshotKeyPrefix; + String destPath = OM_KEY_PREFIX + volume + OM_KEY_PREFIX + bucket2 + + OM_KEY_PREFIX; for (int i = 0; i < 5; i++) { keyCopy(sourcePath + keyPrefix + i, destPath);