You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by el...@apache.org on 2021/05/10 08:48:26 UTC

[ozone] branch master updated: HDDS-5099. Error with unit test for hdds.container-service TestSchemaOneBackwardsCompatibility (#2183)

This is an automated email from the ASF dual-hosted git repository.

elek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 75c5c10  HDDS-5099. Error with unit test for hdds.container-service TestSchemaOneBackwardsCompatibility (#2183)
75c5c10 is described below

commit 75c5c10bf3852449f156b10a7f2c12cf8ad30d63
Author: Neil Joshi <ne...@gmail.com>
AuthorDate: Mon May 10 02:48:07 2021 -0600

    HDDS-5099. Error with unit test for hdds.container-service TestSchemaOneBackwardsCompatibility (#2183)
---
 .../container/common/TestBlockDeletingService.java | 42 +++++++++++++++-------
 .../TestSchemaOneBackwardsCompatibility.java       | 18 ++++++++++
 2 files changed, 47 insertions(+), 13 deletions(-)

diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java
index 1e6dd0e..2a689dc 100644
--- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java
+++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java
@@ -398,7 +398,7 @@ public class TestBlockDeletingService {
   @Test
   public void testBlockDeletion() throws Exception {
     DatanodeConfiguration dnConf = conf.getObject(DatanodeConfiguration.class);
-    dnConf.setBlockDeletionLimit(3);
+    dnConf.setBlockDeletionLimit(2);
     this.blockLimitPerInterval = dnConf.getBlockDeletionLimit();
     conf.setFromObject(dnConf);
     ContainerSet containerSet = new ContainerSet();
@@ -447,6 +447,9 @@ public class TestBlockDeletingService {
       // An interval will delete 1 * 2 blocks
       deleteAndWait(svc, 1);
 
+      GenericTestUtils.waitFor(() ->
+              containerData.get(0).getBytesUsed() == containerSpace /
+                      3, 100, 3000);
       // After first interval 2 blocks will be deleted. Hence, current space
       // used by the container should be less than the space used by the
       // container initially(before running deletion services).
@@ -456,8 +459,8 @@ public class TestBlockDeletingService {
 
       // After deletion of all 3 blocks, space used by the containers
       // should be zero.
-      containerSpace = containerData.get(0).getBytesUsed();
-      Assert.assertTrue(containerSpace == 0);
+      GenericTestUtils.waitFor(() ->
+              containerData.get(0).getBytesUsed() == 0, 100, 3000);
 
       // Check finally DB counters.
       // Not checking bytes used, as handler is a mock call.
@@ -629,8 +632,11 @@ public class TestBlockDeletingService {
       // Hence, space used by the container of whose block has been
       // deleted should be zero.
       deleteAndWait(service, 1);
-      Assert.assertTrue((containerData.get(0).getBytesUsed() == 0)
-          || containerData.get(1).getBytesUsed() == 0);
+
+      GenericTestUtils.waitFor(() ->
+              (containerData.get(0).getBytesUsed() == 0 ||
+                      containerData.get(1).getBytesUsed() == 0),
+              100, 3000);
 
       Assert.assertFalse((containerData.get(0).getBytesUsed() == 0) && (
           containerData.get(1).getBytesUsed() == 0));
@@ -639,8 +645,10 @@ public class TestBlockDeletingService {
       // containers should be zero.
       deleteAndWait(service, 2);
 
-      Assert.assertTrue((containerData.get(0).getBytesUsed() == 0) && (
-          containerData.get(1).getBytesUsed() == 0));
+      GenericTestUtils.waitFor(() ->
+              (containerData.get(0).getBytesUsed() ==
+                      0 && containerData.get(1).getBytesUsed() == 0),
+              100, 3000);
     } finally {
       service.shutdown();
     }
@@ -702,9 +710,12 @@ public class TestBlockDeletingService {
       // Deleted space of 10 blocks should be equal to (initial total space
       // of container - current total space of container).
       deleteAndWait(service, 1);
-      Assert.assertEquals(blockLimitPerInterval * blockSpace,
-          (totalContainerSpace - currentBlockSpace(containerData,
-              containerCount)));
+
+      GenericTestUtils.waitFor(() ->
+              blockLimitPerInterval * blockSpace ==
+                      (totalContainerSpace -
+                              currentBlockSpace(containerData, containerCount)),
+              100, 3000);
 
       // There is only 5 blocks left to runDeletingTasks
 
@@ -713,9 +724,14 @@ public class TestBlockDeletingService {
       // - current total space of container(it will be zero as all blocks
       // in all the containers are deleted)).
       deleteAndWait(service, 2);
-      Assert.assertEquals(blocksPerContainer * containerCount * blockSpace,
-          (totalContainerSpace - currentBlockSpace(containerData,
-              containerCount)));
+
+      long totalContainerBlocks = blocksPerContainer*containerCount;
+      GenericTestUtils.waitFor(() ->
+              totalContainerBlocks * blockSpace ==
+                      (totalContainerSpace -
+                              currentBlockSpace(containerData, containerCount)),
+              100, 3000);
+
     } finally {
       service.shutdown();
     }
diff --git a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestSchemaOneBackwardsCompatibility.java b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestSchemaOneBackwardsCompatibility.java
index 00ebcb0..b08fd0d 100644
--- a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestSchemaOneBackwardsCompatibility.java
+++ b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestSchemaOneBackwardsCompatibility.java
@@ -249,6 +249,14 @@ public class TestSchemaOneBackwardsCompatibility {
 
     runBlockDeletingService(keyValueHandler);
 
+    GenericTestUtils.waitFor(() -> {
+      try {
+        return (newKvData().getBytesUsed() != initialTotalSpace);
+      } catch (IOException ex) {
+      }
+      return false;
+    }, 100, 3000);
+
     long currentTotalSpace = newKvData().getBytesUsed();
     long numberOfBlocksDeleted =
         (initialTotalSpace - currentTotalSpace) / blockSpace;
@@ -264,6 +272,7 @@ public class TestSchemaOneBackwardsCompatibility {
 
     try(ReferenceCountedDB refCountedDB = BlockUtils.getDB(newKvData(), conf)) {
       // Test results via block iteration.
+
       assertEquals(expectedDeletingBlocks,
               countDeletingBlocks(refCountedDB));
       assertEquals(expectedDeletedBlocks,
@@ -328,6 +337,14 @@ public class TestSchemaOneBackwardsCompatibility {
 
       runBlockDeletingService(keyValueHandler);
 
+      GenericTestUtils.waitFor(() -> {
+        try {
+          return (newKvData().getBytesUsed() != initialTotalSpace);
+        } catch (IOException ex) {
+        }
+        return false;
+      }, 100, 3000);
+
       long currentTotalSpace = newKvData().getBytesUsed();
 
       // After the block deleting service runs, get the number of
@@ -494,6 +511,7 @@ public class TestSchemaOneBackwardsCompatibility {
     service.runDeletingTasks();
     GenericTestUtils
         .waitFor(() -> service.getTimesOfProcessed() == 1, 100, 3000);
+
   }
 
   private ContainerSet makeContainerSet() throws Exception {

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org