Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 223A8200BC5 for ; Tue, 8 Nov 2016 00:43:47 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 20D3F160AF9; Mon, 7 Nov 2016 23:43:47 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 66F65160AEC for ; Tue, 8 Nov 2016 00:43:46 +0100 (CET) Received: (qmail 20832 invoked by uid 500); 7 Nov 2016 23:43:45 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 20819 invoked by uid 99); 7 Nov 2016 23:43:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2016 23:43:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id A95D61A9A51 for ; Mon, 7 Nov 2016 23:43:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id djOaIGXRssCg for ; Mon, 7 Nov 2016 23:43:43 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 10F805FBDC for ; Mon, 7 Nov 2016 23:43:42 +0000 (UTC) Received: (qmail 20785 invoked by uid 99); 7 Nov 2016 23:43:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Nov 2016 23:43:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 94489E02E4; Mon, 7 Nov 2016 23:43:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.incubator.apache.org Message-Id: <2f851b64524c40509626c68495b9e63e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-geode git commit: GEODE-2082: fix flakiness in sameKeepsOneFile Date: Mon, 7 Nov 2016 23:43:41 +0000 (UTC) archived-at: Mon, 07 Nov 2016 23:43:47 -0000 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 Authored: Mon Nov 7 11:21:23 2016 -0800 Committer: Kirk Lund 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. */