diff --git a/src/main/java/io/odh/test/platform/RayClient.java b/src/main/java/io/odh/test/platform/RayClient.java index 53821131..90eab93c 100644 --- a/src/main/java/io/odh/test/platform/RayClient.java +++ b/src/main/java/io/odh/test/platform/RayClient.java @@ -14,6 +14,7 @@ import lombok.SneakyThrows; import java.io.IOException; +import java.net.HttpURLConnection; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; @@ -42,6 +43,20 @@ public RayClient(HttpClient httpClient, String baseUrl, String oauthToken) { this.oauthToken = oauthToken; } + /** + * Check that the API server is responsive and ready to accept jobs + */ + @SneakyThrows + public boolean isLive() { + HttpRequest request = buildRequest() + .uri(URI.create(baseUrl + "/api/jobs/")) + .method("HEAD", HttpRequest.BodyPublishers.noBody()) + .build(); + HttpResponse result = httpClient.send(request, HttpResponse.BodyHandlers.discarding()); + + return result.statusCode() == HttpURLConnection.HTTP_OK; + } + /** * @return Job ID */ diff --git a/src/test/java/io/odh/test/e2e/standard/DistributedST.java b/src/test/java/io/odh/test/e2e/standard/DistributedST.java index 2adad476..e8c0d03f 100644 --- a/src/test/java/io/odh/test/e2e/standard/DistributedST.java +++ b/src/test/java/io/odh/test/e2e/standard/DistributedST.java @@ -38,6 +38,7 @@ import io.skodjob.annotations.SuiteDoc; import io.skodjob.annotations.TestDoc; import io.skodjob.testframe.resources.KubeResourceManager; +import io.skodjob.testframe.wait.Wait; import io.x_k8s.kueue.v1beta1.ClusterQueue; import io.x_k8s.kueue.v1beta1.ClusterQueueBuilder; import io.x_k8s.kueue.v1beta1.LocalQueue; @@ -62,6 +63,8 @@ import java.util.concurrent.TimeUnit; import java.util.function.Predicate; +import static io.odh.test.TestConstants.GLOBAL_POLL_INTERVAL_1_SEC; +import static io.odh.test.TestConstants.GLOBAL_STABILITY_TIME; import static io.odh.test.TestConstants.GLOBAL_TIMEOUT; @SuiteDoc( @@ -325,11 +328,15 @@ void testDistributedWorkloadWithKueue() throws Exception { .sslContext(TlsUtils.getSSLContextFromSecret(signingKey)) .build(); - Allure.step("Wait for service availability"); + Allure.step("Wait for OpenShift service availability"); TestUtils.waitForServiceNotUnavailable(httpClient, url); + RayClient ray = new RayClient(httpClient, url, oauthToken); + + Allure.step("Wait for Ray API availability"); + Wait.until("Ray API is available", GLOBAL_POLL_INTERVAL_1_SEC, GLOBAL_STABILITY_TIME, ray::isLive); + Allure.step("Run workload through Ray API", () -> { - RayClient ray = new RayClient(httpClient, url, oauthToken); String jobId = ray.submitJob("expr 3 + 4"); ray.waitForJob(jobId); String logs = ray.getJobLogs(jobId);