From 7a21886cd2fdb9ed187cdb8f6750768153037722 Mon Sep 17 00:00:00 2001 From: Laura Trotta Date: Fri, 28 Mar 2025 18:24:45 +0100 Subject: [PATCH 1/3] avoid executing stress test from gha --- .github/workflows/unit-tests.yml | 3 +++ .../_helpers/bulk/BulkIngesterRetryPolicyTest.java | 9 +++++++++ .../elasticsearch/_helpers/bulk/BulkIngesterTest.java | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index da6db221c..57f01a98e 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -20,5 +20,8 @@ jobs: java-version: '17' distribution: 'temurin' + - name: Set env + run: echo "github_test=true" >> $GITHUB_ENV + - name: Run java client tests run: ./gradlew test -p java-client diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java index dede24b9c..2cadb3c13 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java @@ -38,12 +38,15 @@ import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIf; +import javax.swing.text.html.Option; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; @@ -287,6 +290,7 @@ public void retryTestNoFlushAndContextExponentialBackoff() throws Exception { } @Test + @DisabledIf("isGithubBuild") public void retryMultiThreadStressTest() throws InterruptedException, IOException { // DISCLAIMER: this configuration is highly inefficient and only used here to showcase an extreme @@ -541,4 +545,9 @@ private BulkIngester newBulkIngesterNoFlushAndContextAndLongExponential .backoffPolicy(BackoffPolicy.exponentialBackoff(100L, 8)) ); } + + private boolean isGithubBuild(){ + return Optional.ofNullable(System.getenv("github_test")) + .map(Boolean::valueOf).orElse(false); + } } diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java index 76a48b9fa..59ce6a454 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java @@ -38,12 +38,14 @@ import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIf; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; @@ -176,6 +178,7 @@ private void multiThreadTest(int maxOperations, int maxRequests, int numThreads, } @Test + @DisabledIf("isGithubBuild") public void multiThreadStressTest() throws InterruptedException, IOException { String index = "bulk-ingester-stress-test"; @@ -620,4 +623,8 @@ public void close() throws IOException { } } } + private boolean isGithubBuild(){ + return Optional.ofNullable(System.getenv("github_test")) + .map(Boolean::valueOf).orElse(false); + } } From 2beaf9c83784aba57cf722122c2413c8e9fcd7f3 Mon Sep 17 00:00:00 2001 From: Laura Trotta Date: Fri, 28 Mar 2025 18:33:03 +0100 Subject: [PATCH 2/3] wrong import --- .../elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java index 2cadb3c13..240b67d8b 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java @@ -40,7 +40,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIf; -import javax.swing.text.html.Option; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; From bb1fd1529022c69f643e74b97bb3976f5730ad94 Mon Sep 17 00:00:00 2001 From: Laura Trotta Date: Tue, 1 Apr 2025 11:01:37 +0200 Subject: [PATCH 3/3] using existing github env --- .github/workflows/unit-tests.yml | 4 ---- .../_helpers/bulk/BulkIngesterRetryPolicyTest.java | 4 ++-- .../clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 57f01a98e..e2138789c 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -19,9 +19,5 @@ jobs: with: java-version: '17' distribution: 'temurin' - - - name: Set env - run: echo "github_test=true" >> $GITHUB_ENV - - name: Run java client tests run: ./gradlew test -p java-client diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java index 240b67d8b..e4bbf88f8 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterRetryPolicyTest.java @@ -546,7 +546,7 @@ private BulkIngester newBulkIngesterNoFlushAndContextAndLongExponential } private boolean isGithubBuild(){ - return Optional.ofNullable(System.getenv("github_test")) - .map(Boolean::valueOf).orElse(false); + return Optional.ofNullable(System.getenv("GITHUB_JOB")) + .isPresent(); } } diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java index 59ce6a454..08face1a2 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java @@ -624,7 +624,7 @@ public void close() throws IOException { } } private boolean isGithubBuild(){ - return Optional.ofNullable(System.getenv("github_test")) - .map(Boolean::valueOf).orElse(false); + return Optional.ofNullable(System.getenv("GITHUB_JOB")) + .isPresent(); } }