Skip to content

Commit

Permalink
KOGITO-9523 - Move Data Index DevService test to kogito-apps
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianonicolai committed Jul 12, 2023
1 parent 3908d94 commit e4b06d7
Show file tree
Hide file tree
Showing 12 changed files with 304 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public abstract class AbstractDataIndexContainer extends KogitoGenericContainer<AbstractDataIndexContainer>
implements TestResource {

public static final int PORT = 8180;
public static final int PORT = 8080;

public AbstractDataIndexContainer(String containerName) {
super(containerName);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>integration-tests-data-index-service</artifactId>
<groupId>org.kie.kogito</groupId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>integration-tests-data-index-service-quarkus-devservice</artifactId>
<name>Kogito Apps :: Integration Tests :: Data Index :: Quarkus DevService</name>

<properties>
<data-index-ephemeral.image.test>org.kie.kogito/data-index-service-inmemory:${project.version}</data-index-ephemeral.image.test>
</properties>

<dependencies>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-quarkus-serverless-workflow</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-quarkus-test-utils</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<!-- this is used implicitly by hot reload tests so let's make Maven aware of it -->
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>data-index-service-inmemory</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${version.io.quarkus}</version>
<configuration>
<skipOriginalJarRename>true</skipOriginalJarRename>
</configuration>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<data-index-ephemeral.image.test>${data-index-ephemeral.image.test}</data-index-ephemeral.image.test>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"id": "greet",
"version": "1.0",
"name": "Greeting workflow",
"expressionLang": "jsonpath",
"description": "JSON based greeting workflow",
"start": "ChooseOnLanguage",
"functions": [
{
"name": "greetFunction",
"type": "custom",
"operation": "sysout"
},
{
"name": "isEnglish",
"type": "expression",
"operation" : "$.[?(@.language == 'English')]"
}
],
"states": [
{
"name": "ChooseOnLanguage",
"type": "switch",
"dataConditions": [
{
"condition": "fn:isEnglish",
"transition": "GreetInEnglish"
},
{
"condition": "${ $.[?(@.language == 'Spanish')] }",
"transition": "GreetInSpanish"
}
],
"defaultCondition": {
"transition": "GreetInEnglish"
}
},
{
"name": "GreetInEnglish",
"type": "inject",
"data": {
"greeting": "Hello from JSON Workflow,"
},
"transition": "GreetPerson"
},
{
"name": "GreetInSpanish",
"type": "inject",
"data": {
"greeting": "Saludos desde JSON Workflow,"
},
"transition": "GreetPerson"
},
{
"name": "GreetPerson",
"type": "operation",
"actions": [
{
"name": "greetAction",
"functionRef": {
"refName": "greetFunction",
"arguments": {
"message": "$.greeting $.name"
}
}
}
],
"end": true
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* Copyright 2023 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.index.inmemory;

import java.time.Duration;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.kie.kogito.test.utils.SocketUtils;

import io.quarkus.test.QuarkusDevModeTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;

import static io.restassured.RestAssured.given;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;

public class KogitoDevServiceTest {

private static final Duration TIMEOUT = Duration.ofMinutes(1);
private static final String DATA_INDEX_EPHEMERAL_IMAGE_TEST_PROPERTY = "data-index-ephemeral.image.test";

static {
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
}

final static int httpPort = SocketUtils.findAvailablePort();
final static int dataIndexHttpPort = SocketUtils.findAvailablePort();

@RegisterExtension
final static QuarkusDevModeTest test = new QuarkusDevModeTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addAsResource(new StringAsset(getApplicationPropertiesContent()), "application.properties")
.addAsResource("greet.sw.json"));

@Test
public void testDataIndexDevService() {
await()
.atMost(TIMEOUT)
.ignoreExceptions()
.untilAsserted(() -> given()
.baseUri("http://localhost:" + dataIndexHttpPort)
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
.body("{ \"query\" : \"{ ProcessInstances { id } }\"}")
.when().post("/graphql")
.then()
.statusCode(200)
.body("data.ProcessInstances.size()", is(0)));

String processId = given()
.baseUri("http://localhost:" + httpPort)
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
.body("{\"workflowdata\" : {\"name\" : \"John\", \"language\":\"English\"}}")
.when()
.post("/greet")
.then()
.statusCode(201)
.header("Location", notNullValue())
.body("id", notNullValue())
.extract()
.path("id");

await()
.atMost(TIMEOUT)
.untilAsserted(() -> given()
.baseUri("http://localhost:" + dataIndexHttpPort)
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
.body("{ \"query\" : \"{ ProcessInstances (where: { id: {equal: \\\"" + processId + "\\\"}}) { id, processId, processName } }\"}")
.when().post("/graphql")
.then()
.statusCode(200)
.body("data.ProcessInstances[0].id", is(processId))
.body("data.ProcessInstances[0].processId", is("greet"))
.body("data.ProcessInstances[0].processName", is("Greeting workflow")));
}

private static String getApplicationPropertiesContent() {
return "quarkus.http.port=" + httpPort + "\n"
+ "quarkus.kogito.devservices.port=" + dataIndexHttpPort + "\n"
+ getKogitoDevServicesImageName();
}

private static String getKogitoDevServicesImageName() {
String imageName = System.getProperty(DATA_INDEX_EPHEMERAL_IMAGE_TEST_PROPERTY);
if (imageName == null) {
throw new IllegalStateException("Property " + DATA_INDEX_EPHEMERAL_IMAGE_TEST_PROPERTY + " was not passed to tests!");
}
if (imageName.isEmpty()) {
return "";
}
return "quarkus.kogito.devservices.image-name=" + imageName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@
<name>Kogito Apps :: Integration Tests :: Data Index</name>
<packaging>pom</packaging>

<modules>
<module>integration-tests-data-index-service-quarkus-devservice</module>
</modules>

<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>!productized</name>
</property>
</activation>
<modules>
<module>integration-tests-data-index-service-common</module>
Expand Down
9 changes: 7 additions & 2 deletions apps-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@
<name>Kogito Apps :: Integration Tests</name>
<packaging>pom</packaging>

<modules>
<module>integration-tests-data-index-service</module>
</modules>

<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>!productized</name>
</property>
</activation>
<modules>
<module>integration-tests-jobs-service</module>
<module>integration-tests-trusty-audit</module>
<module>integration-tests-trusty-service</module>
<module>integration-tests-data-index-service</module>
</modules>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ quarkus.kafka.health.enabled=true

#Container image
quarkus.container-image.build=${quarkus.build.image:true}
quarkus.container-image.group=org.kie.kogito
quarkus.container-image.group=org.kie.kogito
quarkus.jib.jvm-arguments=-Dquarkus.http.port=8080
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ quarkus.hibernate-orm.database.generation.halt-on-error=true
#Container image
quarkus.container-image.build=${quarkus.build.image:true}
quarkus.container-image.group=org.kie.kogito
quarkus.jib.jvm-arguments=-Dquarkus.http.port=8080

quarkus.http.cors.origins=/.*/
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ quarkus.mongodb.metrics.enabled=true
#Container image
quarkus.container-image.build=${quarkus.build.image:true}
quarkus.container-image.group=org.kie.kogito
quarkus.jib.jvm-arguments=-Dquarkus.http.port=8080
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.C
#Container image
quarkus.container-image.build=${quarkus.build.image:true}
quarkus.container-image.group=org.kie.kogito
quarkus.jib.jvm-arguments=-Dquarkus.http.port=8080
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.C
#Container image
quarkus.container-image.build=${quarkus.build.image:true}
quarkus.container-image.group=org.kie.kogito
quarkus.jib.jvm-arguments=-Dquarkus.http.port=8080

quarkus.log.console.enable=true
quarkus.log.console.level=INFO
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<module>ui-packages</module>
<module>kogito-quarkus-serverless-workflow-devui-parent</module>
<module>jobs-service</module>
<module>apps-integration-tests</module>
</modules>
</profile>
<profile>
Expand Down

0 comments on commit e4b06d7

Please sign in to comment.