From 2792e598522ea42a0d56686413d1f6af75dffcb1 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Fri, 25 Jun 2021 13:42:37 +1000 Subject: [PATCH] Fix potential race in continuous testing tests --- .../deployment/devmode/tests/TestsProcessor.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/tests/TestsProcessor.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/tests/TestsProcessor.java index 3693f7b9c429e..68b8eb17d414c 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/tests/TestsProcessor.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/tests/TestsProcessor.java @@ -77,12 +77,13 @@ DevConsoleRouteBuildItem handleTestStatus(LaunchModeBuildItem launchModeBuildIte @Override public void handle(RoutingContext event) { jsonResponse(event); - TestSupport.RunStatus status = ts.get().getStatus(); + TestSupport testSupport = ts.get(); + TestSupport.RunStatus status = testSupport.getStatus(); TestStatus testStatus = new TestStatus(); - testStatus.setLastRun(status.getLastRun()); - testStatus.setRunning(status.getRunning()); - if (status.getLastRun() > 0) { - TestRunResults result = ts.get().getResults(); + long lastRun = status.getLastRun(); + testStatus.setLastRun(lastRun); + if (lastRun > 0) { + TestRunResults result = testSupport.getResults(); testStatus.setTestsFailed(result.getCurrentFailedCount()); testStatus.setTestsPassed(result.getCurrentPassedCount()); testStatus.setTestsSkipped(result.getCurrentSkippedCount()); @@ -91,6 +92,9 @@ public void handle(RoutingContext event) { testStatus.setTotalTestsPassed(result.getPassedCount()); testStatus.setTotalTestsSkipped(result.getSkippedCount()); } + //get running last, as otherwise if the test completes in the meantime you could see + //both running and last run being the same number + testStatus.setRunning(status.getRunning()); event.response().end(JsonObject.mapFrom(testStatus).encode()); } });