Browse Source

Longer license wait for xpack rest tests (#89718)

Our CI release builds occasionally fail on xpack REST tests because the
ES license takes longer to generate than the allotted 10s wait. This PR
increases the wait time to 30s. Based on past test failures, this
should give us enough buffer. Note that this only happens for release
builds so far: these are slower than regular CI builds since we use a
different (slower) runner for these. These failures are quite rare (4
failures over the past month)

Another option would be to tailor this specifically towards release
builds via a system setting but that seems to overly complicate the
setup without much benefit.

Relates: #89237
Closes: #89587
Nikolaj Volgushev 3 years ago
parent
commit
e6754bf812

+ 15 - 2
x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/AbstractXPackRestTest.java

@@ -33,6 +33,7 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.function.Supplier;
 
@@ -100,7 +101,8 @@ public abstract class AbstractXPackRestTest extends ESClientYamlSuiteTestCase {
             Map.of(),
             List.of(),
             response -> true,
-            () -> "Exception when waiting for initial license to be generated"
+            () -> "Exception when waiting for initial license to be generated",
+            30 // longer wait time to accommodate slow-running CI release builds
         );
     }
 
@@ -141,6 +143,17 @@ public abstract class AbstractXPackRestTest extends ESClientYamlSuiteTestCase {
         List<Map<String, Object>> bodies,
         CheckedFunction<ClientYamlTestResponse, Boolean, IOException> success,
         Supplier<String> error
+    ) {
+        awaitCallApi(apiName, params, bodies, success, error, 10);
+    }
+
+    private void awaitCallApi(
+        String apiName,
+        Map<String, String> params,
+        List<Map<String, Object>> bodies,
+        CheckedFunction<ClientYamlTestResponse, Boolean, IOException> success,
+        Supplier<String> error,
+        long maxWaitTimeInSeconds
     ) {
         try {
             final AtomicReference<ClientYamlTestResponse> response = new AtomicReference<>();
@@ -155,7 +168,7 @@ public abstract class AbstractXPackRestTest extends ESClientYamlSuiteTestCase {
                     // rather than a runtime failure (which terminates the loop)
                     throw new AssertionError("Failed to call API " + apiName, e);
                 }
-            });
+            }, maxWaitTimeInSeconds, TimeUnit.SECONDS);
             success.apply(response.get());
         } catch (Exception e) {
             throw new IllegalStateException(error.get(), e);