This is an automated email from the ASF dual-hosted git repository.
ricardozanini pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-images.git
The following commit(s) were added to refs/heads/main by this push:
new 5fac5e93 [KOGITO-9729] SonataFlow builder image is not preserving
resources path (#1677)
5fac5e93 is described below
commit 5fac5e93307e730b226256370239586b517acb40
Author: Davide Salerno <[email protected]>
AuthorDate: Wed Sep 27 19:57:44 2023 +0200
[KOGITO-9729] SonataFlow builder image is not preserving resources path
(#1677)
* [KOGITO-9729] SonataFlow builder image is not preserving resources path
Signed-off-by: Davide Salerno <[email protected]>
* [KOGITO-9729] Added shell test
Signed-off-by: Davide Salerno <[email protected]>
* Update modules/kogito-swf/common/scripts/added/build-app.sh
Co-authored-by: Tristan Radisson <[email protected]>
* [KOGITO-9729] Stopping containers into the same shell test
Signed-off-by: Davide Salerno <[email protected]>
---------
Signed-off-by: Davide Salerno <[email protected]>
Co-authored-by: Tristan Radisson <[email protected]>
---
.../kogito-swf/common/scripts/added/build-app.sh | 2 +-
tests/shell/kogito-swf-builder/RunTests.java | 34 ++++++++--
.../{ => greet-with-inputschema}/.mvn/jvm.config | 0
.../{ => greet-with-inputschema}/Dockerfile | 2 +-
.../{ => greet-with-inputschema}/greet.sw.json | 78 ++++++++++++++--------
.../greet-with-inputschema/schemas/input.json | 16 +++++
.../resources/{ => greet}/.mvn/jvm.config | 0
.../resources/{ => greet}/Dockerfile | 0
.../resources/{ => greet}/greet.sw.json | 0
9 files changed, 98 insertions(+), 34 deletions(-)
diff --git a/modules/kogito-swf/common/scripts/added/build-app.sh
b/modules/kogito-swf/common/scripts/added/build-app.sh
index fdc5fc24..762c791e 100755
--- a/modules/kogito-swf/common/scripts/added/build-app.sh
+++ b/modules/kogito-swf/common/scripts/added/build-app.sh
@@ -20,7 +20,7 @@ fi
SUPPORTED_FILES=(".yaml" ".yml" ".json" ".properties" ".mvn/jvm.config")
log_info "-> Copying files from ${resources_path}, if any..."
if [ ! -z "${resources_path}" ]; then
- find "${resources_path}" -regex '.*\.\(yaml\|yml\|json\|properties\)$'
-exec cp -v {} src/main/resources/ \;
+ cd "${resources_path}" && find . -regex
'.*\.\(yaml\|yml\|json\|properties\)$' | sed 's|^./||' | xargs cp -v --parents
-t "${swf_home_dir}"/src/main/resources/ && cd -
find "${resources_path}" -name 'jvm.config' -exec echo "--> found {}" \;
-exec mkdir -p .mvn \; -exec cp -v {} .mvn/ \;
else
log_warning "-> Nothing to copy from ${resources_path}"
diff --git a/tests/shell/kogito-swf-builder/RunTests.java
b/tests/shell/kogito-swf-builder/RunTests.java
index f2dee5a8..8c570502 100644
--- a/tests/shell/kogito-swf-builder/RunTests.java
+++ b/tests/shell/kogito-swf-builder/RunTests.java
@@ -46,9 +46,9 @@ public class RunTests {
private Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(LOGGER);
@Container
- private GenericContainer builtImage = new GenericContainer(
+ private GenericContainer greetBuiltImage = new GenericContainer(
new ImageFromDockerfile("dev.local/jbang-test/swf-test:" +
Math.round(Math.random() * 1000000.00))
- .withDockerfile(Paths.get(getScriptDirPath(), "resources",
"Dockerfile"))
+ .withDockerfile(Paths.get(getScriptDirPath(),
"resources/greet", "Dockerfile"))
.withBuildArg("BUILDER_IMAGE_TAG", getTestImage()))
.withExposedPorts(8080)
.waitingFor(Wait.forHttp("/jsongreet"))
@@ -56,9 +56,9 @@ public class RunTests {
@Test
public void testBuiltContainerAnswerCorrectly() throws URISyntaxException,
IOException, InterruptedException {
- builtImage.start();
+ greetBuiltImage.start();
HttpRequest request = HttpRequest.newBuilder()
- .uri(new URI("http://" + builtImage.getHost() + ":" +
builtImage.getFirstMappedPort() + "/jsongreet"))
+ .uri(new URI("http://" + greetBuiltImage.getHost() + ":" +
greetBuiltImage.getFirstMappedPort() + "/jsongreet"))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.timeout(Duration.ofSeconds(10))
@@ -67,6 +67,32 @@ public class RunTests {
.build();
HttpResponse<String> response =
HttpClient.newHttpClient().send(request, BodyHandlers.ofString());
assertEquals(201, response.statusCode());
+ greetBuiltImage.stop();
+ }
+
+ @Container
+ private GenericContainer greetWithInputSchemaBuiltImage = new
GenericContainer(
+ new ImageFromDockerfile("dev.local/jbang-test/swf-test:" +
Math.round(Math.random() * 1000000.00))
+ .withDockerfile(Paths.get(getScriptDirPath(),
"resources/greet-with-inputschema", "Dockerfile"))
+ .withBuildArg("BUILDER_IMAGE_TAG", getTestImage()))
+ .withExposedPorts(8080)
+ .waitingFor(Wait.forHttp("/greeting"))
+ .withLogConsumer(logConsumer);
+
+ @Test
+ public void testBuiltContainerWithInputSchemaAnswerCorrectly() throws
URISyntaxException, IOException, InterruptedException {
+ greetWithInputSchemaBuiltImage.start();
+ HttpRequest request = HttpRequest.newBuilder()
+ .uri(new URI("http://" +
greetWithInputSchemaBuiltImage.getHost() + ":" +
greetWithInputSchemaBuiltImage.getFirstMappedPort() + "/greeting"))
+ .header("Content-Type", "application/json")
+ .header("Accept", "application/json")
+ .timeout(Duration.ofSeconds(10))
+ .POST(HttpRequest.BodyPublishers
+ .ofString("{\"name\": \"John\", \"language\":
\"English\"}"))
+ .build();
+ HttpResponse<String> response =
HttpClient.newHttpClient().send(request, BodyHandlers.ofString());
+ assertEquals(201, response.statusCode());
+ greetWithInputSchemaBuiltImage.stop();
}
public static void main(String... args) throws Exception {
diff --git a/tests/shell/kogito-swf-builder/resources/.mvn/jvm.config
b/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/.mvn/jvm.config
similarity index 100%
copy from tests/shell/kogito-swf-builder/resources/.mvn/jvm.config
copy to
tests/shell/kogito-swf-builder/resources/greet-with-inputschema/.mvn/jvm.config
diff --git a/tests/shell/kogito-swf-builder/resources/Dockerfile
b/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/Dockerfile
similarity index 98%
copy from tests/shell/kogito-swf-builder/resources/Dockerfile
copy to
tests/shell/kogito-swf-builder/resources/greet-with-inputschema/Dockerfile
index a8e4bdd1..88e1fc8a 100644
--- a/tests/shell/kogito-swf-builder/resources/Dockerfile
+++ b/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/Dockerfile
@@ -11,7 +11,7 @@ ARG MAVEN_DOWNLOAD_OUTPUT="true"
ARG MAVEN_OFFLINE_MODE="true"
# Copy from build context to resources directory
-COPY * ./resources/
+COPY ./ ./resources/
# Build app with given resources
RUN "${KOGITO_HOME}"/launch/build-app.sh './resources'
diff --git a/tests/shell/kogito-swf-builder/resources/greet.sw.json
b/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/greet.sw.json
similarity index 53%
copy from tests/shell/kogito-swf-builder/resources/greet.sw.json
copy to
tests/shell/kogito-swf-builder/resources/greet-with-inputschema/greet.sw.json
index a619b3b8..183e2101 100644
--- a/tests/shell/kogito-swf-builder/resources/greet.sw.json
+++
b/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/greet.sw.json
@@ -1,53 +1,67 @@
{
- "id": "jsongreet",
- "version": "1.0",
- "name": "Greeting workflow",
- "description": "JSON based greeting workflow",
- "start": "ChooseOnLanguage",
- "functions": [
- {
- "name": "greetFunction",
- "type": "custom",
- "operation": "sysout"
- }
- ],
+ "id": "greeting",
+ "description": "Greeting example on k8s!",
+ "version": "0.0.1",
+ "start": {
+ "stateName": "ChooseOnLanguage"
+ },
+ "dataInputSchema": {
+ "schema": "schemas/input.json",
+ "failOnValidationErrors": true
+ },
+ "specVersion": "0.8",
+ "expressionLang": "jq",
"states": [
{
"name": "ChooseOnLanguage",
"type": "switch",
+ "defaultCondition": {
+ "transition": {
+ "nextState": "GreetInEnglish"
+ }
+ },
"dataConditions": [
{
"condition": "${ .language == \"English\" }",
- "transition": "GreetInEnglish"
+ "transition": {
+ "nextState": "GreetInEnglish"
+ }
},
{
"condition": "${ .language == \"Spanish\" }",
- "transition": "GreetInSpanish"
+ "transition": {
+ "nextState": "GreetInSpanish"
+ }
}
- ],
- "defaultCondition": {
- "transition": "GreetInEnglish"
- }
+ ]
},
{
"name": "GreetInEnglish",
"type": "inject",
+ "transition": {
+ "nextState": "GreetPerson"
+ },
"data": {
"greeting": "Hello from JSON Workflow, "
- },
- "transition": "GreetPerson"
+ }
},
{
"name": "GreetInSpanish",
"type": "inject",
+ "transition": {
+ "nextState": "GreetPerson"
+ },
"data": {
"greeting": "Saludos desde JSON Workflow, "
- },
- "transition": "GreetPerson"
+ }
},
{
"name": "GreetPerson",
"type": "operation",
+ "end": {
+ "terminate": true
+ },
+ "actionMode": "sequential",
"actions": [
{
"name": "greetAction",
@@ -55,13 +69,21 @@
"refName": "greetFunction",
"arguments": {
"message": ".greeting+.name"
- }
+ },
+ "invoke": "sync"
+ },
+ "actionDataFilter": {
+ "useResults": true
}
}
- ],
- "end": {
- "terminate": true
- }
+ ]
+ }
+ ],
+ "functions": [
+ {
+ "name": "greetFunction",
+ "operation": "sysout",
+ "type": "custom"
}
]
-}
+}
\ No newline at end of file
diff --git
a/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/schemas/input.json
b/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/schemas/input.json
new file mode 100644
index 00000000..1874fd25
--- /dev/null
+++
b/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/schemas/input.json
@@ -0,0 +1,16 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "language": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "language",
+ "name"
+ ]
+}
\ No newline at end of file
diff --git a/tests/shell/kogito-swf-builder/resources/.mvn/jvm.config
b/tests/shell/kogito-swf-builder/resources/greet/.mvn/jvm.config
similarity index 100%
rename from tests/shell/kogito-swf-builder/resources/.mvn/jvm.config
rename to tests/shell/kogito-swf-builder/resources/greet/.mvn/jvm.config
diff --git a/tests/shell/kogito-swf-builder/resources/Dockerfile
b/tests/shell/kogito-swf-builder/resources/greet/Dockerfile
similarity index 100%
rename from tests/shell/kogito-swf-builder/resources/Dockerfile
rename to tests/shell/kogito-swf-builder/resources/greet/Dockerfile
diff --git a/tests/shell/kogito-swf-builder/resources/greet.sw.json
b/tests/shell/kogito-swf-builder/resources/greet/greet.sw.json
similarity index 100%
rename from tests/shell/kogito-swf-builder/resources/greet.sw.json
rename to tests/shell/kogito-swf-builder/resources/greet/greet.sw.json
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]