From a2e08985a6444750b4401402e49005f0cf08fda9 Mon Sep 17 00:00:00 2001 From: "(skovati) Luke" Date: Mon, 9 Sep 2024 09:26:02 -0700 Subject: [PATCH] introspect failed scheduling run reasons --- .../nasa/jpl/aerie/e2e/SchedulingTests.java | 4 ++- .../jpl/aerie/e2e/utils/HasuraRequests.java | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/SchedulingTests.java b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/SchedulingTests.java index 4a08b5ca41..1e1b1894c9 100644 --- a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/SchedulingTests.java +++ b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/SchedulingTests.java @@ -1063,7 +1063,9 @@ void proceduralUploadWorks() throws IOException { */ @Test void executeSchedulingRunWithoutArguments() throws IOException { - assertThrows(AssertionFailedError.class, () -> hasura.awaitScheduling(specId)); + final var resp = hasura.awaitFailingScheduling(specId); + final var message = resp.reason().getString("message"); + assertTrue(message.contains("java.lang.RuntimeException: Record missing key Component[name=quantity")); } /** diff --git a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/HasuraRequests.java b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/HasuraRequests.java index 385dc3327e..0e98a0ef7a 100644 --- a/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/HasuraRequests.java +++ b/e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/utils/HasuraRequests.java @@ -608,6 +608,38 @@ public SchedulingResponse awaitScheduling(int schedulingSpecId, int timeout) thr throw new TimeoutError("Scheduling timed out after " + timeout + " seconds"); } + /** + * Run scheduling on the specified scheduling specification with a timeout of 30 seconds + * Used when the scheduling run is expected to fail. + */ + public SchedulingResponse awaitFailingScheduling(int schedulingSpecId) throws IOException { + return awaitFailingScheduling(schedulingSpecId, 30); + } + + /** + * Run scheduling on the specified scheduling specification + * Used when the scheduling run is expected to fail. + */ + public SchedulingResponse awaitFailingScheduling(int schedulingSpecId, int timeout) throws IOException { + for(int i = 0; i < timeout; ++i){ + final var response = schedule(schedulingSpecId); + switch (response.status()) { + case "pending", "incomplete" -> { + try { + Thread.sleep(1000); // 1s + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + case "complete", "failed" -> { + return response; + } + default -> fail("Scheduling returned bad status " + response.status() + " with reason " +response.reason()); + } + } + throw new TimeoutError("Scheduling timed out after " + timeout + " seconds"); + } + /** * Start and immediately cancel a scheduling run with a timeout of 30 seconds * @param schedulingSpecId the scheduling specification to use