From 48d582b683d06f0db65cf11736833b09c493854c Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Wed, 1 Sep 2021 08:43:24 +1000 Subject: [PATCH] Don't rely on vert.x for CT tests --- bom/application/pom.xml | 7 - .../ContinuousTestingSharedStateManager.java | 145 ++++++++++++++ .../ContinuousTestingWebsocketListener.java | 108 ---------- .../elytron-security-jdbc/deployment/pom.xml | 6 - .../jdbc/CustomRoleDecoderDevModeTest.java | 4 +- extensions/hibernate-orm/deployment/pom.xml | 6 - .../orm/HibernateHotReloadTestCase.java | 4 +- .../opentelemetry/deployment/pom.xml | 6 - .../OpenTelemetryContinuousTestingTest.java | 4 +- .../deployment/OpenTelemetryDevModeTest.java | 2 +- .../deployment/pom.xml | 6 - ...aDevServicesContinuousTestingTestCase.java | 2 +- ...tinuousTestingWorkingAppPropsTestCase.java | 2 +- extensions/vertx-http/deployment/pom.xml | 11 -- .../ContinuousTestingSharedStateListener.java | 92 +++++++++ ...ontinuousTestingWebSocketTestListener.java | 107 ---------- .../devmode/tests/TestsProcessor.java | 4 +- .../ContinuousTestingTestUtils.java | 53 ----- .../testrunner/QuarkusTestTypeTestCase.java | 3 +- ...tChangeTrackingWhenStartFailsTestCase.java | 3 +- .../TestFailingBeforeAllTestCase.java | 3 +- .../testrunner/TestRunnerSmokeTestCase.java | 3 +- .../http/testrunner/UnitTestTypeTestCase.java | 3 +- .../brokenonly/TestBrokenOnlyTestCase.java | 4 +- .../includes/ExcludePatternTestCase.java | 4 +- .../includes/IncludePatternTestCase.java | 4 +- .../params/TestParameterizedTestCase.java | 4 +- .../testrunner/tags/ExcludeTagsTestCase.java | 4 +- .../testrunner/tags/IncludeTagsTestCase.java | 4 +- .../ContinuousTestWebSocketHandler.java | 8 +- .../runtime/devmode/DevConsoleRecorder.java | 6 +- test-framework/junit5-internal/pom.xml | 4 + .../test/ContinuousTestingTestUtils.java | 185 ++++++++++++++++++ 33 files changed, 466 insertions(+), 345 deletions(-) create mode 100644 core/devmode-spi/src/main/java/io/quarkus/dev/testing/ContinuousTestingSharedStateManager.java delete mode 100644 core/devmode-spi/src/main/java/io/quarkus/dev/testing/ContinuousTestingWebsocketListener.java create mode 100644 extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ContinuousTestingSharedStateListener.java delete mode 100644 extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ContinuousTestingWebSocketTestListener.java delete mode 100644 extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/ContinuousTestingTestUtils.java create mode 100644 test-framework/junit5-internal/src/main/java/io/quarkus/test/ContinuousTestingTestUtils.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index f1c39ced2103be..5cf1616cc82f10 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -1540,13 +1540,6 @@ quarkus-vertx-http-deployment ${project.version} - - io.quarkus - quarkus-vertx-http-deployment - ${project.version} - test-jar - test - io.quarkus quarkus-vertx-web diff --git a/core/devmode-spi/src/main/java/io/quarkus/dev/testing/ContinuousTestingSharedStateManager.java b/core/devmode-spi/src/main/java/io/quarkus/dev/testing/ContinuousTestingSharedStateManager.java new file mode 100644 index 00000000000000..0862167d1d7e06 --- /dev/null +++ b/core/devmode-spi/src/main/java/io/quarkus/dev/testing/ContinuousTestingSharedStateManager.java @@ -0,0 +1,145 @@ +package io.quarkus.dev.testing; + +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.function.Consumer; + +public class ContinuousTestingSharedStateManager { + + private static final CopyOnWriteArraySet> stateListeners = new CopyOnWriteArraySet<>(); + private static volatile State lastState = new State(-1, false, false, 0, 0, 0, 0, 0, 0, 0, false, false, false, true); + + public static void addStateListener(Consumer stateListener) { + stateListeners.add(stateListener); + if (lastState != null) { + stateListener.accept(lastState); + } + } + + public static void removeStateListener(Consumer stateListener) { + stateListeners.remove(stateListener); + } + + public static void setLastState(State state) { + lastState = state; + for (var sl : stateListeners) { + sl.accept(state); + } + } + + public static State getLastState() { + return lastState; + } + + public static void setInProgress(boolean inProgress) { + State state = lastState; + if (state != null) { + setLastState( + new State(state.lastRun, state.running, inProgress, state.run, state.passed, state.failed, state.skipped, + state.currentPassed, state.currentFailed, state.currentSkipped, state.isBrokenOnly, + state.isTestOutput, state.isInstrumentationBasedReload, state.isLiveReload)); + } + } + + public static void setRunning(boolean running) { + State state = lastState; + if (state != null) { + setLastState(new State(state.lastRun, running, running && state.inProgress, state.run, state.passed, state.failed, + state.skipped, + state.currentPassed, state.currentFailed, state.currentSkipped, state.isBrokenOnly, state.isTestOutput, + state.isInstrumentationBasedReload, state.isLiveReload)); + } + } + + public static void setBrokenOnly(boolean brokenOnly) { + State state = lastState; + if (state != null) { + setLastState(new State(state.lastRun, state.running, state.inProgress, state.run, state.passed, state.failed, + state.skipped, + state.currentPassed, state.currentFailed, state.currentSkipped, brokenOnly, state.isTestOutput, + state.isInstrumentationBasedReload, state.isLiveReload)); + } + } + + public static void setTestOutput(boolean testOutput) { + State state = lastState; + if (state != null) { + setLastState(new State(state.lastRun, state.running, state.inProgress, state.run, state.passed, state.failed, + state.skipped, + state.currentPassed, state.currentFailed, state.currentSkipped, state.isBrokenOnly, testOutput, + state.isInstrumentationBasedReload, state.isLiveReload)); + } + } + + public static void setInstrumentationBasedReload(boolean instrumentationBasedReload) { + State state = lastState; + if (state != null) { + setLastState(new State(state.lastRun, state.running, state.inProgress, state.run, state.passed, state.failed, + state.skipped, + state.currentPassed, state.currentFailed, state.currentSkipped, state.isBrokenOnly, state.isTestOutput, + instrumentationBasedReload, state.isLiveReload)); + } + } + + public static void setLiveReloadEnabled(boolean liveReload) { + State state = lastState; + if (state != null) { + setLastState(new State(state.lastRun, state.running, state.inProgress, state.run, state.passed, state.failed, + state.skipped, + state.currentPassed, state.currentFailed, state.currentSkipped, state.isBrokenOnly, state.isTestOutput, + state.isInstrumentationBasedReload, liveReload)); + } + } + + public static class State { + public final long lastRun; + public final boolean running; + public final boolean inProgress; + public final long run; + public final long passed; + public final long failed; + public final long skipped; + public final long currentPassed; + public final long currentFailed; + public final long currentSkipped; + public final boolean isBrokenOnly; + public final boolean isTestOutput; + public final boolean isInstrumentationBasedReload; + public final boolean isLiveReload; + + public State(long lastRun, boolean running, boolean inProgress, long run, long passed, long failed, long skipped, + long currentPassed, long currentFailed, long currentSkipped, boolean isBrokenOnly, boolean isTestOutput, + boolean isInstrumentationBasedReload, boolean isLiveReload) { + this.lastRun = lastRun; + this.running = running; + this.inProgress = inProgress; + this.run = run; + this.passed = passed; + this.failed = failed; + this.skipped = skipped; + this.currentPassed = currentPassed; + this.currentFailed = currentFailed; + this.currentSkipped = currentSkipped; + this.isBrokenOnly = isBrokenOnly; + this.isTestOutput = isTestOutput; + this.isInstrumentationBasedReload = isInstrumentationBasedReload; + this.isLiveReload = isLiveReload; + } + + @Override + public String toString() { + return "State{" + + "lastRun=" + lastRun + + ", running=" + running + + ", inProgress=" + inProgress + + ", run=" + run + + ", passed=" + passed + + ", failed=" + failed + + ", skipped=" + skipped + + ", isBrokenOnly=" + isBrokenOnly + + ", isTestOutput=" + isTestOutput + + ", isInstrumentationBasedReload=" + isInstrumentationBasedReload + + ", isLiveReload=" + isLiveReload + + '}'; + } + } +} diff --git a/core/devmode-spi/src/main/java/io/quarkus/dev/testing/ContinuousTestingWebsocketListener.java b/core/devmode-spi/src/main/java/io/quarkus/dev/testing/ContinuousTestingWebsocketListener.java deleted file mode 100644 index bc272a58a1db5d..00000000000000 --- a/core/devmode-spi/src/main/java/io/quarkus/dev/testing/ContinuousTestingWebsocketListener.java +++ /dev/null @@ -1,108 +0,0 @@ -package io.quarkus.dev.testing; - -import java.util.function.Consumer; - -//TODO: this is pretty horrible -public class ContinuousTestingWebsocketListener { - - private static Consumer stateListener; - private static volatile State lastState = new State(false, false, 0, 0, 0, 0, false, false, false, true); - - public static Consumer getStateListener() { - return stateListener; - } - - public static void setStateListener(Consumer stateListener) { - ContinuousTestingWebsocketListener.stateListener = stateListener; - if (lastState != null && stateListener != null) { - stateListener.accept(lastState); - } - } - - public static void setLastState(State state) { - lastState = state; - Consumer sl = stateListener; - if (sl != null) { - sl.accept(state); - } - } - - public static State getLastState() { - return lastState; - } - - public static void setInProgress(boolean inProgress) { - State state = lastState; - if (state != null) { - setLastState(new State(state.running, inProgress, state.run, state.passed, state.failed, state.skipped, - state.isBrokenOnly, state.isTestOutput, state.isInstrumentationBasedReload, state.isLiveReload)); - } - } - - public static void setRunning(boolean running) { - State state = lastState; - if (state != null) { - setLastState(new State(running, running && state.inProgress, state.run, state.passed, state.failed, state.skipped, - state.isBrokenOnly, state.isTestOutput, state.isInstrumentationBasedReload, state.isLiveReload)); - } - } - - public static void setBrokenOnly(boolean brokenOnly) { - State state = lastState; - if (state != null) { - setLastState(new State(state.running, state.inProgress, state.run, state.passed, state.failed, state.skipped, - brokenOnly, state.isTestOutput, state.isInstrumentationBasedReload, state.isLiveReload)); - } - } - - public static void setTestOutput(boolean testOutput) { - State state = lastState; - if (state != null) { - setLastState(new State(state.running, state.inProgress, state.run, state.passed, state.failed, state.skipped, - state.isBrokenOnly, testOutput, state.isInstrumentationBasedReload, state.isLiveReload)); - } - } - - public static void setInstrumentationBasedReload(boolean instrumentationBasedReload) { - State state = lastState; - if (state != null) { - setLastState(new State(state.running, state.inProgress, state.run, state.passed, state.failed, state.skipped, - state.isBrokenOnly, state.isTestOutput, instrumentationBasedReload, state.isLiveReload)); - } - } - - public static void setLiveReloadEnabled(boolean liveReload) { - State state = lastState; - if (state != null) { - setLastState(new State(state.running, state.inProgress, state.run, state.passed, state.failed, state.skipped, - state.isBrokenOnly, state.isTestOutput, state.isInstrumentationBasedReload, liveReload)); - } - } - - public static class State { - public final boolean running; - public final boolean inProgress; - public final long run; - public final long passed; - public final long failed; - public final long skipped; - public final boolean isBrokenOnly; - public final boolean isTestOutput; - public final boolean isInstrumentationBasedReload; - public final boolean isLiveReload; - - public State(boolean running, boolean inProgress, long run, long passed, long failed, long skipped, - boolean isBrokenOnly, boolean isTestOutput, boolean isInstrumentationBasedReload, boolean isLiveReload) { - this.running = running; - this.inProgress = inProgress; - this.run = run; - this.passed = passed; - this.failed = failed; - this.skipped = skipped; - this.isBrokenOnly = isBrokenOnly; - this.isTestOutput = isTestOutput; - this.isInstrumentationBasedReload = isInstrumentationBasedReload; - this.isLiveReload = isLiveReload; - } - } -} diff --git a/extensions/elytron-security-jdbc/deployment/pom.xml b/extensions/elytron-security-jdbc/deployment/pom.xml index 0e71187e66be69..44c3c8f921931b 100644 --- a/extensions/elytron-security-jdbc/deployment/pom.xml +++ b/extensions/elytron-security-jdbc/deployment/pom.xml @@ -46,12 +46,6 @@ quarkus-resteasy-deployment test - - io.quarkus - quarkus-vertx-http-deployment - test-jar - test - io.quarkus quarkus-junit5-internal diff --git a/extensions/elytron-security-jdbc/deployment/src/test/java/io/quarkus/elytron/security/jdbc/CustomRoleDecoderDevModeTest.java b/extensions/elytron-security-jdbc/deployment/src/test/java/io/quarkus/elytron/security/jdbc/CustomRoleDecoderDevModeTest.java index b55a8c75daf900..772ebd49aeecf4 100644 --- a/extensions/elytron-security-jdbc/deployment/src/test/java/io/quarkus/elytron/security/jdbc/CustomRoleDecoderDevModeTest.java +++ b/extensions/elytron-security-jdbc/deployment/src/test/java/io/quarkus/elytron/security/jdbc/CustomRoleDecoderDevModeTest.java @@ -13,9 +13,9 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.deployment.util.FileUtil; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.restassured.RestAssured; //see https://github.com/quarkusio/quarkus/issues/9296 diff --git a/extensions/hibernate-orm/deployment/pom.xml b/extensions/hibernate-orm/deployment/pom.xml index 75cea02da2efea..f1cd0a90c9730d 100644 --- a/extensions/hibernate-orm/deployment/pom.xml +++ b/extensions/hibernate-orm/deployment/pom.xml @@ -87,12 +87,6 @@ quarkus-smallrye-metrics-deployment test - - io.quarkus - quarkus-vertx-http-deployment - test - test-jar - org.awaitility awaitility diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateHotReloadTestCase.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateHotReloadTestCase.java index 64a86b95bfe2b1..52c1bb4fb2f018 100644 --- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateHotReloadTestCase.java +++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateHotReloadTestCase.java @@ -11,9 +11,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.restassured.RestAssured; public class HibernateHotReloadTestCase { diff --git a/extensions/opentelemetry/opentelemetry/deployment/pom.xml b/extensions/opentelemetry/opentelemetry/deployment/pom.xml index c066a7c1f65030..f124d4a8646183 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/pom.xml +++ b/extensions/opentelemetry/opentelemetry/deployment/pom.xml @@ -69,12 +69,6 @@ quarkus-resteasy-deployment test - - io.quarkus - quarkus-vertx-http-deployment - test - test-jar - io.quarkus quarkus-smallrye-health-deployment diff --git a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryContinuousTestingTest.java b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryContinuousTestingTest.java index 8f213de335f5c3..8345afa9615b9e 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryContinuousTestingTest.java +++ b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryContinuousTestingTest.java @@ -7,9 +7,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; public class OpenTelemetryContinuousTestingTest { @RegisterExtension diff --git a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java index 801673acdb8721..b7dc348682d116 100644 --- a/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java +++ b/extensions/opentelemetry/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/OpenTelemetryDevModeTest.java @@ -8,8 +8,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.restassured.RestAssured; public class OpenTelemetryDevModeTest { diff --git a/extensions/smallrye-reactive-messaging-kafka/deployment/pom.xml b/extensions/smallrye-reactive-messaging-kafka/deployment/pom.xml index bcde6e700bec72..8d8bff7aceca62 100644 --- a/extensions/smallrye-reactive-messaging-kafka/deployment/pom.xml +++ b/extensions/smallrye-reactive-messaging-kafka/deployment/pom.xml @@ -83,12 +83,6 @@ awaitility test - - io.quarkus - quarkus-vertx-http-deployment - test-jar - test - diff --git a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingTestCase.java b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingTestCase.java index e4a232da8146b0..8387a6674986f5 100644 --- a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingTestCase.java +++ b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingTestCase.java @@ -9,8 +9,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; public class KafkaDevServicesContinuousTestingTestCase { diff --git a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingWorkingAppPropsTestCase.java b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingWorkingAppPropsTestCase.java index e4fdcca5abe1a2..57c98b27fdf751 100644 --- a/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingWorkingAppPropsTestCase.java +++ b/extensions/smallrye-reactive-messaging-kafka/deployment/src/test/java/io/quarkus/smallrye/reactivemessaging/kafka/deployment/testing/KafkaDevServicesContinuousTestingWorkingAppPropsTestCase.java @@ -9,8 +9,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; public class KafkaDevServicesContinuousTestingWorkingAppPropsTestCase { diff --git a/extensions/vertx-http/deployment/pom.xml b/extensions/vertx-http/deployment/pom.xml index daa32430e8a055..ed795df314e552 100644 --- a/extensions/vertx-http/deployment/pom.xml +++ b/extensions/vertx-http/deployment/pom.xml @@ -119,17 +119,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - maven-compiler-plugin diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ContinuousTestingSharedStateListener.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ContinuousTestingSharedStateListener.java new file mode 100644 index 00000000000000..4d5fe9235c3ed6 --- /dev/null +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ContinuousTestingSharedStateListener.java @@ -0,0 +1,92 @@ +package io.quarkus.vertx.http.deployment.devmode.console; + +import java.util.function.Consumer; + +import io.quarkus.deployment.dev.testing.TestController; +import io.quarkus.deployment.dev.testing.TestListener; +import io.quarkus.deployment.dev.testing.TestRunListener; +import io.quarkus.deployment.dev.testing.TestRunResults; +import io.quarkus.dev.testing.ContinuousTestingSharedStateManager; + +public class ContinuousTestingSharedStateListener implements TestListener { + + private volatile ContinuousTestingSharedStateManager.State lastState; + + @Override + public void listenerRegistered(TestController testController) { + + } + + @Override + public void testsEnabled() { + if (lastState == null) { + ContinuousTestingSharedStateManager + .setLastState(new ContinuousTestingSharedStateManager.State( + ContinuousTestingSharedStateManager.getLastState().lastRun, true, false, + 0, 0, 0, 0, + 0, 0, 0, ContinuousTestingSharedStateManager.getLastState().isBrokenOnly, + ContinuousTestingSharedStateManager.getLastState().isTestOutput, + ContinuousTestingSharedStateManager.getLastState().isInstrumentationBasedReload, + ContinuousTestingSharedStateManager.getLastState().isLiveReload)); + } else { + ContinuousTestingSharedStateManager + .setLastState(lastState); + } + } + + @Override + public void testsDisabled() { + ContinuousTestingSharedStateManager.setRunning(false); + } + + @Override + public void testRunStarted(Consumer listenerConsumer) { + ContinuousTestingSharedStateManager.setInProgress(true); + listenerConsumer.accept(new TestRunListener() { + + @Override + public void runComplete(TestRunResults testRunResults) { + lastState = new ContinuousTestingSharedStateManager.State(testRunResults.getId(), true, false, + testRunResults.getPassedCount() + + testRunResults.getFailedCount() + + testRunResults.getSkippedCount(), + testRunResults.getPassedCount(), + testRunResults.getFailedCount(), testRunResults.getSkippedCount(), + testRunResults.getCurrentPassedCount(), testRunResults.getCurrentFailedCount(), + testRunResults.getCurrentSkippedCount(), + ContinuousTestingSharedStateManager.getLastState().isBrokenOnly, + ContinuousTestingSharedStateManager.getLastState().isTestOutput, + ContinuousTestingSharedStateManager.getLastState().isInstrumentationBasedReload, + ContinuousTestingSharedStateManager.getLastState().isLiveReload); + ContinuousTestingSharedStateManager.setLastState(lastState); + } + + @Override + public void runAborted() { + ContinuousTestingSharedStateManager.setInProgress(false); + } + }); + + } + + @Override + public void setBrokenOnly(boolean bo) { + ContinuousTestingSharedStateManager.setBrokenOnly(bo); + } + + @Override + public void setTestOutput(boolean to) { + ContinuousTestingSharedStateManager.setTestOutput(to); + } + + @Override + public void setInstrumentationBasedReload(boolean ibr) { + ContinuousTestingSharedStateManager.setInstrumentationBasedReload(ibr); + } + + @Override + public void setLiveReloadEnabled(boolean lre) { + ContinuousTestingSharedStateManager.setLiveReloadEnabled(lre); + } + +} diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ContinuousTestingWebSocketTestListener.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ContinuousTestingWebSocketTestListener.java deleted file mode 100644 index 2d83492a8186b3..00000000000000 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/ContinuousTestingWebSocketTestListener.java +++ /dev/null @@ -1,107 +0,0 @@ -package io.quarkus.vertx.http.deployment.devmode.console; - -import java.util.function.Consumer; - -import org.junit.platform.launcher.TestIdentifier; - -import io.quarkus.deployment.dev.testing.TestController; -import io.quarkus.deployment.dev.testing.TestListener; -import io.quarkus.deployment.dev.testing.TestResult; -import io.quarkus.deployment.dev.testing.TestRunListener; -import io.quarkus.deployment.dev.testing.TestRunResults; -import io.quarkus.dev.testing.ContinuousTestingWebsocketListener; - -public class ContinuousTestingWebSocketTestListener implements TestListener { - - private volatile ContinuousTestingWebsocketListener.State lastState; - - @Override - public void listenerRegistered(TestController testController) { - - } - - @Override - public void testsEnabled() { - if (lastState == null) { - ContinuousTestingWebsocketListener - .setLastState(new ContinuousTestingWebsocketListener.State(true, false, - 0, 0, 0, 0, - ContinuousTestingWebsocketListener.getLastState().isBrokenOnly, - ContinuousTestingWebsocketListener.getLastState().isTestOutput, - ContinuousTestingWebsocketListener.getLastState().isInstrumentationBasedReload, - ContinuousTestingWebsocketListener.getLastState().isLiveReload)); - } else { - ContinuousTestingWebsocketListener - .setLastState(lastState); - } - } - - @Override - public void testsDisabled() { - ContinuousTestingWebsocketListener.setRunning(false); - } - - @Override - public void testRunStarted(Consumer listenerConsumer) { - ContinuousTestingWebsocketListener.setInProgress(true); - listenerConsumer.accept(new TestRunListener() { - @Override - public void runStarted(long toRun) { - - } - - @Override - public void testComplete(TestResult result) { - - } - - @Override - public void runComplete(TestRunResults testRunResults) { - lastState = new ContinuousTestingWebsocketListener.State(true, false, - testRunResults.getPassedCount() + - testRunResults.getFailedCount() + - testRunResults.getSkippedCount(), - testRunResults.getPassedCount(), - testRunResults.getFailedCount(), testRunResults.getSkippedCount(), - ContinuousTestingWebsocketListener.getLastState().isBrokenOnly, - ContinuousTestingWebsocketListener.getLastState().isTestOutput, - ContinuousTestingWebsocketListener.getLastState().isInstrumentationBasedReload, - ContinuousTestingWebsocketListener.getLastState().isLiveReload); - ContinuousTestingWebsocketListener.setLastState( - lastState); - } - - @Override - public void runAborted() { - ContinuousTestingWebsocketListener.setInProgress(false); - } - - @Override - public void testStarted(TestIdentifier testIdentifier, String className) { - - } - }); - - } - - @Override - public void setBrokenOnly(boolean bo) { - ContinuousTestingWebsocketListener.setBrokenOnly(bo); - } - - @Override - public void setTestOutput(boolean to) { - ContinuousTestingWebsocketListener.setTestOutput(to); - } - - @Override - public void setInstrumentationBasedReload(boolean ibr) { - ContinuousTestingWebsocketListener.setInstrumentationBasedReload(ibr); - } - - @Override - public void setLiveReloadEnabled(boolean lre) { - ContinuousTestingWebsocketListener.setLiveReloadEnabled(lre); - } - -} 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 6bc93507d3b807..6730539acd2dbd 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 @@ -23,7 +23,7 @@ import io.quarkus.devconsole.spi.DevConsoleTemplateInfoBuildItem; import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem; import io.quarkus.vertx.http.deployment.RouteBuildItem; -import io.quarkus.vertx.http.deployment.devmode.console.ContinuousTestingWebSocketTestListener; +import io.quarkus.vertx.http.deployment.devmode.console.ContinuousTestingSharedStateListener; import io.quarkus.vertx.http.runtime.devmode.DevConsoleRecorder; import io.quarkus.vertx.http.runtime.devmode.Json; import io.vertx.core.Handler; @@ -61,7 +61,7 @@ public void setupTestRoutes( .route("dev/test") .handler(recorder.continousTestHandler(shutdownContextBuildItem)) .build()); - testListenerBuildItemBuildProducer.produce(new TestListenerBuildItem(new ContinuousTestingWebSocketTestListener())); + testListenerBuildItemBuildProducer.produce(new TestListenerBuildItem(new ContinuousTestingSharedStateListener())); } } diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/ContinuousTestingTestUtils.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/ContinuousTestingTestUtils.java deleted file mode 100644 index 5ae3209c3dfff3..00000000000000 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/ContinuousTestingTestUtils.java +++ /dev/null @@ -1,53 +0,0 @@ -package io.quarkus.vertx.http.testrunner; - -import java.util.Arrays; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; - -import org.awaitility.Awaitility; -import org.awaitility.core.ConditionTimeoutException; - -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; -import io.restassured.RestAssured; - -/** - * Utilities for testing the test runner itself - */ -public class ContinuousTestingTestUtils { - - long runtToWaitFor = 1; - - public TestStatus waitForNextCompletion() { - try { - Awaitility.waitAtMost(1, TimeUnit.MINUTES).pollInterval(50, TimeUnit.MILLISECONDS).until(new Callable() { - @Override - public Boolean call() throws Exception { - TestStatus ts = RestAssured.get("q/dev/io.quarkus.quarkus-vertx-http/tests/status").as(TestStatus.class); - if (ts.getLastRun() > runtToWaitFor) { - throw new RuntimeException( - "Waiting for run " + runtToWaitFor + " but run " + ts.getLastRun() + " has already occurred"); - } - boolean runComplete = ts.getLastRun() == runtToWaitFor; - if (runComplete && ts.getRunning() > 0) { - //there is a small chance of a race, where changes are picked up twice, due to how filesystems work - //this works around it by waiting for the next run - runtToWaitFor = ts.getRunning(); - return false; - } else if (runComplete) { - runtToWaitFor++; - } - return runComplete; - } - }); - } catch (Exception e) { - TestStatus ts = RestAssured.get("q/dev/io.quarkus.quarkus-vertx-http/tests/status").as(TestStatus.class); - throw new ConditionTimeoutException("Failed to wait for test run" + runtToWaitFor + " " + ts); - } - return RestAssured.get("q/dev/io.quarkus.quarkus-vertx-http/tests/status").as(TestStatus.class); - } - - public static String appProperties(String... props) { - return "quarkus.test.continuous-testing=enabled\nquarkus.test.display-test-output=true\nquarkus.test.basic-console=true\nquarkus.test.disable-console-input=true\n" - + String.join("\n", Arrays.asList(props)); - } -} diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/QuarkusTestTypeTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/QuarkusTestTypeTestCase.java index 344e0412ba79be..b1fe0916dc5853 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/QuarkusTestTypeTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/QuarkusTestTypeTestCase.java @@ -9,8 +9,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; public class QuarkusTestTypeTestCase { diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestChangeTrackingWhenStartFailsTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestChangeTrackingWhenStartFailsTestCase.java index fd7735b789b0bc..bb9228f8a6c948 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestChangeTrackingWhenStartFailsTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestChangeTrackingWhenStartFailsTestCase.java @@ -10,8 +10,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; public class TestChangeTrackingWhenStartFailsTestCase { diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestFailingBeforeAllTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestFailingBeforeAllTestCase.java index f5c74a428b92a4..ce3e1e9f0423b9 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestFailingBeforeAllTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestFailingBeforeAllTestCase.java @@ -9,8 +9,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; public class TestFailingBeforeAllTestCase { diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java index 423c9fe8fceb09..f09ec12148800a 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/TestRunnerSmokeTestCase.java @@ -10,10 +10,11 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; import io.quarkus.vertx.http.deployment.devmode.tests.ClassResult; import io.quarkus.vertx.http.deployment.devmode.tests.SuiteResult; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; import io.restassured.RestAssured; public class TestRunnerSmokeTestCase { diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitTestTypeTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitTestTypeTestCase.java index bf2d3946d51f7e..db944cd60ccaae 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitTestTypeTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/UnitTestTypeTestCase.java @@ -9,8 +9,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; public class UnitTestTypeTestCase { diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/brokenonly/TestBrokenOnlyTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/brokenonly/TestBrokenOnlyTestCase.java index e6e48c30f25440..411a751b0a6e6b 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/brokenonly/TestBrokenOnlyTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/brokenonly/TestBrokenOnlyTestCase.java @@ -10,9 +10,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.restassured.RestAssured; public class TestBrokenOnlyTestCase { diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/ExcludePatternTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/ExcludePatternTestCase.java index cb9aa737d133e3..aa5b9f6d033286 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/ExcludePatternTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/ExcludePatternTestCase.java @@ -10,9 +10,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.quarkus.vertx.http.testrunner.HelloResource; public class ExcludePatternTestCase { diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/IncludePatternTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/IncludePatternTestCase.java index 715800e8597a8b..69bcf14d1e857c 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/IncludePatternTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/includes/IncludePatternTestCase.java @@ -10,9 +10,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.quarkus.vertx.http.testrunner.HelloResource; public class IncludePatternTestCase { diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/TestParameterizedTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/TestParameterizedTestCase.java index f90ef041fdbd47..57c14bc6694f16 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/TestParameterizedTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/params/TestParameterizedTestCase.java @@ -10,9 +10,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; public class TestParameterizedTestCase { diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/ExcludeTagsTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/ExcludeTagsTestCase.java index b263e5890688f1..f3bdea49bd1ae1 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/ExcludeTagsTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/ExcludeTagsTestCase.java @@ -10,9 +10,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.quarkus.vertx.http.testrunner.HelloResource; public class ExcludeTagsTestCase { diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/IncludeTagsTestCase.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/IncludeTagsTestCase.java index 15b12b553e4968..8d136c596def60 100644 --- a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/IncludeTagsTestCase.java +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/testrunner/tags/IncludeTagsTestCase.java @@ -10,9 +10,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import io.quarkus.test.ContinuousTestingTestUtils; +import io.quarkus.test.ContinuousTestingTestUtils.TestStatus; import io.quarkus.test.QuarkusDevModeTest; -import io.quarkus.vertx.http.deployment.devmode.tests.TestStatus; -import io.quarkus.vertx.http.testrunner.ContinuousTestingTestUtils; import io.quarkus.vertx.http.testrunner.HelloResource; public class IncludeTagsTestCase { diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/ContinuousTestWebSocketHandler.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/ContinuousTestWebSocketHandler.java index 683ddf8eafc937..34f37b59bf3f65 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/ContinuousTestWebSocketHandler.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/ContinuousTestWebSocketHandler.java @@ -8,21 +8,21 @@ import org.jboss.logging.Logger; import io.netty.handler.codec.http.HttpHeaderNames; -import io.quarkus.dev.testing.ContinuousTestingWebsocketListener; +import io.quarkus.dev.testing.ContinuousTestingSharedStateManager; import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.http.ServerWebSocket; import io.vertx.ext.web.RoutingContext; public class ContinuousTestWebSocketHandler - implements Handler, Consumer { + implements Handler, Consumer { - private static final Logger log = Logger.getLogger(ContinuousTestingWebsocketListener.class); + private static final Logger log = Logger.getLogger(ContinuousTestingSharedStateManager.class); private static final Set sockets = Collections.newSetFromMap(new ConcurrentHashMap<>()); private static volatile String lastMessage; @Override - public void accept(ContinuousTestingWebsocketListener.State state) { + public void accept(ContinuousTestingSharedStateManager.State state) { Json.JsonObjectBuilder response = Json.object(); response.put("running", state.running); response.put("inProgress", state.inProgress); diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/DevConsoleRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/DevConsoleRecorder.java index ec5126f6b59098..6dc1907b511479 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/DevConsoleRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/devmode/DevConsoleRecorder.java @@ -15,7 +15,7 @@ import org.jboss.logging.Logger; import io.quarkus.dev.console.DevConsoleManager; -import io.quarkus.dev.testing.ContinuousTestingWebsocketListener; +import io.quarkus.dev.testing.ContinuousTestingSharedStateManager; import io.quarkus.runtime.ShutdownContext; import io.quarkus.runtime.annotations.Recorder; import io.vertx.core.Handler; @@ -48,11 +48,11 @@ public Handler devConsoleHandler(String devConsoleFinalDestinati public Handler continousTestHandler(ShutdownContext context) { ContinuousTestWebSocketHandler handler = new ContinuousTestWebSocketHandler(); - ContinuousTestingWebsocketListener.setStateListener(handler); + ContinuousTestingSharedStateManager.addStateListener(handler); context.addShutdownTask(new Runnable() { @Override public void run() { - ContinuousTestingWebsocketListener.setStateListener(null); + ContinuousTestingSharedStateManager.removeStateListener(handler); } }); diff --git a/test-framework/junit5-internal/pom.xml b/test-framework/junit5-internal/pom.xml index 85c157b718a990..5e3194031627f8 100644 --- a/test-framework/junit5-internal/pom.xml +++ b/test-framework/junit5-internal/pom.xml @@ -55,6 +55,10 @@ io.quarkus quarkus-devtools-utilities + + org.awaitility + awaitility + diff --git a/test-framework/junit5-internal/src/main/java/io/quarkus/test/ContinuousTestingTestUtils.java b/test-framework/junit5-internal/src/main/java/io/quarkus/test/ContinuousTestingTestUtils.java new file mode 100644 index 00000000000000..75ff7f654fa3fa --- /dev/null +++ b/test-framework/junit5-internal/src/main/java/io/quarkus/test/ContinuousTestingTestUtils.java @@ -0,0 +1,185 @@ +package io.quarkus.test; + +import java.util.Arrays; +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; + +import org.awaitility.Awaitility; +import org.awaitility.core.ConditionTimeoutException; + +import io.quarkus.dev.testing.ContinuousTestingSharedStateManager; + +/** + * Utilities for testing the test runner itself + */ +public class ContinuousTestingTestUtils { + + long runtToWaitFor = 1; + + public TestStatus waitForNextCompletion() { + try { + Awaitility.waitAtMost(1, TimeUnit.MINUTES).pollInterval(50, TimeUnit.MILLISECONDS).until(new Callable() { + @Override + public Boolean call() throws Exception { + ContinuousTestingSharedStateManager.State ts = ContinuousTestingSharedStateManager.getLastState(); + if (ts.lastRun > runtToWaitFor) { + throw new RuntimeException( + "Waiting for run " + runtToWaitFor + " but run " + ts.lastRun + " has already occurred"); + } + boolean runComplete = ts.lastRun == runtToWaitFor; + if (runComplete && ts.lastRun > 0) { + //there is a small chance of a race, where changes are picked up twice, due to how filesystems work + //this works around it by waiting for the next run + runtToWaitFor = ts.lastRun; + return false; + } else if (runComplete) { + runtToWaitFor++; + } + return runComplete; + } + }); + } catch (Exception e) { + ContinuousTestingSharedStateManager.State ts = ContinuousTestingSharedStateManager.getLastState(); + throw new ConditionTimeoutException("Failed to wait for test run" + runtToWaitFor + " " + ts); + } + var s = ContinuousTestingSharedStateManager.getLastState(); + return new TestStatus(s.lastRun, s.running ? s.lastRun + 1 : -1, s.run, s.currentPassed, s.currentFailed, + s.currentSkipped, s.passed, s.failed, s.skipped); + } + + public static String appProperties(String... props) { + return "quarkus.test.continuous-testing=enabled\nquarkus.test.display-test-output=true\nquarkus.test.basic-console=true\nquarkus.test.disable-console-input=true\n" + + String.join("\n", Arrays.asList(props)); + } + + public static class TestStatus { + + private long lastRun; + + private long running; + + private long testsRun = -1; + + private long testsPassed = -1; + + private long testsFailed = -1; + + private long testsSkipped = -1; + + private long totalTestsPassed = -1; + + private long totalTestsFailed = -1; + + private long totalTestsSkipped = -1; + + public TestStatus() { + } + + public TestStatus(long lastRun, long running, long testsRun, long testsPassed, long testsFailed, long testsSkipped, + long totalTestsPassed, long totalTestsFailed, long totalTestsSkipped) { + this.lastRun = lastRun; + this.running = running; + this.testsRun = testsRun; + this.testsPassed = testsPassed; + this.testsFailed = testsFailed; + this.testsSkipped = testsSkipped; + this.totalTestsPassed = totalTestsPassed; + this.totalTestsFailed = totalTestsFailed; + this.totalTestsSkipped = totalTestsSkipped; + + } + + public long getLastRun() { + return lastRun; + } + + public TestStatus setLastRun(long lastRun) { + this.lastRun = lastRun; + return this; + } + + public long getRunning() { + return running; + } + + public TestStatus setRunning(long running) { + this.running = running; + return this; + } + + public long getTestsRun() { + return testsRun; + } + + public TestStatus setTestsRun(long testsRun) { + this.testsRun = testsRun; + return this; + } + + public long getTestsPassed() { + return testsPassed; + } + + public TestStatus setTestsPassed(long testsPassed) { + this.testsPassed = testsPassed; + return this; + } + + public long getTestsFailed() { + return testsFailed; + } + + public TestStatus setTestsFailed(long testsFailed) { + this.testsFailed = testsFailed; + return this; + } + + public long getTestsSkipped() { + return testsSkipped; + } + + public TestStatus setTestsSkipped(long testsSkipped) { + this.testsSkipped = testsSkipped; + return this; + } + + public long getTotalTestsPassed() { + return totalTestsPassed; + } + + public TestStatus setTotalTestsPassed(long totalTestsPassed) { + this.totalTestsPassed = totalTestsPassed; + return this; + } + + public long getTotalTestsFailed() { + return totalTestsFailed; + } + + public TestStatus setTotalTestsFailed(long totalTestsFailed) { + this.totalTestsFailed = totalTestsFailed; + return this; + } + + public long getTotalTestsSkipped() { + return totalTestsSkipped; + } + + public TestStatus setTotalTestsSkipped(long totalTestsSkipped) { + this.totalTestsSkipped = totalTestsSkipped; + return this; + } + + @Override + public String toString() { + return "TestStatus{" + + "lastRun=" + lastRun + + ", running=" + running + + ", testsRun=" + testsRun + + ", testsPassed=" + testsPassed + + ", testsFailed=" + testsFailed + + ", testsSkipped=" + testsSkipped + + '}'; + } + } +}