-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KOGITO-9523 - Move Data Index DevService test to kogito-apps
- Loading branch information
1 parent
3908d94
commit e4b06d7
Showing
12 changed files
with
304 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...-tests-data-index-service/integration-tests-data-index-service-quarkus-devservice/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
71 changes: 71 additions & 0 deletions
71
.../integration-tests-data-index-service-quarkus-devservice/src/main/resources/greet.sw.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] | ||
} |
115 changes: 115 additions & 0 deletions
115
...-quarkus-devservice/src/test/java/org/kie/kogito/index/inmemory/KogitoDevServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters