From a69358a253c2e7c946d9f025da5d5dead7ca2523 Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Thu, 27 Oct 2022 16:49:18 -0300 Subject: [PATCH 01/14] KOGITO-7985 Job service integration tests improvements --- .../pom.xml | 7 + .../JobServiceComposeQuarkusTestResource.java | 38 +++++ .../JobServiceQuarkusTestResource.java | 25 --- ...ource.java => JobServiceTestResource.java} | 27 +++- .../kogito/it/jobs/JobServiceLeaderIT.java | 105 +++++++++++++ .../resources/AbstractJobServiceResource.java | 10 +- .../resources/JobServiceComposeResource.java | 147 ++++++++++++++++++ .../testcontainers/JobServiceContainer.java | 11 +- .../pom.xml | 4 - .../it/jobs/CallbackStateTimeoutsIT.java | 7 +- .../kie/kogito/it/jobs/ProcessAsyncIT.java | 9 +- .../kie/kogito/it/jobs/ProcessTimerIT.java | 9 +- .../kogito/it/jobs/SwitchStateTimeoutsIT.java | 8 +- .../pom.xml | 5 - .../it/jobs/CallbackStateTimeoutsIT.java | 6 +- .../kie/kogito/it/jobs/ProcessAsyncIT.java | 9 +- .../kie/kogito/it/jobs/ProcessTimerIT.java | 9 +- .../kogito/it/jobs/SwitchStateTimeoutsIT.java | 6 +- .../pom.xml | 2 +- .../it/jobs/CallbackStateTimeoutsIT.java | 4 +- .../kie/kogito/it/jobs/ProcessAsyncIT.java | 8 +- .../kie/kogito/it/jobs/ProcessTimerIT.java | 8 +- .../kogito/it/jobs/SwitchStateTimeoutsIT.java | 4 +- .../pom.xml | 28 ++-- .../integration-tests-jobs-service/pom.xml | 31 ++++ 25 files changed, 417 insertions(+), 110 deletions(-) create mode 100644 apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java delete mode 100644 apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceQuarkusTestResource.java rename apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/{JobServiceKafkaQuarkusTestResource.java => JobServiceTestResource.java} (52%) create mode 100644 apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java create mode 100644 apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/pom.xml index 0818593ee2..574adf294e 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/pom.xml @@ -24,6 +24,13 @@ org.kie.kogito integration-tests-jobs-service-common + + + org.kie.kogito + integration-tests-data-index-service-common + ${project.version} + + org.kie.kogito kogito-quarkus-test-utils diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java new file mode 100644 index 0000000000..cdd7a14366 --- /dev/null +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.kie.kogito.test.resources; + +import io.quarkus.test.common.QuarkusTestResourceConfigurableLifecycleManager; +import org.kie.kogito.testcontainers.KogitoKafkaContainer; +import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer; + +public class JobServiceComposeQuarkusTestResource extends AbstractJobServiceQuarkusTestResource + implements QuarkusTestResourceConfigurableLifecycleManager { + + public static final String JOBS_SERVICE_URL = "kogito.jobs-service.url"; + + public JobServiceComposeQuarkusTestResource() { + super(JOBS_SERVICE_URL, new JobServiceComposeResource()); + } + + @Override + public void init(JobServiceTestResource annotation) { + //TODO: set containers according to properties + getTestResource() + .withDependencyContainer(new KogitoPostgreSqlContainer()) + .withDependencyContainer(new KogitoKafkaContainer()); + } +} diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceQuarkusTestResource.java deleted file mode 100644 index e353c6ade1..0000000000 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceQuarkusTestResource.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2022 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.kie.kogito.test.resources; - -public class JobServiceQuarkusTestResource extends AbstractJobServiceQuarkusTestResource { - - public static final String JOBS_SERVICE_URL = "kogito.jobs-service.url"; - - public JobServiceQuarkusTestResource() { - super(JOBS_SERVICE_URL, new JobServiceResource()); - } -} \ No newline at end of file diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceKafkaQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java similarity index 52% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceKafkaQuarkusTestResource.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java index 176b93c6b9..a36a6f7c54 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceKafkaQuarkusTestResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java @@ -13,14 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.kie.kogito.test.resources; -public class JobServiceKafkaQuarkusTestResource extends AbstractJobServiceQuarkusTestResource { +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.quarkus.test.common.QuarkusTestResource; + +@QuarkusTestResource(JobServiceComposeQuarkusTestResource.class) +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface JobServiceTestResource { + + boolean enableKafka() default false; + + boolean enablePostgreSQL() default true; + + boolean enableKnativeEventing() default false; - public static final String JOBS_SERVICE_KAFKA_URL = "kogito.jobs-service-kafka.url"; + boolean enableDataIndex() default false; - public JobServiceKafkaQuarkusTestResource() { - super(JOBS_SERVICE_KAFKA_URL, new JobServiceKafkaResource()); - } -} + int jobServiceInstances() default 1; +} \ No newline at end of file diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java new file mode 100644 index 0000000000..ce75cdd722 --- /dev/null +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.kie.kogito.it.jobs; + +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.kie.kogito.test.resources.JobServiceComposeResource; +import org.kie.kogito.testcontainers.JobServiceContainer; +import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; + +public class JobServiceLeaderIT { + + private static JobServiceComposeResource resource; + private final static Logger logger = LoggerFactory.getLogger(JobServiceLeaderIT.class); + + private static List containers; + + @BeforeAll + public static void init() { + resource = new JobServiceComposeResource() + .withServiceContainer("job-service-1", new JobServiceContainer()) + .withServiceContainer("job-service-2", new JobServiceContainer()) + .withDependencyContainer(new KogitoPostgreSqlContainer()); + containers = resource.getServiceContainers(JobServiceContainer.class); + //decrease the leader expiration timeout to 2 seconds to make the test quicker + containers.stream().forEach(c -> c.withEnv("KOGITO_JOBS_SERVICE_MANAGEMENT_HEARTBEAT_EXPIRATION_IN_SECONDS", "2")); + resource.start(); + } + + @Test + public void testSingleLeader() { + List responses = containers.stream() + .map(container -> healthRequest(container)) + .collect(Collectors.toList()); + //only one instance should be the leader (returning 200 OK) + assertThat(responses).containsExactlyInAnyOrder(200, 503, 503); + } + + @Test + public void testChangingLeader() { + //find the leader + JobServiceContainer leader = containers.stream() + .filter(container -> 200 == healthRequest(container)) + .findFirst() + .orElse(null); + //stop the leader + leader.stop(); + //get the non-leaders + List remain = containers.stream() + .filter(container -> container.isRunning()) + .collect(Collectors.toList()); + assertThat(remain).hasSize(2); + + //wait until a non-leader become leader + await().atMost(5, TimeUnit.SECONDS) + .untilAsserted(() -> { + List responses = remain.stream() + .map(container -> healthRequest(container)) + .collect(Collectors.toList()); + assertThat(responses).containsExactlyInAnyOrder(200, 503); + }); + + //start the old leader again + leader.start(); + //check if the old leader it not a leader anymore + assertThat(healthRequest(leader)).isEqualTo(503); + } + + private static int healthRequest(JobServiceContainer container) { + String url = "http://" + container.getHost() + ":" + container.getMappedPort(); + logger.debug("Request to URL " + url); + return given() + .baseUri(url) + .contentType(ContentType.JSON) + .accept(ContentType.JSON) + .when() + .get("/q/health/ready") + .statusCode(); + } +} diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceResource.java index 8d4e232178..88a95ac58e 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceResource.java @@ -23,9 +23,17 @@ public abstract class AbstractJobServiceResource implements TestResource { - protected final JobServiceContainer jobService = new JobServiceContainer(); + protected final JobServiceContainer jobService; protected final Map properties = new HashMap<>(); + public AbstractJobServiceResource() { + this(new JobServiceContainer()); + } + + public AbstractJobServiceResource(JobServiceContainer jobService) { + this.jobService = jobService; + } + @Override public String getResourceName() { return jobService.getResourceName(); diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java new file mode 100644 index 0000000000..e007f65c49 --- /dev/null +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java @@ -0,0 +1,147 @@ +/* + * Copyright 2022 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.kie.kogito.test.resources; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.kie.kogito.testcontainers.KogitoGenericContainer; +import org.kie.kogito.testcontainers.KogitoKafkaContainer; +import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.Network; +import org.testcontainers.containers.wait.strategy.Wait; + +public class JobServiceComposeResource extends AbstractJobServiceResource { + + private static final Logger LOGGER = LoggerFactory.getLogger(JobServiceComposeResource.class); + private final List> dependencyContainers; + private final Map serviceContainers; + + public JobServiceComposeResource() { + this.dependencyContainers = new ArrayList<>(); + this.serviceContainers = new HashMap<>(); + withServiceContainer("job-service-main", jobService); + } + + public JobServiceComposeResource withServiceContainer(String id, KogitoGenericContainer container) { + serviceContainers.put(id, container); + return this; + } + + public JobServiceComposeResource withDependencyContainer(GenericContainer container) { + dependencyContainers.add(container); + return this; + } + + public List getServiceContainers(Class type) { + return serviceContainers.values().stream().filter(type::isInstance).map(type::cast).collect(Collectors.toList()); + } + + private String hostName(GenericContainer container) { + return container.getContainerInfo().getConfig().getHostName(); + } + + @Override + public void start() { + LOGGER.info("Start JobService with {} test resources", dependencyContainers.stream().map(GenericContainer::getImage).collect(Collectors.toList())); + properties.clear(); + + final Network network = Network.newNetwork(); + dependencyContainers.stream() + .map(c -> c.withNetwork(network)) + .map(c -> c.waitingFor(Wait.forListeningPort())) + .forEach(GenericContainer::start); + + configurePostgreSQL(); + configureKafka(); + startServices(network); + } + + protected void startServices(Network network) { + serviceContainers.values() + .forEach(service -> { + service.withNetwork(network); + service.start(); + LOGGER.info("JobService test resource started"); + }); + } + + protected void configureKafka() { + dependencyContainers.stream() + .filter(KogitoKafkaContainer.class::isInstance) + .map(KogitoKafkaContainer.class::cast) + .findFirst() + .ifPresent(kafka -> { + LOGGER.info("Configure Kafka"); + // external access url + String kafkaURL = kafka.getBootstrapServers(); + LOGGER.info("kafkaURL: {}", kafkaURL); + properties.put("kafka.bootstrap.servers", kafkaURL); + properties.put("spring.kafka.bootstrap-servers", kafkaURL); + + final String kafkaInternalUrl = hostName(kafka) + ":29092"; + LOGGER.info("kafkaInternalURL: {}", kafkaInternalUrl); + serviceContainers.values() + .forEach(service -> { + service.addEnv("KAFKA_BOOTSTRAP_SERVERS", kafkaInternalUrl); + service.addEnv("QUARKUS_PROFILE", "events-support"); + }); + }); + } + + protected void configurePostgreSQL() { + dependencyContainers.stream() + .filter(KogitoPostgreSqlContainer.class::isInstance) + .map(KogitoPostgreSqlContainer.class::cast) + .findFirst() + .ifPresent(postgreSql -> { + LOGGER.info("Configure PostgreSQL"); + final String connectionTemplate = "postgresql://{0}:{1}/{2}"; + final String jdbcConnectionTemplate = "jdbc:postgresql://{0}:{1}/{2}"; + final String server = hostName(postgreSql); + final String port = "5432"; + final String username = postgreSql.getUsername(); + final String password = postgreSql.getPassword(); + final String database = postgreSql.getDatabaseName(); + final String reactiveUrl = MessageFormat.format(connectionTemplate, server, port, database); + final String jdbcUrl = MessageFormat.format(jdbcConnectionTemplate, server, port, database); + serviceContainers.values() + .forEach(service -> { + service.addEnv("QUARKUS_DATASOURCE_JDBC_URL", jdbcUrl); + service.addEnv("QUARKUS_DATASOURCE_REACTIVE_URL", reactiveUrl); + service.addEnv("QUARKUS_DATASOURCE_USERNAME", username); + service.addEnv("QUARKUS_DATASOURCE_PASSWORD", password); + service.addEnv("QUARKUS_DATASOURCE_DB-KIND", "postgresql"); + }); + }); + } + + @Override + public void stop() { + LOGGER.info("Stopping test resource"); + serviceContainers.values().forEach(GenericContainer::stop); + dependencyContainers.forEach(GenericContainer::stop); + LOGGER.info("Test resource stopped"); + } +} diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/testcontainers/JobServiceContainer.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/testcontainers/JobServiceContainer.java index 8541d36233..494c1c08af 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/testcontainers/JobServiceContainer.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/testcontainers/JobServiceContainer.java @@ -26,7 +26,8 @@ public class JobServiceContainer extends KogitoGenericContainerorg.kie.kogito kogito-addons-quarkus-jobs-knative-eventing - - io.quarkus - quarkus-smallrye-health - com.github.tomakehurst wiremock-jre8 diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java index 9435fce06d..2486374752 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java @@ -16,14 +16,11 @@ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceQuarkusTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceQuarkusTestResource.class) @QuarkusIntegrationTest +@JobServiceTestResource class CallbackStateTimeoutsIT extends BaseCallbackStateTimeoutsIT { } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java index c038ac8be2..ddacc064a5 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java @@ -16,17 +16,14 @@ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceQuarkusTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceQuarkusTestResource.JOBS_SERVICE_URL; +import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceQuarkusTestResource.class) +@JobServiceTestResource class ProcessAsyncIT extends BaseProcessAsyncIT { @Override diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java index 51702b23f7..e3417391f2 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java @@ -15,17 +15,14 @@ */ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceQuarkusTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceQuarkusTestResource.JOBS_SERVICE_URL; +import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceQuarkusTestResource.class) +@JobServiceTestResource class ProcessTimerIT extends BaseProcessTimerIT { @Override diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java index d9b1286067..2a43154587 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java @@ -16,8 +16,7 @@ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceQuarkusTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; import com.github.tomakehurst.wiremock.WireMockServer; @@ -31,10 +30,9 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceQuarkusTestResource.class) -@QuarkusTestResource(SinkMock.class) @QuarkusIntegrationTest +@QuarkusTestResource(SinkMock.class) +@JobServiceTestResource class SwitchStateTimeoutsIT extends BaseSwitchStateTimeoutsIT implements SinkMock.SinkMockAware { private WireMockServer sink; diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/pom.xml index 2d99d08883..59cd6be67d 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/pom.xml @@ -17,10 +17,6 @@ org.kie.kogito kogito-addons-quarkus-jobs-management - - io.quarkus - quarkus-smallrye-health - @@ -37,5 +33,4 @@ - \ No newline at end of file diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java index 5ddd2e010f..1725aed1f8 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java @@ -16,16 +16,14 @@ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; -import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; @QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceQuarkusTestResource.class) -@QuarkusTestResource(KafkaQuarkusTestResource.class) +@JobServiceTestResource @QuarkusIntegrationTest class CallbackStateTimeoutsIT extends BaseCallbackStateTimeoutsIT { } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java index eeed2bb70e..255333f32a 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java @@ -15,17 +15,14 @@ */ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceQuarkusTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceQuarkusTestResource.JOBS_SERVICE_URL; +import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceQuarkusTestResource.class) +@JobServiceTestResource class ProcessAsyncIT extends BaseProcessAsyncIT { @Override diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java index 51702b23f7..e3417391f2 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java @@ -15,17 +15,14 @@ */ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceQuarkusTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceQuarkusTestResource.JOBS_SERVICE_URL; +import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceQuarkusTestResource.class) +@JobServiceTestResource class ProcessTimerIT extends BaseProcessTimerIT { @Override diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java index 5f58de7904..07ff158a83 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java @@ -16,16 +16,14 @@ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; -import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; @QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceQuarkusTestResource.class) -@QuarkusTestResource(KafkaQuarkusTestResource.class) +@JobServiceTestResource @QuarkusIntegrationTest class SwitchStateTimeoutsIT extends KafkaBaseSwitchStateTimeoutsIT { } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml index bedba9e528..842c9c46c1 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml @@ -19,7 +19,7 @@ io.quarkus - quarkus-smallrye-health + quarkus-smallrye-reactive-messaging-kafka diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java index d5f78bd7ff..1725aed1f8 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java @@ -16,14 +16,14 @@ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceKafkaQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; @QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceKafkaQuarkusTestResource.class) +@JobServiceTestResource @QuarkusIntegrationTest class CallbackStateTimeoutsIT extends BaseCallbackStateTimeoutsIT { } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java index 3b8e92a38c..42df1099e1 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java @@ -15,21 +15,21 @@ */ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceKafkaQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceKafkaQuarkusTestResource.JOBS_SERVICE_KAFKA_URL; +import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest @QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceKafkaQuarkusTestResource.class) +@JobServiceTestResource class ProcessAsyncIT extends BaseProcessAsyncIT { @Override public String jobServiceUrl() { - return System.getProperty(JOBS_SERVICE_KAFKA_URL); + return System.getProperty(JOBS_SERVICE_URL); } } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java index e8b532cad5..fcdd3b07e5 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java @@ -15,21 +15,21 @@ */ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceKafkaQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceKafkaQuarkusTestResource.JOBS_SERVICE_KAFKA_URL; +import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest @QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceKafkaQuarkusTestResource.class) +@JobServiceTestResource class ProcessTimerIT extends BaseProcessTimerIT { @Override public String jobServiceUrl() { - return System.getProperty(JOBS_SERVICE_KAFKA_URL); + return System.getProperty(JOBS_SERVICE_URL); } } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java index c8ca269db0..07ff158a83 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java @@ -16,14 +16,14 @@ package org.kie.kogito.it.jobs; -import org.kie.kogito.test.resources.JobServiceKafkaQuarkusTestResource; +import org.kie.kogito.test.resources.JobServiceTestResource; import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; @QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@QuarkusTestResource(JobServiceKafkaQuarkusTestResource.class) +@JobServiceTestResource @QuarkusIntegrationTest class SwitchStateTimeoutsIT extends KafkaBaseSwitchStateTimeoutsIT { } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml index 95256cb27b..d421a46777 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml @@ -46,6 +46,10 @@ io.quarkus quarkus-smallrye-reactive-messaging-kafka + + io.quarkus + quarkus-smallrye-health + io.quarkus quarkus-resteasy @@ -103,18 +107,18 @@ - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - + + + + + + + + + + + + diff --git a/apps-integration-tests/integration-tests-jobs-service/pom.xml b/apps-integration-tests/integration-tests-jobs-service/pom.xml index 20b08a1b81..05ecdd7927 100644 --- a/apps-integration-tests/integration-tests-jobs-service/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/pom.xml @@ -77,4 +77,35 @@ + + + + common + + true + + + + org.kie.kogito/jobs-service-postgresql:${project.version} + org.kie.kogito/data-index-service-inmemory:${project.version} + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + ${container.image.jobs-service} + ${container.image.data-index-service-inmemory} + ${container.image.data-index-service-inmemory} + + + + + + + + From c4f0162fb0524f02aacd37dc4488baf407bf52a4 Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Fri, 28 Oct 2022 09:04:48 -0300 Subject: [PATCH 02/14] fix imports --- .../test/resources/JobServiceComposeQuarkusTestResource.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java index cdd7a14366..905bcbd7b8 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java @@ -15,10 +15,11 @@ */ package org.kie.kogito.test.resources; -import io.quarkus.test.common.QuarkusTestResourceConfigurableLifecycleManager; import org.kie.kogito.testcontainers.KogitoKafkaContainer; import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer; +import io.quarkus.test.common.QuarkusTestResourceConfigurableLifecycleManager; + public class JobServiceComposeQuarkusTestResource extends AbstractJobServiceQuarkusTestResource implements QuarkusTestResourceConfigurableLifecycleManager { From 55ac53abf295a034be0699a6cb016ee1382a147f Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Fri, 28 Oct 2022 10:34:20 -0300 Subject: [PATCH 03/14] improving quarkus test resources for job service --- .../JobServiceComposeQuarkusTestResource.java | 21 +++++++++++++++---- .../resources/JobServiceTestResource.java | 14 ++++++++----- .../resources/JobServiceComposeResource.java | 7 ++----- .../it/jobs/CallbackStateTimeoutsIT.java | 5 ++++- .../kie/kogito/it/jobs/ProcessAsyncIT.java | 5 ++++- .../kie/kogito/it/jobs/ProcessTimerIT.java | 5 ++++- .../kogito/it/jobs/SwitchStateTimeoutsIT.java | 4 +++- .../it/jobs/CallbackStateTimeoutsIT.java | 6 +++--- .../kie/kogito/it/jobs/ProcessAsyncIT.java | 3 +++ .../kie/kogito/it/jobs/ProcessTimerIT.java | 3 +++ .../kogito/it/jobs/SwitchStateTimeoutsIT.java | 6 +++--- .../it/jobs/CallbackStateTimeoutsIT.java | 5 +---- .../kie/kogito/it/jobs/ProcessAsyncIT.java | 5 +---- .../kie/kogito/it/jobs/ProcessTimerIT.java | 5 +---- .../kogito/it/jobs/SwitchStateTimeoutsIT.java | 5 +---- .../management/JobServiceInstanceManager.java | 2 +- 16 files changed, 60 insertions(+), 41 deletions(-) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java index 905bcbd7b8..22ea3c3fc3 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java @@ -15,6 +15,8 @@ */ package org.kie.kogito.test.resources; +import org.kie.kogito.index.testcontainers.DataIndexInMemoryContainer; +import org.kie.kogito.testcontainers.JobServiceContainer; import org.kie.kogito.testcontainers.KogitoKafkaContainer; import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer; @@ -31,9 +33,20 @@ public JobServiceComposeQuarkusTestResource() { @Override public void init(JobServiceTestResource annotation) { - //TODO: set containers according to properties - getTestResource() - .withDependencyContainer(new KogitoPostgreSqlContainer()) - .withDependencyContainer(new KogitoKafkaContainer()); + switch (annotation.persistence()) { + case POSTGRESQL: + getTestResource().withDependencyContainer(new KogitoPostgreSqlContainer()); + break; + case IN_MEMORY: + default: + //no persistence + } + if (annotation.kafkaEnabled()) { + getTestResource().withDependencyContainer(new KogitoKafkaContainer()); + getTestResource().getServiceContainers(JobServiceContainer.class).forEach(c -> c.addEnv("QUARKUS_PROFILE", "events-support")); + } + if (annotation.dataIndexEnabled()) { + getTestResource().withServiceContainer("data-index", new DataIndexInMemoryContainer()); + } } } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java index a36a6f7c54..c8ccc87136 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java @@ -23,17 +23,21 @@ import io.quarkus.test.common.QuarkusTestResource; @QuarkusTestResource(JobServiceComposeQuarkusTestResource.class) +@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface JobServiceTestResource { - boolean enableKafka() default false; + enum Persistence { + POSTGRESQL, + IN_MEMORY; + } - boolean enablePostgreSQL() default true; + boolean kafkaEnabled() default false; - boolean enableKnativeEventing() default false; + Persistence persistence() default Persistence.POSTGRESQL; - boolean enableDataIndex() default false; + boolean knativeEventingEnabled() default false; - int jobServiceInstances() default 1; + boolean dataIndexEnabled() default false; } \ No newline at end of file diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java index e007f65c49..f9ea89237f 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java @@ -100,13 +100,10 @@ protected void configureKafka() { properties.put("kafka.bootstrap.servers", kafkaURL); properties.put("spring.kafka.bootstrap-servers", kafkaURL); + //internal access final String kafkaInternalUrl = hostName(kafka) + ":29092"; LOGGER.info("kafkaInternalURL: {}", kafkaInternalUrl); - serviceContainers.values() - .forEach(service -> { - service.addEnv("KAFKA_BOOTSTRAP_SERVERS", kafkaInternalUrl); - service.addEnv("QUARKUS_PROFILE", "events-support"); - }); + serviceContainers.values().forEach(service -> service.addEnv("KAFKA_BOOTSTRAP_SERVERS", kafkaInternalUrl)); }); } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java index 2486374752..3519140d0d 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java @@ -17,10 +17,13 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; +import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; +import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; @QuarkusIntegrationTest -@JobServiceTestResource +@QuarkusTestResource(KafkaQuarkusTestResource.class) +@JobServiceTestResource(knativeEventingEnabled = true) class CallbackStateTimeoutsIT extends BaseCallbackStateTimeoutsIT { } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java index ddacc064a5..622d59a8ec 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java @@ -17,13 +17,16 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; +import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; +import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest -@JobServiceTestResource +@QuarkusTestResource(KafkaQuarkusTestResource.class) +@JobServiceTestResource(knativeEventingEnabled = true) class ProcessAsyncIT extends BaseProcessAsyncIT { @Override diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java index e3417391f2..c97a614919 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java @@ -16,13 +16,16 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; +import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; +import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest -@JobServiceTestResource +@QuarkusTestResource(KafkaQuarkusTestResource.class) +@JobServiceTestResource(knativeEventingEnabled = true) class ProcessTimerIT extends BaseProcessTimerIT { @Override diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java index 2a43154587..f9ba5cf1cf 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java @@ -17,6 +17,7 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; +import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; import com.github.tomakehurst.wiremock.WireMockServer; @@ -31,8 +32,9 @@ import static org.awaitility.Awaitility.await; @QuarkusIntegrationTest +@QuarkusTestResource(KafkaQuarkusTestResource.class) @QuarkusTestResource(SinkMock.class) -@JobServiceTestResource +@JobServiceTestResource(knativeEventingEnabled = true) class SwitchStateTimeoutsIT extends BaseSwitchStateTimeoutsIT implements SinkMock.SinkMockAware { private WireMockServer sink; diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java index 1725aed1f8..6614c03018 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java @@ -17,13 +17,13 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; +import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@JobServiceTestResource @QuarkusIntegrationTest +@QuarkusTestResource(KafkaQuarkusTestResource.class) +@JobServiceTestResource class CallbackStateTimeoutsIT extends BaseCallbackStateTimeoutsIT { } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java index 255333f32a..0cf671beb7 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java @@ -16,12 +16,15 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; +import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; +import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest +@QuarkusTestResource(KafkaQuarkusTestResource.class) @JobServiceTestResource class ProcessAsyncIT extends BaseProcessAsyncIT { diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java index e3417391f2..97daf5be6a 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java @@ -16,12 +16,15 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; +import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; +import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest +@QuarkusTestResource(KafkaQuarkusTestResource.class) @JobServiceTestResource class ProcessTimerIT extends BaseProcessTimerIT { diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java index 07ff158a83..53604cb1f0 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java @@ -17,13 +17,13 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; +import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@JobServiceTestResource @QuarkusIntegrationTest +@QuarkusTestResource(KafkaQuarkusTestResource.class) +@JobServiceTestResource class SwitchStateTimeoutsIT extends KafkaBaseSwitchStateTimeoutsIT { } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java index 1725aed1f8..3592fa917c 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/CallbackStateTimeoutsIT.java @@ -17,13 +17,10 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@JobServiceTestResource @QuarkusIntegrationTest +@JobServiceTestResource(kafkaEnabled = true) class CallbackStateTimeoutsIT extends BaseCallbackStateTimeoutsIT { } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java index 42df1099e1..1864ed2b65 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java @@ -16,16 +16,13 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@JobServiceTestResource +@JobServiceTestResource(kafkaEnabled = true) class ProcessAsyncIT extends BaseProcessAsyncIT { @Override diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java index fcdd3b07e5..97dc5f8996 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java @@ -16,16 +16,13 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@JobServiceTestResource +@JobServiceTestResource(kafkaEnabled = true) class ProcessTimerIT extends BaseProcessTimerIT { @Override diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java index 07ff158a83..5e6f52abc1 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/SwitchStateTimeoutsIT.java @@ -17,13 +17,10 @@ package org.kie.kogito.it.jobs; import org.kie.kogito.test.resources.JobServiceTestResource; -import org.kie.kogito.test.resources.KogitoServiceRandomPortQuarkusTestResource; -import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -@QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) -@JobServiceTestResource @QuarkusIntegrationTest +@JobServiceTestResource(kafkaEnabled = true) class SwitchStateTimeoutsIT extends KafkaBaseSwitchStateTimeoutsIT { } diff --git a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/management/JobServiceInstanceManager.java b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/management/JobServiceInstanceManager.java index 3b1cc0b864..b8eec29b21 100644 --- a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/management/JobServiceInstanceManager.java +++ b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/management/JobServiceInstanceManager.java @@ -93,7 +93,7 @@ void startup(@Observes StartupEvent startupEvent) { //background task for heartbeat will be started when become leader heartbeat = vertx.periodicStream(TimeUnit.SECONDS.toMillis(heardBeatIntervalInSeconds)) .handler(t -> heartbeat(currentInfo.get()) - .subscribe().with(i -> LOGGER.info("Heartbeat {}", currentInfo.get()), + .subscribe().with(i -> LOGGER.debug("Heartbeat {}", currentInfo.get()), ex -> LOGGER.error("Error on heartbeat {}", currentInfo.get(), ex))) .pause(); From 3585294197600eeab83624ad2e054afdb5bde704 Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Fri, 4 Nov 2022 16:47:34 -0300 Subject: [PATCH 04/14] working version in quarkus-messaging --- .../pom.xml | 15 ++ .../src/main/resources/application.properties | 16 ++ .../src/main/resources/data_index_create.sql | 208 ++++++++++++++++++ .../kie/kogito/it/jobs/ProcessTimerIT.java | 10 +- 4 files changed, 247 insertions(+), 2 deletions(-) create mode 100644 apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/data_index_create.sql diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml index 842c9c46c1..8f7b60f450 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml @@ -21,6 +21,21 @@ io.quarkus quarkus-smallrye-reactive-messaging-kafka + + + org.kie.kogito + kogito-addons-quarkus-events-process + + + org.kie.kogito + kogito-addons-quarkus-persistence-filesystem + + + io.quarkus + quarkus-jdbc-postgresql + test + + diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/application.properties b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/application.properties index 36a46449cc..b5ae4594b6 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/application.properties +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/application.properties @@ -30,3 +30,19 @@ mp.messaging.incoming.visa_approved_in.value.deserializer=org.apache.kafka.commo mp.messaging.incoming.visa_denied_in.connector=smallrye-kafka mp.messaging.incoming.visa_denied_in.topic=visa_denied_topic mp.messaging.incoming.visa_denied_in.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer + +mp.messaging.outgoing.kogito-processinstances-events.connector=smallrye-kafka +mp.messaging.outgoing.kogito-processinstances-events.topic=kogito-processinstances-events +mp.messaging.outgoing.kogito-processinstances-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer + +mp.messaging.outgoing.kogito-usertaskinstances-events.connector=smallrye-kafka +mp.messaging.outgoing.kogito-usertaskinstances-events.topic=kogito-usertaskinstances-events +mp.messaging.outgoing.kogito-usertaskinstances-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer + +mp.messaging.outgoing.kogito-variables-events.connector=smallrye-kafka +mp.messaging.outgoing.kogito-variables-events.topic=kogito-variables-events +mp.messaging.outgoing.kogito-variables-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer + +kogito.persistence.type=filesystem + +quarkus.devservices.enabled=false diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/data_index_create.sql b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/data_index_create.sql new file mode 100644 index 0000000000..1f62c2b9c2 --- /dev/null +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/data_index_create.sql @@ -0,0 +1,208 @@ + + create table attachments ( + id varchar(255) not null, + content varchar(255), + name varchar(255), + updated_at timestamp, + updated_by varchar(255), + task_id varchar(255) not null, + primary key (id) + ); + + create table comments ( + id varchar(255) not null, + content varchar(255), + updated_at timestamp, + updated_by varchar(255), + task_id varchar(255) not null, + primary key (id) + ); + + create table jobs ( + id varchar(255) not null, + callback_endpoint varchar(255), + endpoint varchar(255), + execution_counter int4, + expiration_time timestamp, + last_update timestamp, + node_instance_id varchar(255), + priority int4, + process_id varchar(255), + process_instance_id varchar(255), + repeat_interval int8, + repeat_limit int4, + retries int4, + root_process_id varchar(255), + root_process_instance_id varchar(255), + scheduled_id varchar(255), + status varchar(255), + primary key (id) + ); + + create table milestones ( + id varchar(255) not null, + process_instance_id varchar(255) not null, + name varchar(255), + status varchar(255), + primary key (id, process_instance_id) + ); + + create table nodes ( + id varchar(255) not null, + definition_id varchar(255), + enter timestamp, + exit timestamp, + name varchar(255), + node_id varchar(255), + type varchar(255), + process_instance_id varchar(255) not null, + primary key (id) + ); + + create table processes ( + id varchar(255) not null, + business_key varchar(255), + end_time timestamp, + endpoint varchar(255), + message varchar(255), + node_definition_id varchar(255), + last_update_time timestamp, + parent_process_instance_id varchar(255), + process_id varchar(255), + process_name varchar(255), + root_process_id varchar(255), + root_process_instance_id varchar(255), + start_time timestamp, + state int4, + variables jsonb, + primary key (id) + ); + + create table processes_addons ( + process_id varchar(255) not null, + addon varchar(255) not null, + primary key (process_id, addon) + ); + + create table processes_roles ( + process_id varchar(255) not null, + role varchar(255) not null, + primary key (process_id, role) + ); + + create table tasks ( + id varchar(255) not null, + actual_owner varchar(255), + completed timestamp, + description varchar(255), + endpoint varchar(255), + inputs jsonb, + last_update timestamp, + name varchar(255), + outputs jsonb, + priority varchar(255), + process_id varchar(255), + process_instance_id varchar(255), + reference_name varchar(255), + root_process_id varchar(255), + root_process_instance_id varchar(255), + started timestamp, + state varchar(255), + primary key (id) + ); + + create table tasks_admin_groups ( + task_id varchar(255) not null, + group_id varchar(255) not null, + primary key (task_id, group_id) + ); + + create table tasks_admin_users ( + task_id varchar(255) not null, + user_id varchar(255) not null, + primary key (task_id, user_id) + ); + + create table tasks_excluded_users ( + task_id varchar(255) not null, + user_id varchar(255) not null, + primary key (task_id, user_id) + ); + + create table tasks_potential_groups ( + task_id varchar(255) not null, + group_id varchar(255) not null, + primary key (task_id, group_id) + ); + + create table tasks_potential_users ( + task_id varchar(255) not null, + user_id varchar(255) not null, + primary key (task_id, user_id) + ); + + alter table if exists attachments + add constraint fk_attachments_tasks + foreign key (task_id) + references tasks + on delete cascade; + + alter table if exists comments + add constraint fk_comments_tasks + foreign key (task_id) + references tasks + on delete cascade; + + alter table if exists milestones + add constraint fk_milestones_process + foreign key (process_instance_id) + references processes + on delete cascade; + + alter table if exists nodes + add constraint fk_nodes_process + foreign key (process_instance_id) + references processes + on delete cascade; + + alter table if exists processes_addons + add constraint fk_processes_addons_processes + foreign key (process_id) + references processes + on delete cascade; + + alter table if exists processes_roles + add constraint fk_processes_roles_processes + foreign key (process_id) + references processes + on delete cascade; + + alter table if exists tasks_admin_groups + add constraint fk_tasks_admin_groups_tasks + foreign key (task_id) + references tasks + on delete cascade; + + alter table if exists tasks_admin_users + add constraint fk_tasks_admin_users_tasks + foreign key (task_id) + references tasks + on delete cascade; + + alter table if exists tasks_excluded_users + add constraint fk_tasks_excluded_users_tasks + foreign key (task_id) + references tasks + on delete cascade; + + alter table if exists tasks_potential_groups + add constraint fk_tasks_potential_groups_tasks + foreign key (task_id) + references tasks + on delete cascade; + + alter table if exists tasks_potential_users + add constraint fk_tasks_potential_users_tasks + foreign key (task_id) + references tasks + on delete cascade; diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java index 97dc5f8996..45e4b34494 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java @@ -19,14 +19,20 @@ import io.quarkus.test.junit.QuarkusIntegrationTest; +import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.DATA_INDEX_SERVICE_URL; import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest -@JobServiceTestResource(kafkaEnabled = true) +@JobServiceTestResource(kafkaEnabled = true, dataIndexEnabled = true) class ProcessTimerIT extends BaseProcessTimerIT { - @Override public String jobServiceUrl() { return System.getProperty(JOBS_SERVICE_URL); } + + @Override + public String dataIndexUrl() { + String url = System.getProperty(DATA_INDEX_SERVICE_URL); + return url; + } } From 3ec30ebdbe84d155f9605df101303c205e467ee1 Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Fri, 4 Nov 2022 16:47:46 -0300 Subject: [PATCH 05/14] working version in quarkus-messaging --- .../JobServiceComposeQuarkusTestResource.java | 45 ++++++-- .../kogito/it/jobs/JobServiceLeaderIT.java | 9 +- .../kogito/it/jobs/BaseProcessTimerIT.java | 49 +++++++++ .../resources/JobServiceComposeResource.java | 104 ++++++++++++++---- .../integration-tests-jobs-service/pom.xml | 54 ++++----- 5 files changed, 200 insertions(+), 61 deletions(-) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java index 22ea3c3fc3..781338b7d1 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java @@ -15,38 +15,67 @@ */ package org.kie.kogito.test.resources; -import org.kie.kogito.index.testcontainers.DataIndexInMemoryContainer; +import java.util.HashMap; +import java.util.Map; + +import org.kie.kogito.index.testcontainers.DataIndexPostgreSqlContainer; import org.kie.kogito.testcontainers.JobServiceContainer; import org.kie.kogito.testcontainers.KogitoKafkaContainer; import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer; import io.quarkus.test.common.QuarkusTestResourceConfigurableLifecycleManager; -public class JobServiceComposeQuarkusTestResource extends AbstractJobServiceQuarkusTestResource - implements QuarkusTestResourceConfigurableLifecycleManager { +public class JobServiceComposeQuarkusTestResource implements QuarkusTestResourceConfigurableLifecycleManager { public static final String JOBS_SERVICE_URL = "kogito.jobs-service.url"; + public static final String DATA_INDEX_SERVICE_URL = "kogito.data-index.url"; + + private JobServiceTestResource annotation; + + private JobServiceComposeResource resource; public JobServiceComposeQuarkusTestResource() { - super(JOBS_SERVICE_URL, new JobServiceComposeResource()); + resource = new JobServiceComposeResource(new JobServiceContainer()); } @Override public void init(JobServiceTestResource annotation) { + this.annotation = annotation; switch (annotation.persistence()) { case POSTGRESQL: - getTestResource().withDependencyContainer(new KogitoPostgreSqlContainer()); + resource.withDependencyToService(JobServiceComposeResource.MAIN_SERVICE_ID, new KogitoPostgreSqlContainer()); + //resource.withSharedDependencyContainer("postgres", new KogitoPostgreSqlContainer()); break; case IN_MEMORY: default: //no persistence } if (annotation.kafkaEnabled()) { - getTestResource().withDependencyContainer(new KogitoKafkaContainer()); - getTestResource().getServiceContainers(JobServiceContainer.class).forEach(c -> c.addEnv("QUARKUS_PROFILE", "events-support")); + resource.withSharedDependencyContainer("kafka", new KogitoKafkaContainer()); + resource.getServiceContainers(JobServiceContainer.class).forEach(c -> c.addEnv("QUARKUS_PROFILE", "events-support")); } if (annotation.dataIndexEnabled()) { - getTestResource().withServiceContainer("data-index", new DataIndexInMemoryContainer()); + DataIndexPostgreSqlContainer container = new DataIndexPostgreSqlContainer(); + container.addProtoFileFolder(); + KogitoPostgreSqlContainer postgresql = new KogitoPostgreSqlContainer().withInitScript("data_index_create.sql"); + resource.withServiceContainer("data-index", container, postgresql); + } + } + + @Override + public void stop() { + resource.stop(); + } + + @Override + public Map start() { + resource.start(); + if (annotation.dataIndexEnabled()) { + DataIndexPostgreSqlContainer dataIndexContainer = resource.getServiceContainer("data-index"); + System.setProperty(DATA_INDEX_SERVICE_URL, "http://" + dataIndexContainer.getHost() + ":" + dataIndexContainer.getMappedPort()); } + Map properties = new HashMap<>(resource.getProperties()); + properties.put(JOBS_SERVICE_URL, "http://localhost:" + resource.getMappedPort()); + return properties; } } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java index ce75cdd722..158cb47351 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java @@ -42,10 +42,11 @@ public class JobServiceLeaderIT { @BeforeAll public static void init() { - resource = new JobServiceComposeResource() - .withServiceContainer("job-service-1", new JobServiceContainer()) - .withServiceContainer("job-service-2", new JobServiceContainer()) - .withDependencyContainer(new KogitoPostgreSqlContainer()); + KogitoPostgreSqlContainer postgreSqlContainer = new KogitoPostgreSqlContainer(); + resource = new JobServiceComposeResource(new JobServiceContainer()) + .withServiceContainer("job-service-1", new JobServiceContainer(), postgreSqlContainer) + .withServiceContainer("job-service-2", new JobServiceContainer(), postgreSqlContainer) + .withDependencyToService(JobServiceComposeResource.MAIN_SERVICE_ID, postgreSqlContainer); containers = resource.getServiceContainers(JobServiceContainer.class); //decrease the leader expiration timeout to 2 seconds to make the test quicker containers.stream().forEach(c -> c.withEnv("KOGITO_JOBS_SERVICE_MANAGEMENT_HEARTBEAT_EXPIRATION_IN_SECONDS", "2")); diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java index eadcd55de8..b1a1e14211 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java @@ -26,6 +26,7 @@ import static io.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; +import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; public abstract class BaseProcessTimerIT implements JobServiceHealthAware { @@ -47,6 +48,54 @@ public void testTimers() { assertThat(id).isEqualTo(id2); await().atMost(TIMEOUT) .untilAsserted(() -> getTimerWithStatusCode(id, 404, TIMERS)); + + if (dataIndexUrl() != null) { + //data index test + + String query = "{ \"query\" : " + + "\"{ProcessInstances (where : {" + + " id: {equal : \\\"" + id + "\\\" }" + + " }) {" + + " id,processId,state" + + " }" + + "}\"" + + "}"; + await() + .atMost(TIMEOUT) + .untilAsserted(() -> given() + .baseUri(dataIndexUrl()) + .contentType(ContentType.JSON) + //.body("{ \"query\" : \"{ProcessInstances{ id, processId, state } }\" }") + .body(query) + .when().post("/graphql") + .then().statusCode(200) + .body("data.ProcessInstances.size()", is(1)) + .body("data.ProcessInstances[0].id", is(id)) + .body("data.ProcessInstances[0].processId", is("timers")) + .body("data.ProcessInstances[0].state", is("COMPLETED"))); + + String queryJobs = "{ \"query\" : " + + "\"{Jobs (where : {" + + " processInstanceId: {equal : \\\"" + id + "\\\" }" + + " }) {" + + " status" + + " }" + + "}\"" + + "}"; + + given() + .baseUri(dataIndexUrl()) + .contentType(ContentType.JSON) + .body(queryJobs) + .when().post("/graphql") + .then().statusCode(200) + .body("data.Jobs.size()", is(1)) + .body("data.Jobs[0].status", is("EXECUTED")); + } + } + + public String dataIndexUrl() { + return null; } @Test diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java index f9ea89237f..cd8c9b0e4d 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java @@ -18,10 +18,14 @@ import java.text.MessageFormat; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.kie.kogito.testcontainers.KogitoGenericContainer; import org.kie.kogito.testcontainers.KogitoKafkaContainer; @@ -32,25 +36,44 @@ import org.testcontainers.containers.Network; import org.testcontainers.containers.wait.strategy.Wait; -public class JobServiceComposeResource extends AbstractJobServiceResource { +public class JobServiceComposeResource implements TestResource { private static final Logger LOGGER = LoggerFactory.getLogger(JobServiceComposeResource.class); - private final List> dependencyContainers; - private final Map serviceContainers; + public static final String MAIN_SERVICE_ID = "job-service-main"; + private final Map> sharedDependencyContainers; + private final Map> serviceContainers; - public JobServiceComposeResource() { - this.dependencyContainers = new ArrayList<>(); + private final Map>> dependencyContainers; + + private final KogitoGenericContainer mainContainer; + private Map properties; + + public JobServiceComposeResource(KogitoGenericContainer mainContainer) { + this.sharedDependencyContainers = new HashMap<>(); + this.dependencyContainers = new HashMap<>(); this.serviceContainers = new HashMap<>(); - withServiceContainer("job-service-main", jobService); + this.properties = new HashMap<>(); + this.mainContainer = mainContainer; + withServiceContainer(MAIN_SERVICE_ID, mainContainer); } - public JobServiceComposeResource withServiceContainer(String id, KogitoGenericContainer container) { + public JobServiceComposeResource withServiceContainer(String id, KogitoGenericContainer container, GenericContainer... dependency) { serviceContainers.put(id, container); + List> containers = dependencyContainers.getOrDefault(id, new ArrayList<>()); + containers.addAll(Arrays.asList(dependency)); + dependencyContainers.put(id, containers); + return this; + } + + public JobServiceComposeResource withDependencyToService(String serviceId, GenericContainer dependency) { + List> containers = dependencyContainers.getOrDefault(serviceId, new ArrayList<>()); + containers.add(dependency); + dependencyContainers.put(serviceId, containers); return this; } - public JobServiceComposeResource withDependencyContainer(GenericContainer container) { - dependencyContainers.add(container); + public JobServiceComposeResource withSharedDependencyContainer(String prefix, GenericContainer container) { + sharedDependencyContainers.put(prefix, container); return this; } @@ -58,28 +81,46 @@ public List getServiceContainers(Class type) { return serviceContainers.values().stream().filter(type::isInstance).map(type::cast).collect(Collectors.toList()); } + public > T getServiceContainer(String id) { + return (T) serviceContainers.get(id); + } + private String hostName(GenericContainer container) { return container.getContainerInfo().getConfig().getHostName(); } @Override public void start() { - LOGGER.info("Start JobService with {} test resources", dependencyContainers.stream().map(GenericContainer::getImage).collect(Collectors.toList())); - properties.clear(); - + LOGGER.info("Start JobService with {} test resources", sharedDependencyContainers.values().stream().map(GenericContainer::getImage).collect(Collectors.toList())); final Network network = Network.newNetwork(); - dependencyContainers.stream() + sharedDependencyContainers.values().stream() .map(c -> c.withNetwork(network)) .map(c -> c.waitingFor(Wait.forListeningPort())) .forEach(GenericContainer::start); - - configurePostgreSQL(); - configureKafka(); + //configurePostgreSQL(sharedDependencyContainers.values(), mainContainer); + configureKafka(sharedDependencyContainers.values(), serviceContainers.values().toArray(GenericContainer[]::new)); startServices(network); } protected void startServices(Network network) { - serviceContainers.values() + serviceContainers.entrySet() + .stream() + .map(entry -> { + List> dependencies = dependencyContainers.getOrDefault(entry.getKey(), Collections.emptyList()) + .stream() + .map(container -> container.withNetwork(network)) + .map(container -> { + if (!container.isRunning()) { + container.start(); + } + return container; + }) + .collect(Collectors.toList()); + configurePostgreSQL(dependencies, serviceContainers.get(entry.getKey())); + configureKafka(dependencies, serviceContainers.get(entry.getKey())); + return entry; + }) + .map(Map.Entry::getValue) .forEach(service -> { service.withNetwork(network); service.start(); @@ -87,8 +128,8 @@ protected void startServices(Network network) { }); } - protected void configureKafka() { - dependencyContainers.stream() + protected void configureKafka(Collection> containers, GenericContainer... services) { + containers.stream() .filter(KogitoKafkaContainer.class::isInstance) .map(KogitoKafkaContainer.class::cast) .findFirst() @@ -103,12 +144,12 @@ protected void configureKafka() { //internal access final String kafkaInternalUrl = hostName(kafka) + ":29092"; LOGGER.info("kafkaInternalURL: {}", kafkaInternalUrl); - serviceContainers.values().forEach(service -> service.addEnv("KAFKA_BOOTSTRAP_SERVERS", kafkaInternalUrl)); + Stream.of(services).forEach(service -> service.addEnv("KAFKA_BOOTSTRAP_SERVERS", kafkaInternalUrl)); }); } - protected void configurePostgreSQL() { - dependencyContainers.stream() + protected void configurePostgreSQL(Collection> containers, GenericContainer... services) { + containers.stream() .filter(KogitoPostgreSqlContainer.class::isInstance) .map(KogitoPostgreSqlContainer.class::cast) .findFirst() @@ -123,7 +164,7 @@ protected void configurePostgreSQL() { final String database = postgreSql.getDatabaseName(); final String reactiveUrl = MessageFormat.format(connectionTemplate, server, port, database); final String jdbcUrl = MessageFormat.format(jdbcConnectionTemplate, server, port, database); - serviceContainers.values() + Stream.of(services) .forEach(service -> { service.addEnv("QUARKUS_DATASOURCE_JDBC_URL", jdbcUrl); service.addEnv("QUARKUS_DATASOURCE_REACTIVE_URL", reactiveUrl); @@ -138,7 +179,22 @@ protected void configurePostgreSQL() { public void stop() { LOGGER.info("Stopping test resource"); serviceContainers.values().forEach(GenericContainer::stop); - dependencyContainers.forEach(GenericContainer::stop); + sharedDependencyContainers.values().forEach(GenericContainer::stop); + dependencyContainers.values().stream().flatMap(List::stream).forEach(GenericContainer::stop); LOGGER.info("Test resource stopped"); } + + @Override + public String getResourceName() { + return mainContainer.getContainerName(); + } + + @Override + public int getMappedPort() { + return mainContainer.getMappedPort(8080); + } + + public Map getProperties() { + return properties; + } } diff --git a/apps-integration-tests/integration-tests-jobs-service/pom.xml b/apps-integration-tests/integration-tests-jobs-service/pom.xml index 05ecdd7927..aa008b8ede 100644 --- a/apps-integration-tests/integration-tests-jobs-service/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/pom.xml @@ -53,30 +53,29 @@ - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - ${failsafe.include} - - - ${failsafe.exclude} - - - org.jboss.logmanager.LogManager - ${project.build.directory}/${project.build.finalName}-runner - ${container.image.jobs-service} - ${container.image.kafka} - - ${project.build.outputDirectory} - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -87,6 +86,7 @@ org.kie.kogito/jobs-service-postgresql:${project.version} + org.kie.kogito/data-index-service-postgresql:${project.version} org.kie.kogito/data-index-service-inmemory:${project.version} @@ -97,8 +97,12 @@ maven-failsafe-plugin + org.jboss.logmanager.LogManager + ${project.build.directory}/${project.build.finalName}-runner + ${container.image.kafka} + ${container.image.jobs-service} - ${container.image.data-index-service-inmemory} + ${container.image.data-index-service-postgresql} ${container.image.data-index-service-inmemory} From e330db4e939eb01c04600b889a14c227ea4c1df2 Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Mon, 7 Nov 2022 15:52:56 -0300 Subject: [PATCH 06/14] Adjustments to centralize JosServiceCompose --- .../JobServiceComposeQuarkusTestResource.java | 11 +++++++---- .../org/kie/kogito/it/jobs/JobServiceLeaderIT.java | 8 ++++---- ...mposeResource.java => ComposeTestResource.java} | 14 +++++++------- .../pom.xml | 4 ---- 4 files changed, 18 insertions(+), 19 deletions(-) rename apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/{JobServiceComposeResource.java => ComposeTestResource.java} (93%) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java index 781338b7d1..2c9c287299 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java @@ -32,10 +32,10 @@ public class JobServiceComposeQuarkusTestResource implements QuarkusTestResource private JobServiceTestResource annotation; - private JobServiceComposeResource resource; + private ComposeTestResource resource; public JobServiceComposeQuarkusTestResource() { - resource = new JobServiceComposeResource(new JobServiceContainer()); + resource = new ComposeTestResource(new JobServiceContainer()); } @Override @@ -43,7 +43,7 @@ public void init(JobServiceTestResource annotation) { this.annotation = annotation; switch (annotation.persistence()) { case POSTGRESQL: - resource.withDependencyToService(JobServiceComposeResource.MAIN_SERVICE_ID, new KogitoPostgreSqlContainer()); + resource.withDependencyToService(ComposeTestResource.MAIN_SERVICE_ID, new KogitoPostgreSqlContainer()); //resource.withSharedDependencyContainer("postgres", new KogitoPostgreSqlContainer()); break; case IN_MEMORY: @@ -70,12 +70,15 @@ public void stop() { @Override public Map start() { resource.start(); + Map properties = new HashMap<>(resource.getProperties()); if (annotation.dataIndexEnabled()) { DataIndexPostgreSqlContainer dataIndexContainer = resource.getServiceContainer("data-index"); System.setProperty(DATA_INDEX_SERVICE_URL, "http://" + dataIndexContainer.getHost() + ":" + dataIndexContainer.getMappedPort()); + properties.put(DATA_INDEX_SERVICE_URL, "http://" + dataIndexContainer.getHost() + ":" + dataIndexContainer.getMappedPort()); } - Map properties = new HashMap<>(resource.getProperties()); + System.setProperty(JOBS_SERVICE_URL, "http://localhost:" + resource.getMappedPort()); properties.put(JOBS_SERVICE_URL, "http://localhost:" + resource.getMappedPort()); + return properties; } } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java index 158cb47351..32b9eb7de9 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.kie.kogito.test.resources.JobServiceComposeResource; +import org.kie.kogito.test.resources.ComposeTestResource; import org.kie.kogito.testcontainers.JobServiceContainer; import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer; import org.slf4j.Logger; @@ -35,7 +35,7 @@ public class JobServiceLeaderIT { - private static JobServiceComposeResource resource; + private static ComposeTestResource resource; private final static Logger logger = LoggerFactory.getLogger(JobServiceLeaderIT.class); private static List containers; @@ -43,10 +43,10 @@ public class JobServiceLeaderIT { @BeforeAll public static void init() { KogitoPostgreSqlContainer postgreSqlContainer = new KogitoPostgreSqlContainer(); - resource = new JobServiceComposeResource(new JobServiceContainer()) + resource = new ComposeTestResource(new JobServiceContainer()) .withServiceContainer("job-service-1", new JobServiceContainer(), postgreSqlContainer) .withServiceContainer("job-service-2", new JobServiceContainer(), postgreSqlContainer) - .withDependencyToService(JobServiceComposeResource.MAIN_SERVICE_ID, postgreSqlContainer); + .withDependencyToService(ComposeTestResource.MAIN_SERVICE_ID, postgreSqlContainer); containers = resource.getServiceContainers(JobServiceContainer.class); //decrease the leader expiration timeout to 2 seconds to make the test quicker containers.stream().forEach(c -> c.withEnv("KOGITO_JOBS_SERVICE_MANAGEMENT_HEARTBEAT_EXPIRATION_IN_SECONDS", "2")); diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/ComposeTestResource.java similarity index 93% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/ComposeTestResource.java index cd8c9b0e4d..7956ef27c2 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceComposeResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/ComposeTestResource.java @@ -36,10 +36,10 @@ import org.testcontainers.containers.Network; import org.testcontainers.containers.wait.strategy.Wait; -public class JobServiceComposeResource implements TestResource { +public class ComposeTestResource implements TestResource { - private static final Logger LOGGER = LoggerFactory.getLogger(JobServiceComposeResource.class); - public static final String MAIN_SERVICE_ID = "job-service-main"; + private static final Logger LOGGER = LoggerFactory.getLogger(ComposeTestResource.class); + public static final String MAIN_SERVICE_ID = "job-service-main";//fixme private final Map> sharedDependencyContainers; private final Map> serviceContainers; @@ -48,7 +48,7 @@ public class JobServiceComposeResource implements TestResource { private final KogitoGenericContainer mainContainer; private Map properties; - public JobServiceComposeResource(KogitoGenericContainer mainContainer) { + public ComposeTestResource(KogitoGenericContainer mainContainer) { this.sharedDependencyContainers = new HashMap<>(); this.dependencyContainers = new HashMap<>(); this.serviceContainers = new HashMap<>(); @@ -57,7 +57,7 @@ public JobServiceComposeResource(KogitoGenericContainer mainContainer) { withServiceContainer(MAIN_SERVICE_ID, mainContainer); } - public JobServiceComposeResource withServiceContainer(String id, KogitoGenericContainer container, GenericContainer... dependency) { + public ComposeTestResource withServiceContainer(String id, KogitoGenericContainer container, GenericContainer... dependency) { serviceContainers.put(id, container); List> containers = dependencyContainers.getOrDefault(id, new ArrayList<>()); containers.addAll(Arrays.asList(dependency)); @@ -65,14 +65,14 @@ public JobServiceComposeResource withServiceContainer(String id, KogitoGenericCo return this; } - public JobServiceComposeResource withDependencyToService(String serviceId, GenericContainer dependency) { + public ComposeTestResource withDependencyToService(String serviceId, GenericContainer dependency) { List> containers = dependencyContainers.getOrDefault(serviceId, new ArrayList<>()); containers.add(dependency); dependencyContainers.put(serviceId, containers); return this; } - public JobServiceComposeResource withSharedDependencyContainer(String prefix, GenericContainer container) { + public ComposeTestResource withSharedDependencyContainer(String prefix, GenericContainer container) { sharedDependencyContainers.put(prefix, container); return this; } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml index 8f7b60f450..6dc2637ce1 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml @@ -17,10 +17,6 @@ org.kie.kogito kogito-addons-quarkus-jobs-messaging - - io.quarkus - quarkus-smallrye-reactive-messaging-kafka - org.kie.kogito From d901a80470f377e285a7052a5f98912ebb1be9af Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Mon, 7 Nov 2022 17:53:09 -0300 Subject: [PATCH 07/14] removing uncessary code and addin ddl form data index --- ...AbstractJobServiceQuarkusTestResource.java | 38 ---- .../JobServiceComposeQuarkusTestResource.java | 2 +- .../resources/AbstractJobServiceResource.java | 50 ----- .../resources/JobServiceKafkaResource.java | 65 ------ .../test/resources/JobServiceResource.java | 40 ---- .../testcontainers/JobServiceContainer.java | 17 -- .../pom.xml | 21 ++ .../src/main/resources/data_index_create.sql | 208 ------------------ 8 files changed, 22 insertions(+), 419 deletions(-) delete mode 100644 apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceQuarkusTestResource.java delete mode 100644 apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceResource.java delete mode 100644 apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceKafkaResource.java delete mode 100644 apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceResource.java delete mode 100644 apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/data_index_create.sql diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceQuarkusTestResource.java deleted file mode 100644 index 3167176d4b..0000000000 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceQuarkusTestResource.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2022 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.kie.kogito.test.resources; - -import java.util.HashMap; -import java.util.Map; - -public abstract class AbstractJobServiceQuarkusTestResource extends ConditionalQuarkusTestResource { - - protected final String serviceUrlProperty; - - protected AbstractJobServiceQuarkusTestResource(String serviceUrlProperty, T jobServiceResource) { - super(jobServiceResource); - this.serviceUrlProperty = serviceUrlProperty; - } - - @Override - protected Map getProperties() { - Map properties = new HashMap<>(); - properties.put(serviceUrlProperty, "http://localhost:" + getTestResource().getMappedPort()); - properties.putAll(getTestResource().getProperties()); - return properties; - } -} diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java index 2c9c287299..3383115b39 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java @@ -57,7 +57,7 @@ public void init(JobServiceTestResource annotation) { if (annotation.dataIndexEnabled()) { DataIndexPostgreSqlContainer container = new DataIndexPostgreSqlContainer(); container.addProtoFileFolder(); - KogitoPostgreSqlContainer postgresql = new KogitoPostgreSqlContainer().withInitScript("data_index_create.sql"); + KogitoPostgreSqlContainer postgresql = new KogitoPostgreSqlContainer().withInitScript("data_index_postgresql_create.sql"); resource.withServiceContainer("data-index", container, postgresql); } } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceResource.java deleted file mode 100644 index 88a95ac58e..0000000000 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/AbstractJobServiceResource.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2022 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.kie.kogito.test.resources; - -import java.util.HashMap; -import java.util.Map; - -import org.kie.kogito.testcontainers.JobServiceContainer; - -public abstract class AbstractJobServiceResource implements TestResource { - - protected final JobServiceContainer jobService; - protected final Map properties = new HashMap<>(); - - public AbstractJobServiceResource() { - this(new JobServiceContainer()); - } - - public AbstractJobServiceResource(JobServiceContainer jobService) { - this.jobService = jobService; - } - - @Override - public String getResourceName() { - return jobService.getResourceName(); - } - - @Override - public int getMappedPort() { - return jobService.getMappedPort(); - } - - public Map getProperties() { - return properties; - } -} diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceKafkaResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceKafkaResource.java deleted file mode 100644 index 06da5c5bae..0000000000 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceKafkaResource.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2022 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.kie.kogito.test.resources; - -import org.kie.kogito.testcontainers.KogitoKafkaContainer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testcontainers.containers.Network; -import org.testcontainers.containers.wait.strategy.Wait; - -public class JobServiceKafkaResource extends AbstractJobServiceResource { - - private static final Logger LOGGER = LoggerFactory.getLogger(JobServiceKafkaResource.class); - - private final KogitoKafkaContainer kafka = new KogitoKafkaContainer(); - - @Override - public void start() { - LOGGER.info("Start JobServiceKafka test resource"); - properties.clear(); - LOGGER.info("Start Kafka"); - Network network = Network.newNetwork(); - kafka.withNetwork(network); - kafka.withNetworkAliases("kafka"); - kafka.waitingFor(Wait.forListeningPort()); - kafka.start(); - // external access url - String kafkaURL = kafka.getBootstrapServers(); - LOGGER.info("kafkaURL: {}", kafka.getBootstrapServers()); - // internal access url - String kafkaInternalUrl = "kafka:29092"; - LOGGER.info("kafkaInternalURL: {}", kafkaInternalUrl); - properties.put("kafka.bootstrap.servers", kafkaURL); - properties.put("spring.kafka.bootstrap-servers", kafkaURL); - properties.put("quarkus.profile", "events-support"); - - jobService.withNetwork(network); - jobService.setKafkaURL(kafkaInternalUrl); - jobService.setQuarkusProfile("events-support"); - jobService.start(); - LOGGER.info("JobServiceKafka test resource started"); - } - - @Override - public void stop() { - LOGGER.info("Stop JobServiceKafka test resource"); - jobService.stop(); - kafka.stop(); - LOGGER.info("JobServiceKafka test resource stopped"); - } -} diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceResource.java deleted file mode 100644 index 210cd03f0a..0000000000 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/JobServiceResource.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2022 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.kie.kogito.test.resources; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class JobServiceResource extends AbstractJobServiceResource { - - private static final Logger LOGGER = LoggerFactory.getLogger(JobServiceResource.class); - - @Override - public void start() { - LOGGER.info("Start JobService test resource"); - properties.clear(); - jobService.start(); - LOGGER.info("JobService test resource started"); - } - - @Override - public void stop() { - LOGGER.info("Stop JobService test resource"); - jobService.stop(); - LOGGER.info("JobService test resource stopped"); - } -} \ No newline at end of file diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/testcontainers/JobServiceContainer.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/testcontainers/JobServiceContainer.java index 494c1c08af..da8b4fb050 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/testcontainers/JobServiceContainer.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/testcontainers/JobServiceContainer.java @@ -26,7 +26,6 @@ public class JobServiceContainer extends KogitoGenericContainer + + + + + com.coderplus.maven.plugins + copy-rename-maven-plugin + + + copy-postgresql-file + generate-sources + + copy + + + ${project.root.dir}/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/data_index_create.sql + ${project.basedir}/target/classes/data_index_postgresql_create.sql + + + + + diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/data_index_create.sql b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/data_index_create.sql deleted file mode 100644 index 1f62c2b9c2..0000000000 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/data_index_create.sql +++ /dev/null @@ -1,208 +0,0 @@ - - create table attachments ( - id varchar(255) not null, - content varchar(255), - name varchar(255), - updated_at timestamp, - updated_by varchar(255), - task_id varchar(255) not null, - primary key (id) - ); - - create table comments ( - id varchar(255) not null, - content varchar(255), - updated_at timestamp, - updated_by varchar(255), - task_id varchar(255) not null, - primary key (id) - ); - - create table jobs ( - id varchar(255) not null, - callback_endpoint varchar(255), - endpoint varchar(255), - execution_counter int4, - expiration_time timestamp, - last_update timestamp, - node_instance_id varchar(255), - priority int4, - process_id varchar(255), - process_instance_id varchar(255), - repeat_interval int8, - repeat_limit int4, - retries int4, - root_process_id varchar(255), - root_process_instance_id varchar(255), - scheduled_id varchar(255), - status varchar(255), - primary key (id) - ); - - create table milestones ( - id varchar(255) not null, - process_instance_id varchar(255) not null, - name varchar(255), - status varchar(255), - primary key (id, process_instance_id) - ); - - create table nodes ( - id varchar(255) not null, - definition_id varchar(255), - enter timestamp, - exit timestamp, - name varchar(255), - node_id varchar(255), - type varchar(255), - process_instance_id varchar(255) not null, - primary key (id) - ); - - create table processes ( - id varchar(255) not null, - business_key varchar(255), - end_time timestamp, - endpoint varchar(255), - message varchar(255), - node_definition_id varchar(255), - last_update_time timestamp, - parent_process_instance_id varchar(255), - process_id varchar(255), - process_name varchar(255), - root_process_id varchar(255), - root_process_instance_id varchar(255), - start_time timestamp, - state int4, - variables jsonb, - primary key (id) - ); - - create table processes_addons ( - process_id varchar(255) not null, - addon varchar(255) not null, - primary key (process_id, addon) - ); - - create table processes_roles ( - process_id varchar(255) not null, - role varchar(255) not null, - primary key (process_id, role) - ); - - create table tasks ( - id varchar(255) not null, - actual_owner varchar(255), - completed timestamp, - description varchar(255), - endpoint varchar(255), - inputs jsonb, - last_update timestamp, - name varchar(255), - outputs jsonb, - priority varchar(255), - process_id varchar(255), - process_instance_id varchar(255), - reference_name varchar(255), - root_process_id varchar(255), - root_process_instance_id varchar(255), - started timestamp, - state varchar(255), - primary key (id) - ); - - create table tasks_admin_groups ( - task_id varchar(255) not null, - group_id varchar(255) not null, - primary key (task_id, group_id) - ); - - create table tasks_admin_users ( - task_id varchar(255) not null, - user_id varchar(255) not null, - primary key (task_id, user_id) - ); - - create table tasks_excluded_users ( - task_id varchar(255) not null, - user_id varchar(255) not null, - primary key (task_id, user_id) - ); - - create table tasks_potential_groups ( - task_id varchar(255) not null, - group_id varchar(255) not null, - primary key (task_id, group_id) - ); - - create table tasks_potential_users ( - task_id varchar(255) not null, - user_id varchar(255) not null, - primary key (task_id, user_id) - ); - - alter table if exists attachments - add constraint fk_attachments_tasks - foreign key (task_id) - references tasks - on delete cascade; - - alter table if exists comments - add constraint fk_comments_tasks - foreign key (task_id) - references tasks - on delete cascade; - - alter table if exists milestones - add constraint fk_milestones_process - foreign key (process_instance_id) - references processes - on delete cascade; - - alter table if exists nodes - add constraint fk_nodes_process - foreign key (process_instance_id) - references processes - on delete cascade; - - alter table if exists processes_addons - add constraint fk_processes_addons_processes - foreign key (process_id) - references processes - on delete cascade; - - alter table if exists processes_roles - add constraint fk_processes_roles_processes - foreign key (process_id) - references processes - on delete cascade; - - alter table if exists tasks_admin_groups - add constraint fk_tasks_admin_groups_tasks - foreign key (task_id) - references tasks - on delete cascade; - - alter table if exists tasks_admin_users - add constraint fk_tasks_admin_users_tasks - foreign key (task_id) - references tasks - on delete cascade; - - alter table if exists tasks_excluded_users - add constraint fk_tasks_excluded_users_tasks - foreign key (task_id) - references tasks - on delete cascade; - - alter table if exists tasks_potential_groups - add constraint fk_tasks_potential_groups_tasks - foreign key (task_id) - references tasks - on delete cascade; - - alter table if exists tasks_potential_users - add constraint fk_tasks_potential_users_tasks - foreign key (task_id) - references tasks - on delete cascade; From 812110b39a7efdf47910af348e21a2c8ff56b119 Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Tue, 8 Nov 2022 09:50:00 -0300 Subject: [PATCH 08/14] adjusting spring boot IT to use in-memory jobservice container --- .../integration-tests-jobs-service-springboot/pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/pom.xml index 3a9e00f463..a200cd65f8 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-springboot/pom.xml @@ -123,6 +123,9 @@ maven-failsafe-plugin ${skip.springboot} + + org.kie.kogito/jobs-service-common:${project.version} + From 8059dd8aca8d276512d70b7af7b33acc14743cac Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Tue, 8 Nov 2022 15:56:42 -0300 Subject: [PATCH 09/14] moving quarkus common module and adding more data index tests --- .../kogito/it/jobs/BaseProcessTimerIT.java | 51 +++++++++++-------- .../pom.xml | 11 ++-- .../it/jobs/BaseCallbackStateTimeoutsIT.java | 0 .../it/jobs/BaseSwitchStateTimeoutsIT.java | 0 .../jobs/KafkaBaseSwitchStateTimeoutsIT.java | 0 .../JobServiceComposeQuarkusTestResource.java | 0 .../resources/JobServiceTestResource.java | 0 ...oServiceRandomPortQuarkusTestResource.java | 0 .../kogito/it/jobs/JobServiceLeaderIT.java | 0 .../pom.xml | 17 +++++++ .../pom.xml | 17 +++++++ .../pom.xml | 17 ++++++- .../pom.xml | 33 +----------- .../integration-tests-jobs-service/pom.xml | 34 +------------ 14 files changed, 87 insertions(+), 93 deletions(-) rename apps-integration-tests/integration-tests-jobs-service/{ => integration-tests-jobs-service-quarkus}/integration-tests-jobs-service-common-quarkus/pom.xml (97%) rename apps-integration-tests/integration-tests-jobs-service/{ => integration-tests-jobs-service-quarkus}/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseCallbackStateTimeoutsIT.java (100%) rename apps-integration-tests/integration-tests-jobs-service/{ => integration-tests-jobs-service-quarkus}/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseSwitchStateTimeoutsIT.java (100%) rename apps-integration-tests/integration-tests-jobs-service/{ => integration-tests-jobs-service-quarkus}/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/KafkaBaseSwitchStateTimeoutsIT.java (100%) rename apps-integration-tests/integration-tests-jobs-service/{ => integration-tests-jobs-service-quarkus}/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java (100%) rename apps-integration-tests/integration-tests-jobs-service/{ => integration-tests-jobs-service-quarkus}/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java (100%) rename apps-integration-tests/integration-tests-jobs-service/{ => integration-tests-jobs-service-quarkus}/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/KogitoServiceRandomPortQuarkusTestResource.java (100%) rename apps-integration-tests/integration-tests-jobs-service/{ => integration-tests-jobs-service-quarkus}/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java (100%) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java index b1a1e14211..f85f9e8ae4 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java @@ -48,13 +48,27 @@ public void testTimers() { assertThat(id).isEqualTo(id2); await().atMost(TIMEOUT) .untilAsserted(() -> getTimerWithStatusCode(id, 404, TIMERS)); + assertJobsAndProcessOnDataIndex(TIMERS, id, "COMPLETED", "EXECUTED"); + } - if (dataIndexUrl() != null) { - //data index test + public String dataIndexUrl() { + return null; + } + + @Test + public void testCancelTimer() { + String id = createTimer(new RequestPayload("PT030S"), TIMERS); + Object id2 = deleteTimer(id, TIMERS); + assertThat(id).isEqualTo(id2); + getTimerWithStatusCode(id, 404, TIMERS); + assertJobsAndProcessOnDataIndex(TIMERS, id, "ABORTED", "CANCELED"); + } + private void assertJobsAndProcessOnDataIndex(String processId, String processInstanceId, String processStatus, String jobStatus) { + if (dataIndexUrl() != null) { String query = "{ \"query\" : " + "\"{ProcessInstances (where : {" + - " id: {equal : \\\"" + id + "\\\" }" + + " id: {equal : \\\"" + processInstanceId + "\\\" }" + " }) {" + " id,processId,state" + " }" + @@ -65,18 +79,17 @@ public void testTimers() { .untilAsserted(() -> given() .baseUri(dataIndexUrl()) .contentType(ContentType.JSON) - //.body("{ \"query\" : \"{ProcessInstances{ id, processId, state } }\" }") .body(query) .when().post("/graphql") .then().statusCode(200) .body("data.ProcessInstances.size()", is(1)) - .body("data.ProcessInstances[0].id", is(id)) - .body("data.ProcessInstances[0].processId", is("timers")) - .body("data.ProcessInstances[0].state", is("COMPLETED"))); + .body("data.ProcessInstances[0].id", is(processInstanceId)) + .body("data.ProcessInstances[0].processId", is(processId)) + .body("data.ProcessInstances[0].state", is(processStatus))); String queryJobs = "{ \"query\" : " + "\"{Jobs (where : {" + - " processInstanceId: {equal : \\\"" + id + "\\\" }" + + " processInstanceId: {equal : \\\"" + processInstanceId + "\\\" }" + " }) {" + " status" + " }" + @@ -90,22 +103,10 @@ public void testTimers() { .when().post("/graphql") .then().statusCode(200) .body("data.Jobs.size()", is(1)) - .body("data.Jobs[0].status", is("EXECUTED")); + .body("data.Jobs[0].status", is(jobStatus)); } } - public String dataIndexUrl() { - return null; - } - - @Test - public void testCancelTimer() { - String id = createTimer(new RequestPayload("PT030S"), TIMERS); - Object id2 = deleteTimer(id, TIMERS); - assertThat(id).isEqualTo(id2); - getTimerWithStatusCode(id, 404, TIMERS); - } - //Cycle Timers Tests @Test public void testTimerCycle() { @@ -113,7 +114,8 @@ public void testTimerCycle() { String id2 = getTimerById(id, TIMERS_CYCLE); assertThat(id).isEqualTo(id2); await().atMost(TIMEOUT) - .untilAsserted(() -> getTimerWithStatusCode(id, 404, TIMERS)); + .untilAsserted(() -> getTimerWithStatusCode(id, 404, TIMERS_CYCLE)); + assertJobsAndProcessOnDataIndex(TIMERS_CYCLE, id, "COMPLETED", "EXECUTED"); } @Test @@ -122,6 +124,9 @@ public void testDeleteTimerCycle() { String id2 = getTimerById(id, TIMERS_CYCLE); assertThat(id).isEqualTo(id2); deleteTimer(id, TIMERS_CYCLE); + await().atMost(TIMEOUT) + .untilAsserted(() -> getTimerWithStatusCode(id, 404, TIMERS_CYCLE)); + assertJobsAndProcessOnDataIndex(TIMERS_CYCLE, id, "ABORTED", "CANCELED"); } //Boundary Timers Tests @@ -132,6 +137,7 @@ public void testBoundaryTimersOnTask() { assertThat(id).isEqualTo(id2); await().atMost(TIMEOUT) .untilAsserted(() -> getTimerWithStatusCode(id, 404, TIMERS_ON_TASK)); + assertJobsAndProcessOnDataIndex(TIMERS_ON_TASK, id, "COMPLETED", "EXECUTED"); } @Test @@ -140,6 +146,7 @@ public void testDeleteBoundaryTimersOnTask() { String id2 = getTimerById(id, TIMERS_ON_TASK); assertThat(id).isEqualTo(id2); deleteTimer(id, TIMERS_ON_TASK); + assertJobsAndProcessOnDataIndex(TIMERS_ON_TASK, id, "ABORTED", "CANCELED"); } private ValidatableResponse getTimerWithStatusCode(String id, int code, String path) { diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/pom.xml similarity index 97% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/pom.xml rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/pom.xml index 574adf294e..24004998ef 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/pom.xml @@ -5,9 +5,10 @@ 4.0.0 - org.kie.kogito integration-tests-jobs-service + org.kie.kogito 2.0.0-SNAPSHOT + ../../pom.xml integration-tests-jobs-service-common-quarkus @@ -22,15 +23,13 @@ org.kie.kogito - integration-tests-jobs-service-common + integration-tests-data-index-service-common + ${project.version} - org.kie.kogito - integration-tests-data-index-service-common - ${project.version} + integration-tests-jobs-service-common - org.kie.kogito kogito-quarkus-test-utils diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseCallbackStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseCallbackStateTimeoutsIT.java similarity index 100% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseCallbackStateTimeoutsIT.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseCallbackStateTimeoutsIT.java diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseSwitchStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseSwitchStateTimeoutsIT.java similarity index 100% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseSwitchStateTimeoutsIT.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseSwitchStateTimeoutsIT.java diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/KafkaBaseSwitchStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/KafkaBaseSwitchStateTimeoutsIT.java similarity index 100% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/KafkaBaseSwitchStateTimeoutsIT.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/KafkaBaseSwitchStateTimeoutsIT.java diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java similarity index 100% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java similarity index 100% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/KogitoServiceRandomPortQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/KogitoServiceRandomPortQuarkusTestResource.java similarity index 100% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/KogitoServiceRandomPortQuarkusTestResource.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/KogitoServiceRandomPortQuarkusTestResource.java diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java similarity index 100% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/pom.xml index 668477939f..5ddcc1f9c0 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/pom.xml @@ -25,6 +25,23 @@ + + + io.quarkus + quarkus-maven-plugin + ${version.io.quarkus} + + true + + + + + build + + + + + src/main/resources diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/pom.xml index 59cd6be67d..92cb8651e2 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/pom.xml @@ -20,6 +20,23 @@ + + + io.quarkus + quarkus-maven-plugin + ${version.io.quarkus} + + true + + + + + build + + + + + src/main/resources diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml index ee9364651e..3f773747ba 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml @@ -48,8 +48,23 @@ - + + io.quarkus + quarkus-maven-plugin + ${version.io.quarkus} + + true + + + + + build + + + + + com.coderplus.maven.plugins copy-rename-maven-plugin diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml index d421a46777..b6f2bce395 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml @@ -85,40 +85,9 @@ + integration-tests-jobs-service-common-quarkus integration-tests-jobs-service-quarkus-management integration-tests-jobs-service-quarkus-messaging integration-tests-jobs-service-quarkus-knative-eventing - - - - - io.quarkus - quarkus-maven-plugin - ${version.io.quarkus} - - true - - - - - build - - - - - - - - - - - - - - - - - - diff --git a/apps-integration-tests/integration-tests-jobs-service/pom.xml b/apps-integration-tests/integration-tests-jobs-service/pom.xml index aa008b8ede..4117767c6c 100644 --- a/apps-integration-tests/integration-tests-jobs-service/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/pom.xml @@ -16,7 +16,6 @@ integration-tests-jobs-service-common - integration-tests-jobs-service-common-quarkus integration-tests-jobs-service-quarkus integration-tests-jobs-service-springboot @@ -40,7 +39,7 @@ org.kie.kogito - jobs-service-common + jobs-service ${project.version} pom provided @@ -53,41 +52,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - common + postgresql true - org.kie.kogito/jobs-service-postgresql:${project.version} org.kie.kogito/data-index-service-postgresql:${project.version} - org.kie.kogito/data-index-service-inmemory:${project.version} @@ -100,10 +73,8 @@ org.jboss.logmanager.LogManager ${project.build.directory}/${project.build.finalName}-runner ${container.image.kafka} - ${container.image.jobs-service} ${container.image.data-index-service-postgresql} - ${container.image.data-index-service-inmemory} @@ -111,5 +82,4 @@ - From c024e3ffd949681ba5d656bc52021bd8a998bd8a Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Wed, 9 Nov 2022 12:21:09 -0300 Subject: [PATCH 10/14] adding more IT with data index, fix repetitive timers --- .../java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java | 9 +++++---- .../kogito/jobs/service/executor/HttpJobExecutor.java | 4 ++-- .../org/kie/kogito/jobs/service/model/ScheduledJob.java | 1 - .../jobs/service/model/job/ScheduledJobAdapter.java | 2 +- .../jobs/service/executor/HttpJobExecutorTest.java | 5 ++--- .../jobs/service/model/job/ScheduledJobAdapterTest.java | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java index f85f9e8ae4..c6c878c46b 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java @@ -43,7 +43,7 @@ public abstract class BaseProcessTimerIT implements JobServiceHealthAware { //Timers Tests @Test public void testTimers() { - String id = createTimer(new RequestPayload("PT02S"), TIMERS); + String id = createTimer(new RequestPayload("PT01S"), TIMERS); Object id2 = getTimerById(id, TIMERS); assertThat(id).isEqualTo(id2); await().atMost(TIMEOUT) @@ -120,19 +120,20 @@ public void testTimerCycle() { @Test public void testDeleteTimerCycle() { - String id = createTimer(new RequestPayload("R20/PT1S"), TIMERS_CYCLE); + String id = createTimer(new RequestPayload("R20/PT10S"), TIMERS_CYCLE); String id2 = getTimerById(id, TIMERS_CYCLE); assertThat(id).isEqualTo(id2); deleteTimer(id, TIMERS_CYCLE); await().atMost(TIMEOUT) .untilAsserted(() -> getTimerWithStatusCode(id, 404, TIMERS_CYCLE)); - assertJobsAndProcessOnDataIndex(TIMERS_CYCLE, id, "ABORTED", "CANCELED"); + await().atMost(TIMEOUT) + .untilAsserted(() -> assertJobsAndProcessOnDataIndex(TIMERS_CYCLE, id, "ABORTED", "CANCELED")); } //Boundary Timers Tests @Test public void testBoundaryTimersOnTask() { - String id = createTimer(new RequestPayload("PT02S"), TIMERS_ON_TASK); + String id = createTimer(new RequestPayload("PT01S"), TIMERS_ON_TASK); String id2 = getTimerById(id, TIMERS_ON_TASK); assertThat(id).isEqualTo(id2); await().atMost(TIMEOUT) diff --git a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/executor/HttpJobExecutor.java b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/executor/HttpJobExecutor.java index f092d55800..fbd51de927 100644 --- a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/executor/HttpJobExecutor.java +++ b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/executor/HttpJobExecutor.java @@ -143,7 +143,7 @@ private HTTPRequestCallback buildCallbackRequest(String callbackEndpoint, String private String getLimit(JobDetails job) { return Optional.ofNullable(job.getTrigger()) .filter(IntervalTrigger.class::isInstance) - .map(interval -> getRepeatableJobCountDown(job)) + .map(limit -> getRepeatableJobCountDown(job)) .map(String::valueOf) .orElse(null); } @@ -158,7 +158,7 @@ private String getCallbackEndpoint(JobDetails job) { private int getRepeatableJobCountDown(JobDetails job) { IntervalTrigger trigger = (IntervalTrigger) job.getTrigger(); - return trigger.getRepeatLimit() - trigger.getRepeatCount(); + return trigger.getRepeatLimit() - trigger.getRepeatCount() - 1;//since repeatCount is init with 1 } WebClient getClient() { diff --git a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/model/ScheduledJob.java b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/model/ScheduledJob.java index 5de3d1eb80..e6723c8f86 100644 --- a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/model/ScheduledJob.java +++ b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/model/ScheduledJob.java @@ -229,7 +229,6 @@ public ScheduledJob build() { instance.retries = retries; instance.status = status; instance.lastUpdate = getLastUpdate(); - instance.executionResponse = executionResponse; instance.executionCounter = executionCounter; instance.executionResponse = executionResponse; return instance; diff --git a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/model/job/ScheduledJobAdapter.java b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/model/job/ScheduledJobAdapter.java index 6999832f69..6597c3a5a3 100644 --- a/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/model/job/ScheduledJobAdapter.java +++ b/jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/model/job/ScheduledJobAdapter.java @@ -112,7 +112,7 @@ public static Trigger triggerAdapter(ScheduledJob scheduledJob) { . map(interval -> new IntervalTrigger(0l, toDate(scheduledJob.getExpirationTime()), null, - scheduledJob.getRepeatLimit() + 1, //IntervalTrigger uses repeatCount >= repeatLimit + scheduledJob.getRepeatLimit(), 0, interval, null, diff --git a/jobs-service/jobs-service-common/src/test/java/org/kie/kogito/jobs/service/executor/HttpJobExecutorTest.java b/jobs-service/jobs-service-common/src/test/java/org/kie/kogito/jobs/service/executor/HttpJobExecutorTest.java index 79f7672a77..d62657857b 100644 --- a/jobs-service/jobs-service-common/src/test/java/org/kie/kogito/jobs/service/executor/HttpJobExecutorTest.java +++ b/jobs-service/jobs-service-common/src/test/java/org/kie/kogito/jobs/service/executor/HttpJobExecutorTest.java @@ -84,10 +84,9 @@ void testExecutePeriodic(@Mock HttpRequest request, @Mock MultiMap param .id(JOB_ID) .recipient(new Recipient.HTTPRecipient(ENDPOINT)) .trigger(ScheduledJobAdapter.intervalTrigger(DateUtil.now(), 10, 1)) - .executionCounter(1).build(); - + .build(); Map queryParams = assertExecuteAndReturnQueryParams(request, params, scheduledJob, false); - assertThat(queryParams).hasSize(1).containsEntry("limit", "9"); + assertThat(queryParams).hasSize(1).containsEntry("limit", "8");//repeatCount is init in 1 } private Map assertExecuteAndReturnQueryParams(@Mock HttpRequest request, @Mock MultiMap params, diff --git a/jobs-service/jobs-service-common/src/test/java/org/kie/kogito/jobs/service/model/job/ScheduledJobAdapterTest.java b/jobs-service/jobs-service-common/src/test/java/org/kie/kogito/jobs/service/model/job/ScheduledJobAdapterTest.java index cc8f6be0e7..d2dc8484ba 100644 --- a/jobs-service/jobs-service-common/src/test/java/org/kie/kogito/jobs/service/model/job/ScheduledJobAdapterTest.java +++ b/jobs-service/jobs-service-common/src/test/java/org/kie/kogito/jobs/service/model/job/ScheduledJobAdapterTest.java @@ -95,7 +95,7 @@ void testToJobDetailsInterval() { assertThat(jobDetails.getTrigger()).isInstanceOf(IntervalTrigger.class); IntervalTrigger intervalTrigger = (IntervalTrigger) jobDetails.getTrigger(); assertThat(intervalTrigger.getNextFireTime()).isEqualTo(DateUtil.toDate(TIME)); - assertThat(intervalTrigger.getRepeatLimit()).isEqualTo(REPEAT_LIMIT + 1); + assertThat(intervalTrigger.getRepeatLimit()).isEqualTo(REPEAT_LIMIT); assertThat(intervalTrigger.getPeriod()).isEqualTo(INTERVAL); } From 7af2987e416df475ab4b8db95ac34f0f2075eea3 Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Wed, 16 Nov 2022 11:53:48 -0300 Subject: [PATCH 11/14] applying pr comments --- .../kogito/it/jobs/BaseProcessTimerIT.java | 57 +++---------------- .../java/org/kie/kogito/test/TestUtils.java | 46 +++++++++++++++ ...source.java => CompositeTestResource.java} | 43 ++++++-------- ...bServiceCompositeQuarkusTestResource.java} | 10 ++-- .../resources/JobServiceTestResource.java | 2 +- .../kogito/it/jobs/JobServiceLeaderIT.java | 10 ++-- .../kie/kogito/it/jobs/ProcessAsyncIT.java | 2 +- .../kie/kogito/it/jobs/ProcessTimerIT.java | 2 +- .../kie/kogito/it/jobs/ProcessAsyncIT.java | 2 +- .../kie/kogito/it/jobs/ProcessTimerIT.java | 2 +- .../kie/kogito/it/jobs/ProcessAsyncIT.java | 2 +- .../kie/kogito/it/jobs/ProcessTimerIT.java | 4 +- 12 files changed, 88 insertions(+), 94 deletions(-) rename apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/{ComposeTestResource.java => CompositeTestResource.java} (78%) rename apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/{JobServiceComposeQuarkusTestResource.java => JobServiceCompositeQuarkusTestResource.java} (88%) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java index c6c878c46b..fbf30b06ed 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/it/jobs/BaseProcessTimerIT.java @@ -26,8 +26,8 @@ import static io.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; -import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; +import static org.kie.kogito.test.TestUtils.assertJobsAndProcessOnDataIndex; public abstract class BaseProcessTimerIT implements JobServiceHealthAware { @@ -48,7 +48,7 @@ public void testTimers() { assertThat(id).isEqualTo(id2); await().atMost(TIMEOUT) .untilAsserted(() -> getTimerWithStatusCode(id, 404, TIMERS)); - assertJobsAndProcessOnDataIndex(TIMERS, id, "COMPLETED", "EXECUTED"); + assertJobsAndProcessOnDataIndex(dataIndexUrl(), TIMERS, id, "COMPLETED", "EXECUTED", TIMEOUT); } public String dataIndexUrl() { @@ -61,50 +61,7 @@ public void testCancelTimer() { Object id2 = deleteTimer(id, TIMERS); assertThat(id).isEqualTo(id2); getTimerWithStatusCode(id, 404, TIMERS); - assertJobsAndProcessOnDataIndex(TIMERS, id, "ABORTED", "CANCELED"); - } - - private void assertJobsAndProcessOnDataIndex(String processId, String processInstanceId, String processStatus, String jobStatus) { - if (dataIndexUrl() != null) { - String query = "{ \"query\" : " + - "\"{ProcessInstances (where : {" + - " id: {equal : \\\"" + processInstanceId + "\\\" }" + - " }) {" + - " id,processId,state" + - " }" + - "}\"" + - "}"; - await() - .atMost(TIMEOUT) - .untilAsserted(() -> given() - .baseUri(dataIndexUrl()) - .contentType(ContentType.JSON) - .body(query) - .when().post("/graphql") - .then().statusCode(200) - .body("data.ProcessInstances.size()", is(1)) - .body("data.ProcessInstances[0].id", is(processInstanceId)) - .body("data.ProcessInstances[0].processId", is(processId)) - .body("data.ProcessInstances[0].state", is(processStatus))); - - String queryJobs = "{ \"query\" : " + - "\"{Jobs (where : {" + - " processInstanceId: {equal : \\\"" + processInstanceId + "\\\" }" + - " }) {" + - " status" + - " }" + - "}\"" + - "}"; - - given() - .baseUri(dataIndexUrl()) - .contentType(ContentType.JSON) - .body(queryJobs) - .when().post("/graphql") - .then().statusCode(200) - .body("data.Jobs.size()", is(1)) - .body("data.Jobs[0].status", is(jobStatus)); - } + assertJobsAndProcessOnDataIndex(dataIndexUrl(), TIMERS, id, "ABORTED", "CANCELED", TIMEOUT); } //Cycle Timers Tests @@ -115,7 +72,7 @@ public void testTimerCycle() { assertThat(id).isEqualTo(id2); await().atMost(TIMEOUT) .untilAsserted(() -> getTimerWithStatusCode(id, 404, TIMERS_CYCLE)); - assertJobsAndProcessOnDataIndex(TIMERS_CYCLE, id, "COMPLETED", "EXECUTED"); + assertJobsAndProcessOnDataIndex(dataIndexUrl(), TIMERS_CYCLE, id, "COMPLETED", "EXECUTED", TIMEOUT); } @Test @@ -127,7 +84,7 @@ public void testDeleteTimerCycle() { await().atMost(TIMEOUT) .untilAsserted(() -> getTimerWithStatusCode(id, 404, TIMERS_CYCLE)); await().atMost(TIMEOUT) - .untilAsserted(() -> assertJobsAndProcessOnDataIndex(TIMERS_CYCLE, id, "ABORTED", "CANCELED")); + .untilAsserted(() -> assertJobsAndProcessOnDataIndex(dataIndexUrl(), TIMERS_CYCLE, id, "ABORTED", "CANCELED", TIMEOUT)); } //Boundary Timers Tests @@ -138,7 +95,7 @@ public void testBoundaryTimersOnTask() { assertThat(id).isEqualTo(id2); await().atMost(TIMEOUT) .untilAsserted(() -> getTimerWithStatusCode(id, 404, TIMERS_ON_TASK)); - assertJobsAndProcessOnDataIndex(TIMERS_ON_TASK, id, "COMPLETED", "EXECUTED"); + assertJobsAndProcessOnDataIndex(dataIndexUrl(), TIMERS_ON_TASK, id, "COMPLETED", "EXECUTED", TIMEOUT); } @Test @@ -147,7 +104,7 @@ public void testDeleteBoundaryTimersOnTask() { String id2 = getTimerById(id, TIMERS_ON_TASK); assertThat(id).isEqualTo(id2); deleteTimer(id, TIMERS_ON_TASK); - assertJobsAndProcessOnDataIndex(TIMERS_ON_TASK, id, "ABORTED", "CANCELED"); + assertJobsAndProcessOnDataIndex(dataIndexUrl(), TIMERS_ON_TASK, id, "ABORTED", "CANCELED", TIMEOUT); } private ValidatableResponse getTimerWithStatusCode(String id, int code, String path) { diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/TestUtils.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/TestUtils.java index d8bb5b0cc7..b02ac14fa5 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/TestUtils.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/TestUtils.java @@ -16,10 +16,12 @@ package org.kie.kogito.test; +import java.time.Duration; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; +import org.awaitility.Awaitility; import org.kie.kogito.test.quarkus.kafka.KafkaTestClient; import io.restassured.http.ContentType; @@ -28,6 +30,7 @@ import static io.restassured.RestAssured.given; import static java.util.concurrent.TimeUnit.SECONDS; import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.CoreMatchers.is; import static org.testcontainers.shaded.org.awaitility.Awaitility.await; public class TestUtils { @@ -123,4 +126,47 @@ public static JsonPath waitForEvent(KafkaTestClient kafkaClient, String topic, l assertThat(countDownLatch.await(seconds, TimeUnit.SECONDS)).isTrue(); return new JsonPath(cloudEvent.get()); } + + public static void assertJobsAndProcessOnDataIndex(String dataIndexURL, String processId, String processInstanceId, String processStatus, String jobStatus, Duration timeout) { + if (dataIndexURL != null) { + String query = "{ \"query\" : " + + "\"{ProcessInstances (where : {" + + " id: {equal : \\\"" + processInstanceId + "\\\" }" + + " }) {" + + " id,processId,state" + + " }" + + "}\"" + + "}"; + Awaitility.await() + .atMost(timeout) + .untilAsserted(() -> given() + .baseUri(dataIndexURL) + .contentType(ContentType.JSON) + .body(query) + .when().post("/graphql") + .then().statusCode(200) + .body("data.ProcessInstances.size()", is(1)) + .body("data.ProcessInstances[0].id", is(processInstanceId)) + .body("data.ProcessInstances[0].processId", is(processId)) + .body("data.ProcessInstances[0].state", is(processStatus))); + + String queryJobs = "{ \"query\" : " + + "\"{Jobs (where : {" + + " processInstanceId: {equal : \\\"" + processInstanceId + "\\\" }" + + " }) {" + + " status" + + " }" + + "}\"" + + "}"; + + given() + .baseUri(dataIndexURL) + .contentType(ContentType.JSON) + .body(queryJobs) + .when().post("/graphql") + .then().statusCode(200) + .body("data.Jobs.size()", is(1)) + .body("data.Jobs[0].status", is(jobStatus)); + } + } } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/ComposeTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/CompositeTestResource.java similarity index 78% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/ComposeTestResource.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/CompositeTestResource.java index 7956ef27c2..2d2c93409d 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/ComposeTestResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-common/src/main/java/org/kie/kogito/test/resources/CompositeTestResource.java @@ -36,19 +36,19 @@ import org.testcontainers.containers.Network; import org.testcontainers.containers.wait.strategy.Wait; -public class ComposeTestResource implements TestResource { +public class CompositeTestResource implements TestResource { - private static final Logger LOGGER = LoggerFactory.getLogger(ComposeTestResource.class); - public static final String MAIN_SERVICE_ID = "job-service-main";//fixme + private static final Logger LOGGER = LoggerFactory.getLogger(CompositeTestResource.class); + public static final String MAIN_SERVICE_ID = "main-service"; private final Map> sharedDependencyContainers; private final Map> serviceContainers; private final Map>> dependencyContainers; private final KogitoGenericContainer mainContainer; - private Map properties; + private final Map properties; - public ComposeTestResource(KogitoGenericContainer mainContainer) { + public CompositeTestResource(KogitoGenericContainer mainContainer) { this.sharedDependencyContainers = new HashMap<>(); this.dependencyContainers = new HashMap<>(); this.serviceContainers = new HashMap<>(); @@ -57,22 +57,19 @@ public ComposeTestResource(KogitoGenericContainer mainContainer) { withServiceContainer(MAIN_SERVICE_ID, mainContainer); } - public ComposeTestResource withServiceContainer(String id, KogitoGenericContainer container, GenericContainer... dependency) { + public CompositeTestResource withServiceContainer(String id, KogitoGenericContainer container, GenericContainer... dependency) { serviceContainers.put(id, container); - List> containers = dependencyContainers.getOrDefault(id, new ArrayList<>()); - containers.addAll(Arrays.asList(dependency)); - dependencyContainers.put(id, containers); - return this; + return withDependencyToService(id, dependency); } - public ComposeTestResource withDependencyToService(String serviceId, GenericContainer dependency) { + public CompositeTestResource withDependencyToService(String serviceId, GenericContainer... dependency) { List> containers = dependencyContainers.getOrDefault(serviceId, new ArrayList<>()); - containers.add(dependency); + containers.addAll(Arrays.asList(dependency)); dependencyContainers.put(serviceId, containers); return this; } - public ComposeTestResource withSharedDependencyContainer(String prefix, GenericContainer container) { + public CompositeTestResource withSharedDependencyContainer(String prefix, GenericContainer container) { sharedDependencyContainers.put(prefix, container); return this; } @@ -91,14 +88,13 @@ private String hostName(GenericContainer container) { @Override public void start() { - LOGGER.info("Start JobService with {} test resources", sharedDependencyContainers.values().stream().map(GenericContainer::getImage).collect(Collectors.toList())); + LOGGER.info("Starting {} Test Resource", mainContainer); final Network network = Network.newNetwork(); sharedDependencyContainers.values().stream() .map(c -> c.withNetwork(network)) .map(c -> c.waitingFor(Wait.forListeningPort())) .forEach(GenericContainer::start); - //configurePostgreSQL(sharedDependencyContainers.values(), mainContainer); - configureKafka(sharedDependencyContainers.values(), serviceContainers.values().toArray(GenericContainer[]::new)); + configureKafkaToService(sharedDependencyContainers.values(), serviceContainers.values().toArray(GenericContainer[]::new)); startServices(network); } @@ -116,45 +112,41 @@ protected void startServices(Network network) { return container; }) .collect(Collectors.toList()); - configurePostgreSQL(dependencies, serviceContainers.get(entry.getKey())); - configureKafka(dependencies, serviceContainers.get(entry.getKey())); + configurePostgreSQLToService(dependencies, serviceContainers.get(entry.getKey())); + configureKafkaToService(dependencies, serviceContainers.get(entry.getKey())); return entry; }) .map(Map.Entry::getValue) .forEach(service -> { service.withNetwork(network); service.start(); - LOGGER.info("JobService test resource started"); + LOGGER.info("Test resource started"); }); } - protected void configureKafka(Collection> containers, GenericContainer... services) { + protected void configureKafkaToService(Collection> containers, GenericContainer... services) { containers.stream() .filter(KogitoKafkaContainer.class::isInstance) .map(KogitoKafkaContainer.class::cast) .findFirst() .ifPresent(kafka -> { - LOGGER.info("Configure Kafka"); // external access url String kafkaURL = kafka.getBootstrapServers(); - LOGGER.info("kafkaURL: {}", kafkaURL); properties.put("kafka.bootstrap.servers", kafkaURL); properties.put("spring.kafka.bootstrap-servers", kafkaURL); //internal access final String kafkaInternalUrl = hostName(kafka) + ":29092"; - LOGGER.info("kafkaInternalURL: {}", kafkaInternalUrl); Stream.of(services).forEach(service -> service.addEnv("KAFKA_BOOTSTRAP_SERVERS", kafkaInternalUrl)); }); } - protected void configurePostgreSQL(Collection> containers, GenericContainer... services) { + protected void configurePostgreSQLToService(Collection> containers, GenericContainer... services) { containers.stream() .filter(KogitoPostgreSqlContainer.class::isInstance) .map(KogitoPostgreSqlContainer.class::cast) .findFirst() .ifPresent(postgreSql -> { - LOGGER.info("Configure PostgreSQL"); final String connectionTemplate = "postgresql://{0}:{1}/{2}"; final String jdbcConnectionTemplate = "jdbc:postgresql://{0}:{1}/{2}"; final String server = hostName(postgreSql); @@ -181,7 +173,6 @@ public void stop() { serviceContainers.values().forEach(GenericContainer::stop); sharedDependencyContainers.values().forEach(GenericContainer::stop); dependencyContainers.values().stream().flatMap(List::stream).forEach(GenericContainer::stop); - LOGGER.info("Test resource stopped"); } @Override diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceCompositeQuarkusTestResource.java similarity index 88% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceCompositeQuarkusTestResource.java index 3383115b39..7d30deb6d9 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceComposeQuarkusTestResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceCompositeQuarkusTestResource.java @@ -25,17 +25,17 @@ import io.quarkus.test.common.QuarkusTestResourceConfigurableLifecycleManager; -public class JobServiceComposeQuarkusTestResource implements QuarkusTestResourceConfigurableLifecycleManager { +public class JobServiceCompositeQuarkusTestResource implements QuarkusTestResourceConfigurableLifecycleManager { public static final String JOBS_SERVICE_URL = "kogito.jobs-service.url"; public static final String DATA_INDEX_SERVICE_URL = "kogito.data-index.url"; private JobServiceTestResource annotation; - private ComposeTestResource resource; + private CompositeTestResource resource; - public JobServiceComposeQuarkusTestResource() { - resource = new ComposeTestResource(new JobServiceContainer()); + public JobServiceCompositeQuarkusTestResource() { + resource = new CompositeTestResource(new JobServiceContainer()); } @Override @@ -43,7 +43,7 @@ public void init(JobServiceTestResource annotation) { this.annotation = annotation; switch (annotation.persistence()) { case POSTGRESQL: - resource.withDependencyToService(ComposeTestResource.MAIN_SERVICE_ID, new KogitoPostgreSqlContainer()); + resource.withDependencyToService(CompositeTestResource.MAIN_SERVICE_ID, new KogitoPostgreSqlContainer()); //resource.withSharedDependencyContainer("postgres", new KogitoPostgreSqlContainer()); break; case IN_MEMORY: diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java index c8ccc87136..c8fa913afc 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/test/resources/JobServiceTestResource.java @@ -22,7 +22,7 @@ import io.quarkus.test.common.QuarkusTestResource; -@QuarkusTestResource(JobServiceComposeQuarkusTestResource.class) +@QuarkusTestResource(JobServiceCompositeQuarkusTestResource.class) @QuarkusTestResource(KogitoServiceRandomPortQuarkusTestResource.class) @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java index 32b9eb7de9..f31a967665 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/JobServiceLeaderIT.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.kie.kogito.test.resources.ComposeTestResource; +import org.kie.kogito.test.resources.CompositeTestResource; import org.kie.kogito.testcontainers.JobServiceContainer; import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer; import org.slf4j.Logger; @@ -35,7 +35,7 @@ public class JobServiceLeaderIT { - private static ComposeTestResource resource; + private static CompositeTestResource resource; private final static Logger logger = LoggerFactory.getLogger(JobServiceLeaderIT.class); private static List containers; @@ -43,13 +43,13 @@ public class JobServiceLeaderIT { @BeforeAll public static void init() { KogitoPostgreSqlContainer postgreSqlContainer = new KogitoPostgreSqlContainer(); - resource = new ComposeTestResource(new JobServiceContainer()) + resource = new CompositeTestResource(new JobServiceContainer()) .withServiceContainer("job-service-1", new JobServiceContainer(), postgreSqlContainer) .withServiceContainer("job-service-2", new JobServiceContainer(), postgreSqlContainer) - .withDependencyToService(ComposeTestResource.MAIN_SERVICE_ID, postgreSqlContainer); + .withDependencyToService(CompositeTestResource.MAIN_SERVICE_ID, postgreSqlContainer); containers = resource.getServiceContainers(JobServiceContainer.class); //decrease the leader expiration timeout to 2 seconds to make the test quicker - containers.stream().forEach(c -> c.withEnv("KOGITO_JOBS_SERVICE_MANAGEMENT_HEARTBEAT_EXPIRATION_IN_SECONDS", "2")); + containers.forEach(c -> c.withEnv("KOGITO_JOBS_SERVICE_MANAGEMENT_HEARTBEAT_EXPIRATION_IN_SECONDS", "2")); resource.start(); } diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java index 622d59a8ec..e9c281d9fc 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java @@ -22,7 +22,7 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; +import static org.kie.kogito.test.resources.JobServiceCompositeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest @QuarkusTestResource(KafkaQuarkusTestResource.class) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java index c97a614919..cff73a99d6 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-knative-eventing/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java @@ -21,7 +21,7 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; +import static org.kie.kogito.test.resources.JobServiceCompositeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest @QuarkusTestResource(KafkaQuarkusTestResource.class) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java index 0cf671beb7..8bd3b4c241 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java @@ -21,7 +21,7 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; +import static org.kie.kogito.test.resources.JobServiceCompositeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest @QuarkusTestResource(KafkaQuarkusTestResource.class) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java index 97daf5be6a..35d7e5fbcc 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-management/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java @@ -21,7 +21,7 @@ import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; +import static org.kie.kogito.test.resources.JobServiceCompositeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest @QuarkusTestResource(KafkaQuarkusTestResource.class) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java index 1864ed2b65..556dbe30f1 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessAsyncIT.java @@ -19,7 +19,7 @@ import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; +import static org.kie.kogito.test.resources.JobServiceCompositeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest @JobServiceTestResource(kafkaEnabled = true) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java index 45e4b34494..24325f5a29 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/test/java/org/kie/kogito/it/jobs/ProcessTimerIT.java @@ -19,8 +19,8 @@ import io.quarkus.test.junit.QuarkusIntegrationTest; -import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.DATA_INDEX_SERVICE_URL; -import static org.kie.kogito.test.resources.JobServiceComposeQuarkusTestResource.JOBS_SERVICE_URL; +import static org.kie.kogito.test.resources.JobServiceCompositeQuarkusTestResource.DATA_INDEX_SERVICE_URL; +import static org.kie.kogito.test.resources.JobServiceCompositeQuarkusTestResource.JOBS_SERVICE_URL; @QuarkusIntegrationTest @JobServiceTestResource(kafkaEnabled = true, dataIndexEnabled = true) From 5ed5810e60aa307bc4a5604953a6fe43b6b21bcc Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Thu, 17 Nov 2022 10:05:42 -0300 Subject: [PATCH 12/14] Moving BaseCallbackStateTimeoutsIT to test folder --- .../pom.xml | 15 +++++++++++++++ .../it/jobs/BaseCallbackStateTimeoutsIT.java | 0 .../kogito/it/jobs/BaseSwitchStateTimeoutsIT.java | 0 .../it/jobs/KafkaBaseSwitchStateTimeoutsIT.java | 0 .../pom.xml | 6 ++++++ .../integration-tests-jobs-service/pom.xml | 6 ++++++ 6 files changed, 27 insertions(+) rename apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/{main => test}/java/org/kie/kogito/it/jobs/BaseCallbackStateTimeoutsIT.java (100%) rename apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/{main => test}/java/org/kie/kogito/it/jobs/BaseSwitchStateTimeoutsIT.java (100%) rename apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/{main => test}/java/org/kie/kogito/it/jobs/KafkaBaseSwitchStateTimeoutsIT.java (100%) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/pom.xml index 24004998ef..6628ddd515 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/pom.xml @@ -45,4 +45,19 @@ compile + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseCallbackStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/BaseCallbackStateTimeoutsIT.java similarity index 100% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseCallbackStateTimeoutsIT.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/BaseCallbackStateTimeoutsIT.java diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseSwitchStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/BaseSwitchStateTimeoutsIT.java similarity index 100% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/BaseSwitchStateTimeoutsIT.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/BaseSwitchStateTimeoutsIT.java diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/KafkaBaseSwitchStateTimeoutsIT.java b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/KafkaBaseSwitchStateTimeoutsIT.java similarity index 100% rename from apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/main/java/org/kie/kogito/it/jobs/KafkaBaseSwitchStateTimeoutsIT.java rename to apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/src/test/java/org/kie/kogito/it/jobs/KafkaBaseSwitchStateTimeoutsIT.java diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml index b6f2bce395..33c3e18a6b 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/pom.xml @@ -67,6 +67,12 @@ integration-tests-jobs-service-common-quarkus test + + org.kie.kogito + integration-tests-jobs-service-common-quarkus + test-jar + test + org.kie.kogito kogito-quarkus-test-utils diff --git a/apps-integration-tests/integration-tests-jobs-service/pom.xml b/apps-integration-tests/integration-tests-jobs-service/pom.xml index 4117767c6c..4872c9dd79 100644 --- a/apps-integration-tests/integration-tests-jobs-service/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/pom.xml @@ -32,6 +32,12 @@ integration-tests-jobs-service-common-quarkus ${project.version} + + org.kie.kogito + integration-tests-jobs-service-common-quarkus + ${project.version} + test-jar + From 83811dda463572847e0d748165023f73aa8f1e76 Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Fri, 18 Nov 2022 09:04:28 -0300 Subject: [PATCH 13/14] remove abstract test classes from mvn IT execution --- .../pom.xml | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/pom.xml index 6628ddd515..e492944368 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-common-quarkus/pom.xml @@ -46,18 +46,27 @@ - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + **/*Base*IT*.java + + + + From 32af5d45cf22c812e86f9de0824a43776dc1b023 Mon Sep 17 00:00:00 2001 From: Tiago Dolphine Date: Tue, 22 Nov 2022 12:54:22 -0300 Subject: [PATCH 14/14] adding comment to describe why the filesystem persistence is enabled in the test --- .../integration-tests-jobs-service-quarkus-messaging/pom.xml | 1 + .../src/main/resources/application.properties | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml index 3f773747ba..f8819926ae 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/pom.xml @@ -22,6 +22,7 @@ org.kie.kogito kogito-addons-quarkus-events-process + org.kie.kogito kogito-addons-quarkus-persistence-filesystem diff --git a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/application.properties b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/application.properties index b5ae4594b6..820697f557 100644 --- a/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/application.properties +++ b/apps-integration-tests/integration-tests-jobs-service/integration-tests-jobs-service-quarkus/integration-tests-jobs-service-quarkus-messaging/src/main/resources/application.properties @@ -45,4 +45,4 @@ mp.messaging.outgoing.kogito-variables-events.value.serializer=org.apache.kafka. kogito.persistence.type=filesystem -quarkus.devservices.enabled=false +quarkus.devservices.enabled=false \ No newline at end of file