From 7fa5cc558d4ff2aeb960e25b5296ace2591f5690 Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Thu, 5 Sep 2024 12:26:26 -0700 Subject: [PATCH 1/3] Test with 5 seconds Signed-off-by: Harsha Vamsi Kalluri --- .../src/main/java/org/opensearch/test/OpenSearchTestCase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java index b180187303a60..98dd209f127cd 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java @@ -1113,6 +1113,7 @@ public static void assertBusy(CheckedRunnable codeBlock) throws Excep * Runs the code block for the provided interval, waiting for no assertions to trip. */ public static void assertBusy(CheckedRunnable codeBlock, long maxWaitTime, TimeUnit unit) throws Exception { + maxWaitTime = 5; long maxTimeInMillis = TimeUnit.MILLISECONDS.convert(maxWaitTime, unit); // In case you've forgotten your high-school studies, log10(x) / log10(y) == log y(x) long iterations = Math.max(Math.round(Math.log10(maxTimeInMillis) / Math.log10(2)), 1); From 3a5e7145e9c275fb25ae2a3946bcd0501d8eaa08 Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Thu, 5 Sep 2024 14:08:12 -0700 Subject: [PATCH 2/3] Choose lower time Signed-off-by: Harsha Vamsi Kalluri --- .../src/main/java/org/opensearch/test/OpenSearchTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java index 98dd209f127cd..a351371844956 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java @@ -1113,7 +1113,7 @@ public static void assertBusy(CheckedRunnable codeBlock) throws Excep * Runs the code block for the provided interval, waiting for no assertions to trip. */ public static void assertBusy(CheckedRunnable codeBlock, long maxWaitTime, TimeUnit unit) throws Exception { - maxWaitTime = 5; + if ((unit.equals(TimeUnit.SECONDS) && maxWaitTime > 5) || unit.equals(TimeUnit.MINUTES)) maxWaitTime = 5; long maxTimeInMillis = TimeUnit.MILLISECONDS.convert(maxWaitTime, unit); // In case you've forgotten your high-school studies, log10(x) / log10(y) == log y(x) long iterations = Math.max(Math.round(Math.log10(maxTimeInMillis) / Math.log10(2)), 1); From ca42a9569dac81dbd88af419c4dacec57c061bae Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Thu, 5 Sep 2024 15:09:33 -0700 Subject: [PATCH 3/3] Choose lower time Signed-off-by: Harsha Vamsi Kalluri --- .../main/java/org/opensearch/test/OpenSearchTestCase.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java index a351371844956..123cbcc97320e 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java @@ -1113,7 +1113,11 @@ public static void assertBusy(CheckedRunnable codeBlock) throws Excep * Runs the code block for the provided interval, waiting for no assertions to trip. */ public static void assertBusy(CheckedRunnable codeBlock, long maxWaitTime, TimeUnit unit) throws Exception { - if ((unit.equals(TimeUnit.SECONDS) && maxWaitTime > 5) || unit.equals(TimeUnit.MINUTES)) maxWaitTime = 5; + if ((unit.equals(TimeUnit.SECONDS) && maxWaitTime > 5) || unit.equals(TimeUnit.MINUTES)) { + maxWaitTime = 10; + unit = TimeUnit.SECONDS; + } + ; long maxTimeInMillis = TimeUnit.MILLISECONDS.convert(maxWaitTime, unit); // In case you've forgotten your high-school studies, log10(x) / log10(y) == log y(x) long iterations = Math.max(Math.round(Math.log10(maxTimeInMillis) / Math.log10(2)), 1);