Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KOGITO-9145] Create an implementation of the Service Discovery catal… #3166

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions kogito-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,25 @@
<type>pom</type>
</dependency>

<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>

<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
</dependency>

<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-common-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog-deployment</artifactId>
<name>Kogito Add-On MicroProfile Config Service Catalog - Deployment</name>

<dependencies>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${version.io.quarkus}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog-integration-tests</artifactId>
<name>Kogito Add-On Microprofile Config Service Catalog - Integration Tests</name>
<description>Microprofile Config Service Catalog Kogito Add-On Integration Tests.</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-quarkus-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
</dependency>
<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-addons-quarkus-knative-serving</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-kubernetes</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-fabric8-kubernetes-service-catalog</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes</artifactId>
</dependency>

<!-- Test -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-kubernetes-client</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-fabric8-kubernetes-service-catalog-test-utils</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<configuration>
<noDeps>true</noDeps>
<skip>${skipTests}</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* 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.addons.quarkus.microprofile.config.service.catalog.it;

import java.net.HttpURLConnection;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;

import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.kubernetes.client.KubernetesTestServer;
import io.quarkus.test.kubernetes.client.WithKubernetesTestServer;
import io.restassured.http.ContentType;

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;
import static org.kie.kogito.addons.quarkus.k8s.test.utils.KnativeResourceDiscoveryTestUtil.createServiceIfNotExists;

@QuarkusTest
@WithKubernetesTestServer
class MicroProfileConfigServiceAddonIT {

private static final String NAMESPACE = "default";

private static final String SERVICENAME = "serverless-workflow-greeting-quarkus";

private static WireMockServer wireMockServer;

private static String remoteServiceUrl;

@KubernetesTestServer
KubernetesServer mockServer;

@BeforeAll
static void beforeAll() {
createWiremockServer();
}

@BeforeEach
void beforeEach() {
createServiceIfNotExists(mockServer, "knative/quarkus-greeting.yaml", NAMESPACE, SERVICENAME, remoteServiceUrl);
}

@AfterAll
static void afterAll() {
if (wireMockServer != null) {
wireMockServer.stop();
}
}

@Test
void executeWithEmptyParameters() {
mockExecuteWithEmptyParametersEndpoint();

given()
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
.body("{\"workflowdata\":{}}").when()
.post("/emptyParamsKnativeFunction")
.then()
.statusCode(HttpURLConnection.HTTP_CREATED)
.body("workflowdata.org", is("Acme"))
.body("workflowdata.project", is("Kogito"));
}

private void mockExecuteWithEmptyParametersEndpoint() {
wireMockServer.stubFor(post(urlEqualTo("/emptyParamsKnativeFunction"))
.willReturn(aResponse()
.withStatus(HttpURLConnection.HTTP_OK)
.withHeader("Content-Type", "application/json")
.withJsonBody(JsonNodeFactory.instance.objectNode()
.put("org", "Acme")
.put("project", "Kogito"))));
}

private static void createWiremockServer() {
wireMockServer = new WireMockServer(WireMockConfiguration.wireMockConfig().dynamicPort());
wireMockServer.start();
remoteServiceUrl = wireMockServer.baseUrl();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
annotations:
serving.knative.dev/creator: minikube-user
serving.knative.dev/lastModifier: minikube-user
creationTimestamp: '2022-08-17T13:58:53Z'
generation: 1
name: serverless-workflow-greeting-quarkus
resourceVersion: '43817'
uid: 98530cb6-3274-4d0c-b654-a82645cda058
spec:
template:
metadata:
annotations:
client.knative.dev/updateTimestamp: '2022-08-17T13:58:53Z'
client.knative.dev/user-image: kiegroup/serverless-workflow-greeting-quarkus:1.0
creationTimestamp:
spec:
containerConcurrency: 0
containers:
- image: kiegroup/serverless-workflow-greeting-quarkus:1.0
name: user-container
readinessProbe:
successThreshold: 1
tcpSocket:
port: 0
resources: { }
enableServiceLinks: false
timeoutSeconds: 300
traffic:
- latestRevision: true
percent: 100
status:
address:
url: http://serverless-workflow-greeting-quarkus.test.svc.cluster.local
conditions:
- lastTransitionTime: '2022-08-17T13:59:00Z'
status: 'True'
type: ConfigurationsReady
- lastTransitionTime: '2022-08-17T13:59:00Z'
status: 'True'
type: Ready
- lastTransitionTime: '2022-08-17T13:59:00Z'
status: 'True'
type: RoutesReady
latestCreatedRevisionName: serverless-workflow-greeting-quarkus-00001
latestReadyRevisionName: serverless-workflow-greeting-quarkus-00001
observedGeneration: 1
traffic:
- latestRevision: true
percent: 100
revisionName: serverless-workflow-greeting-quarkus-00001
url: http://serverless-workflow-greeting-quarkus.test.10.99.154.147.sslip.io
21 changes: 21 additions & 0 deletions quarkus/addons/microprofile-config-service-catalog/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.kie.kogito</groupId>
<artifactId>kogito-addons-quarkus-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>kogito-addons-quarkus-microprofile-config-service-catalog-parent</artifactId>
<name>Kogito Add-On MicroProfile Config Service Catalog - Parent</name>
<packaging>pom</packaging>

<modules>
<module>deployment</module>
<module>runtime</module>
Comment on lines +17 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to register these modules in the kogito-bom. Take a look at https://github.com/kiegroup/kogito-runtimes/blob/e37b961eb5fec25b4545a7937b5f067fee331ade/kogito-bom/pom.xml#L318 to use the Fabric8 implementation as a reference.

<module>integration-tests</module>
</modules>
</project>
Loading
Loading