geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject incubator-geode git commit: GEODE-2082: fix flakiness in sameKeepsOneFile
Date Mon, 07 Nov 2016 23:43:41 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 89c522ad6 -> 64da18de4


GEODE-2082: fix flakiness in sameKeepsOneFile

* rename sameKeepsOneFile to aboveZeroKeepsAtLeastOneFile


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/64da18de
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/64da18de
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/64da18de

Branch: refs/heads/develop
Commit: 64da18de4fb64f59eab537fb7d01edf8d1117a9b
Parents: 89c522a
Author: Kirk Lund <klund@apache.org>
Authored: Mon Nov 7 11:21:23 2016 -0800
Committer: Kirk Lund <klund@apache.org>
Committed: Mon Nov 7 15:43:09 2016 -0800

----------------------------------------------------------------------
 .../DiskSpaceLimitIntegrationTest.java          | 39 ++++++++++++++++----
 1 file changed, 32 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/64da18de/geode-core/src/test/java/org/apache/geode/internal/statistics/DiskSpaceLimitIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/statistics/DiskSpaceLimitIntegrationTest.java
b/geode-core/src/test/java/org/apache/geode/internal/statistics/DiskSpaceLimitIntegrationTest.java
index 2381a53..9daa425 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/statistics/DiskSpaceLimitIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/statistics/DiskSpaceLimitIntegrationTest.java
@@ -43,7 +43,7 @@ import java.util.concurrent.TimeoutException;
 public class DiskSpaceLimitIntegrationTest {
 
   private static final long FILE_SIZE_LIMIT = 256;
-  private static final long DISK_SPACE_LIMIT = FILE_SIZE_LIMIT * 2;
+  private static final long DISK_SPACE_LIMIT = FILE_SIZE_LIMIT*2;
 
   private File dir;
   private File dirOfDeletedFiles;
@@ -117,12 +117,24 @@ public class DiskSpaceLimitIntegrationTest {
   }
 
   @Test
-  public void sameKeepsOneFile() throws Exception {
+  public void aboveZeroKeepsAtLeastOneFile() throws Exception {
     when(this.config.getArchiveDiskSpaceLimit()).thenReturn(DISK_SPACE_LIMIT);
     sampleUntilFileExists(archiveFile(1));
     sampleUntilFileExists(archiveFile(2));
+    sampleUntilFileDeleted(archiveFile(1));
+
     assertThat(archiveFile(1)).doesNotExist();
-    assertThat(archiveFile(2)).exists();
+
+    // different file systems may have different children created/deleted
+    int childFile = 2;
+    for (; childFile < 10; childFile++) {
+      if (archiveFile(childFile).exists()) {
+        break;
+      }
+    }
+    assertThat(childFile).isLessThan(10);
+
+    assertThat(archiveFile(childFile)).exists();
     assertThat(everExisted(archiveFile(1))).isTrue();
   }
 
@@ -143,6 +155,23 @@ public class DiskSpaceLimitIntegrationTest {
     System.out.println("Sampled " + count + " times to create " + file);
   }
 
+  private void sampleUntilFileDeleted(final File file)
+      throws InterruptedException, TimeoutException {
+    long minutes = 1;
+    long timeout = System.nanoTime() + MINUTES.toNanos(minutes);
+    int count = 0;
+    do {
+      sample(advanceNanosTimeStamp());
+      count++;
+      Thread.sleep(10);
+    } while (file.exists() && System.nanoTime() < timeout);
+    if (file.exists()) {
+      throw new TimeoutException("File " + file + " does not exist after " + count
+          + " samples within " + minutes + " " + MINUTES);
+    }
+    System.out.println("Sampled " + count + " times to delete " + file);
+  }
+
   private boolean everExisted(final File file) {
     if (file.exists()) {
       return true;
@@ -179,10 +208,6 @@ public class DiskSpaceLimitIntegrationTest {
         this.testName.getMethodName() + "-01-" + String.format("%02d", child) + ".gfs");
   }
 
-  private File archiveFile() {
-    return new File(this.archiveFileName);
-  }
-
   /**
    * Override protected method to move file instead of deleting it.
    */


Mime
View raw message