From b0d7435e8192fa20c30c7552ae489e8aa5190855 Mon Sep 17 00:00:00 2001 From: Jose Carvajal Date: Wed, 14 Jul 2021 13:17:56 +0200 Subject: [PATCH] Improve Native coverage for several modules (#238) From https://github.com/quarkusio/quarkus/pull/13154, the `@TestProfile` annotation supports Native tests, therefore the modules 001, 301 and 303 can be extended for Native test coverage. As part of this work, we have supported also the test resources for Native: https://github.com/quarkusio/quarkus/pull/18077 And also, I've removed the workaround for https://github.com/quarkusio/quarkus/issues/16810 that had been fixed a while ago. Moreover, for 301: - We've fixed the native failures and got rid of the application.properties file in the test resources. This can be closed now: https://github.com/quarkusio/quarkus/issues/17829. - Reduce the number of traces to ease the troubleshot of failures. And for 303: - Refactored the test resources to not rely on system properties to load/unload application properties. --- .../qe/core/AsciiMultipartResourceTest.java | 2 - .../core/NativeAsciiMultipartResourceIT.java | 8 +++ .../webclient/ChuckNorrisResourceIT.java | 3 +- .../kafka/consumer/KStockPriceConsumer.java | 8 +-- .../kafka/producers/StockPriceProducer.java | 6 +- .../src/main/resources/application.properties | 8 +-- .../quarkus/qe/kafka/ConfluentKafkaTest.java | 4 +- .../io/quarkus/qe/kafka/KafkaCommonTest.java | 21 +++--- .../qe/kafka/NativeConfluentKafkaIT.java | 12 ++++ .../qe/kafka/NativeStrimziKafkaIT.java | 12 ++++ .../io/quarkus/qe/kafka/StrimziKafkaIT.java | 22 ------- .../io/quarkus/qe/kafka/StrimziKafkaTest.java | 2 +- .../qe/kafka/resources/JaegerContainer.java | 2 +- .../kafka/resources/JaegerTestResource.java | 4 +- .../src/test/resources/application.properties | 65 ------------------- .../sql/handlers/NativeDb2HandlerIT.java | 7 ++ .../sql/handlers/NativeMysqlHandlerIT.java | 7 ++ .../handlers/NativePostgresqlHandlerIT.java | 7 ++ .../sql/handlers/PostgresqlHandlerIT.java | 10 --- .../vertx/sql/test/resources/Db2Resource.java | 19 ++---- .../sql/test/resources/MysqlResource.java | 19 ++---- .../sql/test/resources/MysqlTestProfile.java | 2 +- .../test/resources/PostgresqlResource.java | 20 ++---- 23 files changed, 103 insertions(+), 167 deletions(-) create mode 100644 001-quarkus-getting-started-with-jaxrs/src/test/java/io/quarkus/qe/core/NativeAsciiMultipartResourceIT.java create mode 100644 301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/NativeConfluentKafkaIT.java create mode 100644 301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/NativeStrimziKafkaIT.java delete mode 100644 301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/StrimziKafkaIT.java delete mode 100644 301-quarkus-vertx-kafka/src/test/resources/application.properties create mode 100644 303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativeDb2HandlerIT.java create mode 100644 303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativeMysqlHandlerIT.java create mode 100644 303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativePostgresqlHandlerIT.java delete mode 100644 303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/PostgresqlHandlerIT.java diff --git a/001-quarkus-getting-started-with-jaxrs/src/test/java/io/quarkus/qe/core/AsciiMultipartResourceTest.java b/001-quarkus-getting-started-with-jaxrs/src/test/java/io/quarkus/qe/core/AsciiMultipartResourceTest.java index 42ecdebe..334814bf 100644 --- a/001-quarkus-getting-started-with-jaxrs/src/test/java/io/quarkus/qe/core/AsciiMultipartResourceTest.java +++ b/001-quarkus-getting-started-with-jaxrs/src/test/java/io/quarkus/qe/core/AsciiMultipartResourceTest.java @@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test; -import io.quarkus.test.junit.DisabledOnNativeImage; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; @@ -17,7 +16,6 @@ import io.restassured.specification.MultiPartSpecification; @QuarkusTest -@DisabledOnNativeImage // @TestProfile works in JVM mode @TestProfile(AsciiMultipartResourceTest.AsciiTestProfile.class) public class AsciiMultipartResourceTest { diff --git a/001-quarkus-getting-started-with-jaxrs/src/test/java/io/quarkus/qe/core/NativeAsciiMultipartResourceIT.java b/001-quarkus-getting-started-with-jaxrs/src/test/java/io/quarkus/qe/core/NativeAsciiMultipartResourceIT.java new file mode 100644 index 00000000..0659b72a --- /dev/null +++ b/001-quarkus-getting-started-with-jaxrs/src/test/java/io/quarkus/qe/core/NativeAsciiMultipartResourceIT.java @@ -0,0 +1,8 @@ +package io.quarkus.qe.core; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class NativeAsciiMultipartResourceIT extends AsciiMultipartResourceTest { + +} diff --git a/300-quarkus-vertx-webClient/src/test/java/io/quarkus/qe/vertx/webclient/ChuckNorrisResourceIT.java b/300-quarkus-vertx-webClient/src/test/java/io/quarkus/qe/vertx/webclient/ChuckNorrisResourceIT.java index bf99e1a2..bd703546 100644 --- a/300-quarkus-vertx-webClient/src/test/java/io/quarkus/qe/vertx/webclient/ChuckNorrisResourceIT.java +++ b/300-quarkus-vertx-webClient/src/test/java/io/quarkus/qe/vertx/webclient/ChuckNorrisResourceIT.java @@ -3,7 +3,6 @@ import static org.junit.Assert.assertTrue; import java.io.File; -import java.net.MalformedURLException; import java.nio.file.Paths; import org.junit.jupiter.api.Test; @@ -16,7 +15,7 @@ public class ChuckNorrisResourceIT extends ChuckNorrisResourceTest { private static final String DEBUG_SYMBOLS_FILE_NAME = "300-quarkus-vertx-webclient-1.0.0-SNAPSHOT-runner.debug"; @Test - public void checkNativeDebugSymbols() throws MalformedURLException { + public void checkNativeDebugSymbols() { File debugFile = Paths.get("target", DEBUG_SYMBOLS_FILE_NAME).toFile(); assertTrue("Missing debug symbols file: " + DEBUG_SYMBOLS_FILE_NAME, debugFile.exists()); } diff --git a/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/consumer/KStockPriceConsumer.java b/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/consumer/KStockPriceConsumer.java index b39f3c88..e2cf9e7d 100644 --- a/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/consumer/KStockPriceConsumer.java +++ b/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/consumer/KStockPriceConsumer.java @@ -41,15 +41,15 @@ public Uni asyncStart() { @Broadcast public String process(StockPrice next) { next.setStatus(status.COMPLETED); - LOG.infov("CONSUMER -> ID: {0}, PRICE: {1}", next.getId(), next.getPrice()); - emitter.send(next).whenComplete(handlerEmitterResponse(KStockPriceConsumer.class.getName())); + LOG.debugv("CONSUMER -> ID: {0}, PRICE: {1}", next.getId(), next.getPrice()); + emitter.send(next).whenComplete(handlerEmitterResponse()); return next.getId() + "-" + next.getPrice() + "-" + next.getStatus(); } - private BiConsumer handlerEmitterResponse(final String owner) { + private BiConsumer handlerEmitterResponse() { return (success, failure) -> { if (failure != null) { - LOG.info(String.format("D'oh! %s", failure.getMessage())); + LOG.debugv("D'oh! {0}", failure.getMessage()); } }; } diff --git a/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/producers/StockPriceProducer.java b/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/producers/StockPriceProducer.java index c2f2dff2..c2c599cd 100644 --- a/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/producers/StockPriceProducer.java +++ b/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/producers/StockPriceProducer.java @@ -36,7 +36,7 @@ public Uni generate() { IntStream.range(0, config.batchSize()).forEach(next -> { StockPrice event = StockPrice.newBuilder().setId("IBM").setPrice(random.nextDouble()).setStatus(status.PENDING) .build(); - LOG.infov("PRODUCER -> ID: {0}, PRICE: {1}", event.getId(), event.getPrice()); + LOG.debugv("PRODUCER -> ID: {0}, PRICE: {1}", event.getId(), event.getPrice()); emitter.send(event).whenComplete(handlerEmitterResponse(StockPriceProducer.class.getName())); }); @@ -46,9 +46,9 @@ public Uni generate() { private BiConsumer handlerEmitterResponse(final String owner) { return (success, failure) -> { if (failure != null) { - LOG.info(String.format("D'oh! %s", failure.getMessage())); + LOG.debugv("D'oh! {0}", failure.getMessage()); } else { - LOG.info(String.format("Message sent successfully. Owner %s", owner)); + LOG.debugv("Message sent successfully. Owner {0}", owner); } }; } diff --git a/301-quarkus-vertx-kafka/src/main/resources/application.properties b/301-quarkus-vertx-kafka/src/main/resources/application.properties index 48e3536c..39e542d9 100644 --- a/301-quarkus-vertx-kafka/src/main/resources/application.properties +++ b/301-quarkus-vertx-kafka/src/main/resources/application.properties @@ -1,8 +1,4 @@ -quarkus.test.native-image-profile=test -# TODO https://github.com/quarkusio/quarkus/issues/16810 -quarkus.test.flat-class-path=true # Configuration file - Quarkus profile: Strimzi [Default] - kafka.bootstrap.servers=localhost:9092 # Kafka AVRO scenario @@ -33,12 +29,14 @@ mp.messaging.outgoing.sink-stock-price.apicurio.registry.artifact-id=io.apicurio mp.messaging.outgoing.sink-stock-price.apicurio.registry.global-id=io.apicurio.registry.utils.serde.strategy.GetOrCreateIdStrategy mp.messaging.outgoing.sink-stock-price.apicurio.registry.avro-datum-provider=io.apicurio.registry.utils.serde.avro.ReflectAvroDatumProvider +# Jaeger +quarkus.opentelemetry.tracer.exporter.jaeger.endpoint=http://localhost:14250/api/traces # Configuration file - Quarkus profile: Confluent %confluent.kafka.bootstrap.servers=localhost:9092 -%confluent.vertx.kafka.producer.delay-ms=5 +%confluent.vertx.kafka.producer.delay-ms=100 %confluent.vertx.kafka.producer.batch-size=1 %confluent.mp.messaging.outgoing.source-stock-price.connector=smallrye-kafka diff --git a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/ConfluentKafkaTest.java b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/ConfluentKafkaTest.java index 40c4d4c3..6b50227b 100644 --- a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/ConfluentKafkaTest.java +++ b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/ConfluentKafkaTest.java @@ -3,16 +3,14 @@ import io.quarkus.qe.kafka.resources.ConfluentTestProfile; import io.quarkus.qe.kafka.resources.JaegerTestResource; import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.DisabledOnNativeImage; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @QuarkusTest @TestProfile(ConfluentTestProfile.class) @QuarkusTestResource(JaegerTestResource.class) -@DisabledOnNativeImage public class ConfluentKafkaTest extends KafkaCommonTest { - private static final String STOCK_MONITOR_SSE_ENDPOINT = "http://localhost:8083/stock/stream"; + private static final String STOCK_MONITOR_SSE_ENDPOINT = "http://localhost:8081/stock/stream"; @Override protected String getServerSentEventURL() { diff --git a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/KafkaCommonTest.java b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/KafkaCommonTest.java index b544193e..26d66dc8 100644 --- a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/KafkaCommonTest.java +++ b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/KafkaCommonTest.java @@ -27,10 +27,7 @@ import io.restassured.response.Response; abstract class KafkaCommonTest { - private final static String jaegerEndpoint = "http://localhost:16686/api/traces"; - static final String NATIVE = "native"; - static final String QUARKUS_PROFILE = "quarkus.profile"; - static final boolean IS_NATIVE = System.getProperty(QUARKUS_PROFILE, "").equals(NATIVE); + private final static String JAEGER_ENDPOINT = "http://localhost:16686/api/traces"; private Response resp; @@ -46,7 +43,7 @@ public void kafkaProducerShouldTrace() { final int pageLimit = 50; final String expectedOperationName = "stock-price send"; await().atMost(1, TimeUnit.MINUTES).pollInterval(Duration.ofSeconds(1)).untilAsserted(() -> { - thenRetrieveTraces(pageLimit, "1h", getServiceName(), expectedOperationName); + thenRetrieveTraces(pageLimit, "1h", expectedOperationName); thenStatusCodeMustBe(HttpStatus.SC_OK); thenTraceDataSizeMustBe(greaterThan(0)); thenTraceSpanSizeMustBe(greaterThan(0)); @@ -62,7 +59,7 @@ public void kafkaConsumerShouldTrace() throws InterruptedException { final int pageLimit = 50; final String expectedOperationName = "stock-price receive"; await().atMost(1, TimeUnit.MINUTES).pollInterval(Duration.ofSeconds(1)).untilAsserted(() -> { - thenRetrieveTraces(pageLimit, "1h", getServiceName(), expectedOperationName); + thenRetrieveTraces(pageLimit, "1h", expectedOperationName); thenStatusCodeMustBe(HttpStatus.SC_OK); thenTraceDataSizeMustBe(greaterThan(0)); thenTraceSpanSizeMustBe(greaterThan(0)); @@ -72,13 +69,13 @@ public void kafkaConsumerShouldTrace() throws InterruptedException { }); } - private void thenRetrieveTraces(int pageLimit, String lookBack, String serviceName, String operationName) { + private void thenRetrieveTraces(int pageLimit, String lookBack, String operationName) { resp = given().when() .queryParam("limit", pageLimit) .queryParam("lookback", lookBack) - .queryParam("service", serviceName) + .queryParam("service", getServiceName()) .queryParam("operation", operationName) - .get(jaegerEndpoint); + .get(JAEGER_ENDPOINT); } private void thenStatusCodeMustBe(int expectedStatusCode) { @@ -108,7 +105,7 @@ private void thenCheckThatAllOperationNamesAreEqualTo(String expectedOperationNa private String getServiceName() { // TODO https://github.com/quarkusio/quarkus/issues/16499 - return (IS_NATIVE) ? "301-quarkus-vertx-kafka" : "<>"; + return isNativeTest() ? "301-quarkus-vertx-kafka" : "<>"; } private void sendAndReceiveEvents(int timeoutMin, int expectedEventsAmount) throws InterruptedException { @@ -125,5 +122,9 @@ private void sendAndReceiveEvents(int timeoutMin, int expectedEventsAmount) thro source.close(); } + protected boolean isNativeTest() { + return false; + } + protected abstract String getServerSentEventURL(); } diff --git a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/NativeConfluentKafkaIT.java b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/NativeConfluentKafkaIT.java new file mode 100644 index 00000000..6557e10d --- /dev/null +++ b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/NativeConfluentKafkaIT.java @@ -0,0 +1,12 @@ +package io.quarkus.qe.kafka; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class NativeConfluentKafkaIT extends ConfluentKafkaTest { + + @Override + protected boolean isNativeTest() { + return true; + } +} diff --git a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/NativeStrimziKafkaIT.java b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/NativeStrimziKafkaIT.java new file mode 100644 index 00000000..8808852c --- /dev/null +++ b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/NativeStrimziKafkaIT.java @@ -0,0 +1,12 @@ +package io.quarkus.qe.kafka; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class NativeStrimziKafkaIT extends StrimziKafkaTest { + + @Override + protected boolean isNativeTest() { + return true; + } +} diff --git a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/StrimziKafkaIT.java b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/StrimziKafkaIT.java deleted file mode 100644 index 7e0452ac..00000000 --- a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/StrimziKafkaIT.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.quarkus.qe.kafka; - -import org.junit.jupiter.api.Disabled; - -import io.quarkus.qe.kafka.resources.JaegerTestResource; -import io.quarkus.qe.kafka.resources.StrimziKafkaResource; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.NativeImageTest; - -@Disabled(value = "Kafka failing when using Apicurio registry on Native: https://github.com/quarkusio/quarkus/issues/17829") -@NativeImageTest -@QuarkusTestResource(StrimziKafkaResource.class) -@QuarkusTestResource(JaegerTestResource.class) -public class StrimziKafkaIT extends KafkaCommonTest { - - private static final String STOCK_MONITOR_SSE_ENDPOINT = "http://localhost:8083/stock/stream"; - - @Override - protected String getServerSentEventURL() { - return STOCK_MONITOR_SSE_ENDPOINT; - } -} diff --git a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/StrimziKafkaTest.java b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/StrimziKafkaTest.java index 9b2a94b8..500b099d 100644 --- a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/StrimziKafkaTest.java +++ b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/StrimziKafkaTest.java @@ -11,7 +11,7 @@ @QuarkusTestResource(JaegerTestResource.class) public class StrimziKafkaTest extends KafkaCommonTest { - private static final String STOCK_MONITOR_SSE_ENDPOINT = "http://localhost:8083/stock/stream"; + private static final String STOCK_MONITOR_SSE_ENDPOINT = "http://localhost:8081/stock/stream"; @Override protected String getServerSentEventURL() { diff --git a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/resources/JaegerContainer.java b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/resources/JaegerContainer.java index 8392f943..76c0b5bf 100644 --- a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/resources/JaegerContainer.java +++ b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/resources/JaegerContainer.java @@ -5,7 +5,7 @@ public class JaegerContainer extends GenericContainer { public static final int REST_PORT = 16686; - private static final int TRACE_PORT = 14250; + public static final int TRACE_PORT = 14250; public JaegerContainer() { super("jaegertracing/all-in-one:latest"); diff --git a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/resources/JaegerTestResource.java b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/resources/JaegerTestResource.java index d578db8e..fec69461 100644 --- a/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/resources/JaegerTestResource.java +++ b/301-quarkus-vertx-kafka/src/test/java/io/quarkus/qe/kafka/resources/JaegerTestResource.java @@ -17,7 +17,9 @@ public Map start() { container = new JaegerContainer(); container.start(); - return Collections.emptyMap(); + return Collections.singletonMap( + "quarkus.opentelemetry.tracer.exporter.jaeger.endpoint", + String.format("http://%s:%s/api/traces", container.getContainerIpAddress(), JaegerContainer.TRACE_PORT)); } @Override diff --git a/301-quarkus-vertx-kafka/src/test/resources/application.properties b/301-quarkus-vertx-kafka/src/test/resources/application.properties deleted file mode 100644 index c317d692..00000000 --- a/301-quarkus-vertx-kafka/src/test/resources/application.properties +++ /dev/null @@ -1,65 +0,0 @@ -quarkus.test.native-image-profile=test -quarkus.http.test-port=8083 - -# TODO https://github.com/quarkusio/quarkus/issues/16810 -quarkus.test.flat-class-path=true - -## Configuration file - Quarkus profile: Strimzi [Default] -# Kafka AVRO scenario - -kafka.bootstrap.servers=localhost:9092 -mp.messaging.connector.smallrye-kafka.apicurio.registry.url=http://localhost:8081/api - -vertx.kafka.producer.delay-ms=100 -vertx.kafka.producer.batch-size=1 - -mp.messaging.outgoing.source-stock-price.connector=smallrye-kafka -mp.messaging.outgoing.source-stock-price.topic=stock-price -mp.messaging.outgoing.source-stock-price.value.serializer=io.apicurio.registry.utils.serde.AvroKafkaSerializer -mp.messaging.outgoing.source-stock-price.apicurio.registry.artifact-id=io.apicurio.registry.utils.serde.strategy.SimpleTopicIdStrategy -mp.messaging.outgoing.source-stock-price.apicurio.registry.global-id=io.apicurio.registry.utils.serde.strategy.GetOrCreateIdStrategy -mp.messaging.outgoing.source-stock-price.apicurio.registry.avro-datum-provider=io.apicurio.registry.utils.serde.avro.ReflectAvroDatumProvider - -mp.messaging.incoming.channel-stock-price.connector=smallrye-kafka -mp.messaging.incoming.channel-stock-price.specific.avro.reader=true -mp.messaging.incoming.channel-stock-price.topic=stock-price -mp.messaging.incoming.channel-stock-price.value.deserializer=io.apicurio.registry.utils.serde.AvroKafkaDeserializer -mp.messaging.incoming.channel-stock-price.auto.offset.reset=earliest -mp.messaging.incoming.channel-stock-price.enable.auto.commit=true -mp.messaging.incoming.channel-stock-price.apicurio.registry.avro-datum-provider=io.apicurio.registry.utils.serde.avro.ReflectAvroDatumProvider - -mp.messaging.outgoing.sink-stock-price.connector=smallrye-kafka -mp.messaging.outgoing.sink-stock-price.topic=end-stock-price -mp.messaging.outgoing.sink-stock-price.value.serializer=io.apicurio.registry.utils.serde.AvroKafkaSerializer -mp.messaging.outgoing.sink-stock-price.apicurio.registry.artifact-id=io.apicurio.registry.utils.serde.strategy.SimpleTopicIdStrategy -mp.messaging.outgoing.sink-stock-price.apicurio.registry.global-id=io.apicurio.registry.utils.serde.strategy.GetOrCreateIdStrategy -mp.messaging.outgoing.sink-stock-price.apicurio.registry.avro-datum-provider=io.apicurio.registry.utils.serde.avro.ReflectAvroDatumProvider - -# Jaeger -quarkus.opentelemetry.tracer.exporter.jaeger.endpoint=http://localhost:14250/api/traces - -## Configuration file - Quarkus profile: Confluent - -%confluent.kafka.bootstrap.servers=localhost:9092 -%confluent.mp.messaging.connector.smallrye-kafka.schema.registry.url=http://localhost:8081 - -%confluent.vertx.kafka.producer.delay-ms=100 -%confluent.vertx.kafka.producer.batch-size=1 - -%confluent.mp.messaging.outgoing.source-stock-price.connector=smallrye-kafka -%confluent.mp.messaging.outgoing.source-stock-price.topic=stock-price -%confluent.mp.messaging.outgoing.source-stock-price.schema.registry.url=http://localhost:8081 -%confluent.mp.messaging.outgoing.source-stock-price.value.serializer=io.confluent.kafka.serializers.KafkaAvroSerializer - -%confluent.mp.messaging.incoming.channel-stock-price.connector=smallrye-kafka -%confluent.mp.messaging.incoming.channel-stock-price.topic=stock-price -%confluent.mp.messaging.incoming.channel-stock-price.schema.registry.url=http://localhost:8081 -%confluent.mp.messaging.incoming.channel-stock-price.specific.avro.reader=true -%confluent.mp.messaging.incoming.channel-stock-price.value.deserializer=io.confluent.kafka.serializers.KafkaAvroDeserializer -%confluent.mp.messaging.incoming.channel-stock-price.auto.offset.reset=earliest -%confluent.mp.messaging.incoming.channel-stock-price.enable.auto.commit=true - -%confluent.mp.messaging.outgoing.sink-stock-price.connector=smallrye-kafka -%confluent.mp.messaging.outgoing.sink-stock-price.topic=end-stock-price -%confluent.mp.messaging.outgoing.sink-stock-price.schema.registry.url=http://localhost:8081 -%confluent.mp.messaging.outgoing.sink-stock-price.value.serializer=io.confluent.kafka.serializers.KafkaAvroSerializer diff --git a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativeDb2HandlerIT.java b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativeDb2HandlerIT.java new file mode 100644 index 00000000..26b15d76 --- /dev/null +++ b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativeDb2HandlerIT.java @@ -0,0 +1,7 @@ +package io.quarkus.qe.vertx.sql.handlers; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class NativeDb2HandlerIT extends Db2HandlerTest { +} diff --git a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativeMysqlHandlerIT.java b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativeMysqlHandlerIT.java new file mode 100644 index 00000000..28b791b6 --- /dev/null +++ b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativeMysqlHandlerIT.java @@ -0,0 +1,7 @@ +package io.quarkus.qe.vertx.sql.handlers; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class NativeMysqlHandlerIT extends MysqlHandlerTest { +} diff --git a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativePostgresqlHandlerIT.java b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativePostgresqlHandlerIT.java new file mode 100644 index 00000000..72a01d30 --- /dev/null +++ b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/NativePostgresqlHandlerIT.java @@ -0,0 +1,7 @@ +package io.quarkus.qe.vertx.sql.handlers; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class NativePostgresqlHandlerIT extends PostgresqlHandlerTest { +} diff --git a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/PostgresqlHandlerIT.java b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/PostgresqlHandlerIT.java deleted file mode 100644 index 803680fa..00000000 --- a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/handlers/PostgresqlHandlerIT.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.quarkus.qe.vertx.sql.handlers; - -import io.quarkus.qe.vertx.sql.test.resources.PostgresqlResource; -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.NativeImageTest; - -@NativeImageTest -@QuarkusTestResource(PostgresqlResource.class) -public class PostgresqlHandlerIT extends CommonTestCases { -} diff --git a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/Db2Resource.java b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/Db2Resource.java index 8ab26245..54a2697c 100644 --- a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/Db2Resource.java +++ b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/Db2Resource.java @@ -1,7 +1,5 @@ package io.quarkus.qe.vertx.sql.test.resources; -import static io.quarkus.qe.vertx.sql.test.resources.Db2TestProfile.PROFILE; - import java.time.Duration; import java.util.HashMap; import java.util.Map; @@ -19,16 +17,6 @@ public class Db2Resource implements QuarkusTestResourceLifecycleManager { @Override public Map start() { - Map config = new HashMap<>(); - String profile = System.getProperty("quarkus.test.profile"); - if (profile.equals(PROFILE)) - defaultDb2Container(config); - - return config; - } - - @SuppressWarnings("resource") - private void defaultDb2Container(Map config) { db2Container = new GenericContainer<>(DockerImageName.parse("quay.io/pjgg/db2:11.5.5.0")) .withPrivilegedMode(true) .withEnv("LICENSE", "accept") @@ -42,13 +30,20 @@ private void defaultDb2Container(Map config) { db2Container.waitingFor(new HostPortWaitStrategy()).waitingFor( Wait.forLogMessage(".*Setup has completed\\..*", 1).withStartupTimeout(Duration.ofMinutes(10))).start(); + Map config = new HashMap<>(); config.put("quarkus.datasource.db2.jdbc.url", String.format("jdbc:db2://%s:%d/amadeus", db2Container.getHost(), db2Container.getFirstMappedPort())); config.put("quarkus.datasource.db2.reactive.url", String.format("db2://%s:%d/amadeus", db2Container.getHost(), db2Container.getFirstMappedPort())); config.put("app.selected.db", "db2"); + // Enable Flyway for DB2 + config.put("quarkus.flyway.db2.migrate-at-start", "true"); + // Disable Flyway for Postgresql config.put("quarkus.flyway.migrate-at-start", "false"); + // Disable Flyway for MySQL config.put("quarkus.flyway.mysql.migrate-at-start", "false"); + + return config; } @Override diff --git a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/MysqlResource.java b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/MysqlResource.java index fbee4f53..c306c945 100644 --- a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/MysqlResource.java +++ b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/MysqlResource.java @@ -1,7 +1,5 @@ package io.quarkus.qe.vertx.sql.test.resources; -import static io.quarkus.qe.vertx.sql.test.resources.MysqlTestProfile.PROFILE; - import java.util.HashMap; import java.util.Map; @@ -18,16 +16,6 @@ public class MysqlResource implements QuarkusTestResourceLifecycleManager { @Override public Map start() { - Map config = new HashMap<>(); - String profile = System.getProperty("quarkus.test.profile"); - if (profile.equals(PROFILE)) - defaultMysqlContainer(config); - - return config; - } - - @SuppressWarnings("resource") - private void defaultMysqlContainer(Map config) { mysqlContainer = new GenericContainer<>(DockerImageName.parse("quay.io/bitnami/mysql:5.7.32")) .withEnv("MYSQL_ROOT_PASSWORD", "test") .withEnv("MYSQL_USER", "test") @@ -38,13 +26,20 @@ private void defaultMysqlContainer(Map config) { mysqlContainer.waitingFor(new HostPortWaitStrategy()).waitingFor( Wait.forLogMessage(".*MySQL Community Server.*", 1)).start(); + Map config = new HashMap<>(); config.put("quarkus.datasource.mysql.jdbc.url", String.format("jdbc:mysql://%s:%d/amadeus", mysqlContainer.getHost(), mysqlContainer.getFirstMappedPort())); config.put("quarkus.datasource.mysql.reactive.url", String.format("mysql://%s:%d/amadeus", mysqlContainer.getHost(), mysqlContainer.getFirstMappedPort())); config.put("app.selected.db", "mysql"); + // Enable Flyway for MySQL + config.put("quarkus.flyway.mysql.migrate-at-start", "true"); + // Disable Flyway for Postgresql config.put("quarkus.flyway.migrate-at-start", "false"); + // Disable Flyway for DB2 config.put("quarkus.flyway.db2.migrate-at-start", "false"); + + return config; } @Override diff --git a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/MysqlTestProfile.java b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/MysqlTestProfile.java index d66c7948..481845f3 100644 --- a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/MysqlTestProfile.java +++ b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/MysqlTestProfile.java @@ -16,6 +16,6 @@ public String getConfigProfile() { @Override public List testResources() { - return Collections.singletonList(new TestResourceEntry(io.quarkus.qe.vertx.sql.test.resources.MysqlResource.class)); + return Collections.singletonList(new TestResourceEntry(MysqlResource.class)); } } diff --git a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/PostgresqlResource.java b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/PostgresqlResource.java index 271eb97a..8a317348 100644 --- a/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/PostgresqlResource.java +++ b/303-quarkus-vertx-sql/src/test/java/io/quarkus/qe/vertx/sql/test/resources/PostgresqlResource.java @@ -1,13 +1,10 @@ package io.quarkus.qe.vertx.sql.test.resources; -import static io.quarkus.qe.vertx.sql.test.resources.PostgresqlTestProfile.PROFILE; - import java.util.HashMap; import java.util.Map; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy; -import org.testcontainers.shaded.org.apache.commons.lang.StringUtils; import org.testcontainers.utility.DockerImageName; import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; @@ -18,16 +15,6 @@ public class PostgresqlResource implements QuarkusTestResourceLifecycleManager { @Override public Map start() { - Map config = new HashMap<>(); - String profile = System.getProperty("quarkus.test.profile"); - if (StringUtils.isEmpty(profile) || profile.equals(PROFILE)) - defaultPostgresContainer(config); - - return config; - } - - @SuppressWarnings("resource") - private void defaultPostgresContainer(Map config) { postgresContainer = new GenericContainer<>(DockerImageName.parse("quay.io/debezium/postgres:latest")) .withEnv("POSTGRES_USER", "test") .withEnv("POSTGRES_PASSWORD", "test") @@ -36,13 +23,20 @@ private void defaultPostgresContainer(Map config) { postgresContainer.waitingFor(new HostPortWaitStrategy()).start(); + Map config = new HashMap<>(); config.put("quarkus.datasource.jdbc.url", String.format("jdbc:postgresql://%s:%d/amadeus", postgresContainer.getHost(), postgresContainer.getFirstMappedPort())); config.put("quarkus.datasource.reactive.url", String.format("postgresql://%s:%d/amadeus", postgresContainer.getHost(), postgresContainer.getFirstMappedPort())); config.put("app.selected.db", "postgresql"); + // Enable Flyway for Postgresql + config.put("quarkus.flyway.migrate-at-start", "true"); + // Disable Flyway for MySQL config.put("quarkus.flyway.mysql.migrate-at-start", "false"); + // Disable Flyway for DB2 config.put("quarkus.flyway.db2.migrate-at-start", "false"); + + return config; } @Override