From 354ad9e289f986d3702ddb8bed190cd5c3226c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Vav=C5=99=C3=ADk?= Date: Thu, 21 Mar 2024 23:56:17 +0100 Subject: [PATCH] Drop Helm support --- .github/workflows/daily.yaml | 52 ---- .github/workflows/pr.yaml | 41 --- README.md | 2 - examples/pom.xml | 2 - examples/quarkus-helm/pom.xml | 169 ---------- .../src/main/docker/Dockerfile.jvm | 94 ------ .../src/main/docker/Dockerfile.native | 27 -- .../java/io/quarkus/qe/GreetingResource.java | 16 - .../src/main/resources/application.properties | 12 - .../quarkus/qe/helm/CommonHelmScenarios.java | 119 ------- .../helm/KubernetesQuarkusHelmClientIT.java | 29 -- .../qe/helm/OpenShiftQuarkusHelmClientIT.java | 28 -- .../qe/helm/QuarkusHelmFileClientIT.java | 44 --- .../helm/QuarkusKubernetesHelmClientIT.java | 52 ---- .../qe/helm/QuarkusOpenShiftHelmClientIT.java | 64 ---- .../test/resources/helmfiles/helmfile.yaml | 10 - .../helmfiles/postgresql-values.yaml | 0 .../src/test/resources/test.properties | 2 - pom.xml | 6 - quarkus-test-helm/pom.xml | 38 --- .../io/quarkus/test/bootstrap/HelmUtils.java | 41 --- .../test/bootstrap/QuarkusHelmClient.java | 293 ------------------ .../QuarkusHelmExtensionBootstrap.java | 35 --- .../test/bootstrap/QuarkusHelmFileClient.java | 101 ------ .../QuarkusHelmFileExtensionBootstrap.java | 34 -- ....quarkus.test.bootstrap.ExtensionBootstrap | 2 - .../io/quarkus/test/QuarkusHelmClientIT.java | 31 -- .../src/test/resources/test.properties | 2 - 28 files changed, 1346 deletions(-) delete mode 100644 examples/quarkus-helm/pom.xml delete mode 100644 examples/quarkus-helm/src/main/docker/Dockerfile.jvm delete mode 100644 examples/quarkus-helm/src/main/docker/Dockerfile.native delete mode 100644 examples/quarkus-helm/src/main/java/io/quarkus/qe/GreetingResource.java delete mode 100644 examples/quarkus-helm/src/main/resources/application.properties delete mode 100644 examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/CommonHelmScenarios.java delete mode 100644 examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/KubernetesQuarkusHelmClientIT.java delete mode 100644 examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/OpenShiftQuarkusHelmClientIT.java delete mode 100644 examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusHelmFileClientIT.java delete mode 100644 examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusKubernetesHelmClientIT.java delete mode 100644 examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusOpenShiftHelmClientIT.java delete mode 100644 examples/quarkus-helm/src/test/resources/helmfiles/helmfile.yaml delete mode 100644 examples/quarkus-helm/src/test/resources/helmfiles/postgresql-values.yaml delete mode 100644 examples/quarkus-helm/src/test/resources/test.properties delete mode 100644 quarkus-test-helm/pom.xml delete mode 100644 quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/HelmUtils.java delete mode 100644 quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmClient.java delete mode 100644 quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmExtensionBootstrap.java delete mode 100644 quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmFileClient.java delete mode 100644 quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmFileExtensionBootstrap.java delete mode 100644 quarkus-test-helm/src/main/resources/META-INF/services/io.quarkus.test.bootstrap.ExtensionBootstrap delete mode 100644 quarkus-test-helm/src/test/java/io/quarkus/test/QuarkusHelmClientIT.java delete mode 100644 quarkus-test-helm/src/test/resources/test.properties diff --git a/.github/workflows/daily.yaml b/.github/workflows/daily.yaml index 8d940b89f..9063374ac 100644 --- a/.github/workflows/daily.yaml +++ b/.github/workflows/daily.yaml @@ -53,16 +53,6 @@ jobs: java-version: ${{ matrix.java }} check-latest: true cache: 'maven' - - name: Install Helm client - uses: azure/setup-helm@v4 - with: - version: v3.9.0 - id: install-helm - - name: Setup helmfile - uses: mamezou-tech/setup-helmfile@v2.0.0 - with: - helmfile-version: "v0.145.2" - install-helm: no - name: Build run: | MAVEN_PROFILES="-Pframework,examples" @@ -102,16 +92,6 @@ jobs: check-latest: true cache: 'maven' id: install-jdk - - name: Install Helm client - uses: azure/setup-helm@v4 - with: - version: v3.9.0 - id: install-helm - - name: Setup helmfile - uses: mamezou-tech/setup-helmfile@v2.0.0 - with: - helmfile-version: "v0.145.2" - install-helm: no - name: Download Maven Repo uses: actions/download-artifact@v4 with: @@ -212,16 +192,6 @@ jobs: java-version: ${{ matrix.java }} check-latest: true cache: 'maven' - - name: Install Helm client - uses: azure/setup-helm@v4 - with: - version: v3.9.0 - id: install-helm - - name: Setup helmfile - uses: mamezou-tech/setup-helmfile@v2.0.0 - with: - helmfile-version: "v0.145.2" - install-helm: no - name: Download Maven Repo uses: actions/download-artifact@v4 with: @@ -264,17 +234,6 @@ jobs: java-version: ${{ matrix.java }} check-latest: true cache: 'maven' - - name: Install Helm client - uses: azure/setup-helm@v4 - with: - version: v3.9.0 - id: install-helm - - uses: MinoruSekine/setup-scoop@main - with: - add_extras_bucket: 'true' - - name: Install helmfile through windows scoop - shell: bash - run: scoop install helmfile - name: Download Maven Repo uses: actions/download-artifact@v4 with: @@ -318,17 +277,6 @@ jobs: java-version: ${{ matrix.java }} check-latest: true cache: 'maven' - - name: Install Helm client - uses: azure/setup-helm@v4 - with: - version: v3.9.0 - id: install-helm - - uses: MinoruSekine/setup-scoop@main - with: - add_extras_bucket: 'true' - - name: Install helmfile through windows scoop - shell: bash - run: scoop install helmfile - name: Download Sysinternals Handle program used for native race debugging shell: pwsh run: Invoke-WebRequest https://download.sysinternals.com/files/Handle.zip -OutFile .\handle.zip diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 7f2932290..8d7afc89e 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -86,16 +86,6 @@ jobs: java-version: ${{ matrix.java }} check-latest: true cache: 'maven' - - name: Install Helm client - uses: azure/setup-helm@v4 - with: - version: v3.9.0 - id: install - - name: Setup helmfile - uses: mamezou-tech/setup-helmfile@v2.0.0 - with: - helmfile-version: "v0.145.2" - install-helm: no - name: Download Maven Repo uses: actions/download-artifact@v4 with: @@ -141,16 +131,6 @@ jobs: java-version: ${{ matrix.java }} check-latest: true cache: 'maven' - - name: Install Helm client - uses: azure/setup-helm@v4 - with: - version: v3.9.0 - id: install - - name: Setup helmfile - uses: mamezou-tech/setup-helmfile@v2.0.0 - with: - helmfile-version: "v0.145.2" - install-helm: no - name: Download Maven Repo uses: actions/download-artifact@v4 with: @@ -211,16 +191,6 @@ jobs: java-version: ${{ matrix.java }} check-latest: true cache: 'maven' - - name: Install Helm client - uses: azure/setup-helm@v4 - with: - version: v3.9.0 - id: install-helm - - name: Setup helmfile - uses: mamezou-tech/setup-helmfile@v2.0.0 - with: - helmfile-version: "v0.145.2" - install-helm: no - name: Download Maven Repo uses: actions/download-artifact@v4 with: @@ -266,17 +236,6 @@ jobs: java-version: ${{ matrix.java }} check-latest: true cache: 'maven' - - name: Install Helm client - uses: azure/setup-helm@v4 - with: - version: v3.9.0 - id: install - - uses: MinoruSekine/setup-scoop@main - with: - add_extras_bucket: 'true' - - name: Install helmfile - shell: bash - run: scoop install helmfile - name: Download Maven Repo uses: actions/download-artifact@v4 with: diff --git a/README.md b/README.md index 45c7cb7eb..8c6d5cd2f 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,6 @@ Main features: - JDK 17+ - Maven 3+ - Docker -- Helm -- Helmfiles - OCP/K8s client # Getting Started diff --git a/examples/pom.xml b/examples/pom.xml index 900518955..cbb010794 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -12,8 +12,6 @@ pom quarkus-cli - - pingpong restclient greetings diff --git a/examples/quarkus-helm/pom.xml b/examples/quarkus-helm/pom.xml deleted file mode 100644 index 1911773a7..000000000 --- a/examples/quarkus-helm/pom.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - 4.0.0 - - io.quarkus.qe - quarkus-examples-parent - 1.3.1.Beta27-SNAPSHOT - ../pom.xml - - examples-quarkus-helm - Quarkus - Test Framework - Examples - Quarkus HELM - - 1.1.0 - - - - - io.quarkus - quarkus-kubernetes - - - io.quarkus - quarkus-openshift - - - io.quarkus - quarkus-resteasy - - - io.quarkus - quarkus-container-image-docker - - - io.quarkiverse.helm - quarkus-helm - ${quarkus-helm.version} - - - io.quarkus.qe - quarkus-test-core - test - - - io.quarkus.qe - quarkus-test-helm - test - - - io.quarkus.qe - quarkus-test-openshift - test - - - io.quarkus.qe - quarkus-test-kubernetes - test - - - - - - ${quarkus.platform.group-id} - quarkus-maven-plugin - ${quarkus.platform.version} - true - - - - build - generate-code - generate-code-tests - - - - - - - - - - openshift - - - openshift - - - - **/OpenShift*IT.java - no - - - - - ${quarkus.platform.group-id} - quarkus-maven-plugin - ${quarkus.platform.version} - true - - - - build - generate-code - generate-code-tests - - - - - - true - true - - - - - - - - - kubernetes - - - kubernetes - - - - **/Kubernetes*IT.java - no - - - - - ${quarkus.platform.group-id} - quarkus-maven-plugin - ${quarkus.platform.version} - true - - - - build - generate-code - generate-code-tests - - - - - - true - true - - - - - - - - - - native - - - native - - - - true - - - - diff --git a/examples/quarkus-helm/src/main/docker/Dockerfile.jvm b/examples/quarkus-helm/src/main/docker/Dockerfile.jvm deleted file mode 100644 index 8747762ea..000000000 --- a/examples/quarkus-helm/src/main/docker/Dockerfile.jvm +++ /dev/null @@ -1,94 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode -# -# Before building the container image run: -# -# ./mvnw package -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/helm-quickstart-jvm . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/helm-quickstart-jvm -# -# If you want to include the debug port into your docker image -# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005 -# -# Then run the container using : -# -# docker run -i --rm -p 8080:8080 quarkus/helm-quickstart-jvm -# -# This image uses the `run-java.sh` script to run the application. -# This scripts computes the command line to execute your Java application, and -# includes memory/GC tuning. -# You can configure the behavior using the following environment properties: -# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") -# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options -# in JAVA_OPTS (example: "-Dsome.property=foo") -# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is -# used to calculate a default maximal heap memory based on a containers restriction. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio -# of the container available memory as set here. The default is `50` which means 50% -# of the available memory is used as an upper boundary. You can skip this mechanism by -# setting this value to `0` in which case no `-Xmx` option is added. -# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This -# is used to calculate a default initial heap memory based on the maximum heap memory. -# If used in a container without any memory constraints for the container then this -# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio -# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` -# is used as the initial heap size. You can skip this mechanism by setting this value -# to `0` in which case no `-Xms` option is added (example: "25") -# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. -# This is used to calculate the maximum value of the initial heap memory. If used in -# a container without any memory constraints for the container then this option has -# no effect. If there is a memory constraint then `-Xms` is limited to the value set -# here. The default is 4096MB which means the calculated value of `-Xms` never will -# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") -# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output -# when things are happening. This option, if set to true, will set -# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). -# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: -# true"). -# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). -# - CONTAINER_CORE_LIMIT: A calculated core limit as described in -# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") -# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). -# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. -# (example: "20") -# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. -# (example: "40") -# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. -# (example: "4") -# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus -# previous GC times. (example: "90") -# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") -# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") -# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should -# contain the necessary JRE command-line options to specify the required GC, which -# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). -# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") -# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") -# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be -# accessed directly. (example: "foo.example.com,bar.example.com") -# -### -FROM registry.access.redhat.com/ubi8/openjdk-17:latest - -ENV LANGUAGE='en_US:en' - - -# We make four distinct layers so if there are application changes the library layers can be re-used -COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ -COPY --chown=185 target/quarkus-app/*.jar /deployments/ -COPY --chown=185 target/quarkus-app/app/ /deployments/app/ -COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ - -EXPOSE 8080 -USER 185 -ENV AB_JOLOKIA_OFF="" -ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" -ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" - diff --git a/examples/quarkus-helm/src/main/docker/Dockerfile.native b/examples/quarkus-helm/src/main/docker/Dockerfile.native deleted file mode 100644 index 509a9f890..000000000 --- a/examples/quarkus-helm/src/main/docker/Dockerfile.native +++ /dev/null @@ -1,27 +0,0 @@ -#### -# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. -# -# Before building the container image run: -# -# ./mvnw package -Pnative -# -# Then, build the image with: -# -# docker build -f src/main/docker/Dockerfile.native -t quarkus/helm-quickstart . -# -# Then run the container using: -# -# docker run -i --rm -p 8080:8080 quarkus/helm-quickstart -# -### -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9 -WORKDIR /work/ -RUN chown 1001 /work \ - && chmod "g+rwX" /work \ - && chown 1001:root /work -COPY --chown=1001:root target/*-runner /work/application - -EXPOSE 8080 -USER 1001 - -CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/examples/quarkus-helm/src/main/java/io/quarkus/qe/GreetingResource.java b/examples/quarkus-helm/src/main/java/io/quarkus/qe/GreetingResource.java deleted file mode 100644 index e1ccd7b20..000000000 --- a/examples/quarkus-helm/src/main/java/io/quarkus/qe/GreetingResource.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.quarkus.qe; - -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.core.MediaType; - -@Path("/greeting") -public class GreetingResource { - - @GET - @Produces(MediaType.TEXT_PLAIN) - public String sayHello() { - return "Hello World!"; - } -} diff --git a/examples/quarkus-helm/src/main/resources/application.properties b/examples/quarkus-helm/src/main/resources/application.properties deleted file mode 100644 index a5756daad..000000000 --- a/examples/quarkus-helm/src/main/resources/application.properties +++ /dev/null @@ -1,12 +0,0 @@ -# Application properties - -quarkus.openshift.route.expose=true -quarkus.kubernetes.ingress.expose=true - -quarkus.container-image.registry=quay.io -quarkus.container-image.group=quarkusqeteam -quarkus.container-image.name=examples-quarkus-helm -quarkus.container-image.tag=v1 -quarkus.helm.version=v1 -quarkus.container-image.builder=docker - diff --git a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/CommonHelmScenarios.java b/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/CommonHelmScenarios.java deleted file mode 100644 index 23d3cc91c..000000000 --- a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/CommonHelmScenarios.java +++ /dev/null @@ -1,119 +0,0 @@ -package io.quarkus.qe.helm; - -import static java.net.HttpURLConnection.HTTP_OK; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.hasItemInArray; -import static org.hamcrest.Matchers.is; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.time.Duration; -import java.util.List; -import java.util.stream.Collectors; - -import jakarta.inject.Inject; - -import org.hamcrest.Matchers; -import org.junit.jupiter.api.Test; - -import io.quarkus.test.bootstrap.QuarkusHelmClient; -import io.quarkus.test.bootstrap.inject.OpenShiftClient; -import io.restassured.RestAssured; - -public abstract class CommonHelmScenarios { - - protected abstract QuarkusHelmClient getHelmClient(); - - private static int TIMEOUT = 1; - - @Inject - static OpenShiftClient ocpClient; - - protected abstract String getPlatformName(); - - @Test - public void shouldInstallQuarkusAppThroughHelm() { - QuarkusHelmClient helmClient = getHelmClient(); - String chartName = "examples-quarkus-helm"; - - String chartFolderName = helmClient.getWorkingDirectory().getAbsolutePath() + "/helm/" + getPlatformName() + "/" - + chartName; - QuarkusHelmClient.Result chartResultCmd = helmClient.installChart(chartName, chartFolderName); - thenSucceed(chartResultCmd); - - String appURL = ocpClient.url(chartName).getRestAssuredStyleUri(); - helmClient.waitToReadiness(appURL + "/greeting", Duration.ofMinutes(TIMEOUT)); - - RestAssured.given().baseUri(appURL).get("/greeting") - .then().statusCode(HTTP_OK) - .body(is("Hello World!")); - - List chartNames = helmClient.getChartsNames(chartName); - assertTrue(chartNames.size() > 0, "Chart " + chartName + " not found. Installation fail"); - assertThat(chartNames.toArray(), hasItemInArray(chartName)); - - assertTrue(helmClient.chartDependencyUpdate(chartFolderName).isSuccessful()); - assertTrue(helmClient.chartDependencyBuild(chartFolderName).isSuccessful()); - } - - @Test - public void shouldInstallNewEmptyHelmChartManually() { - QuarkusHelmClient helmClient = getHelmClient(); - String chartName = "mychart-manually"; - String chartFolderName = helmClient.getWorkingDirectory().getAbsolutePath() + "/" + chartName; - QuarkusHelmClient.Result chartResultCmd = helmClient.run("create", chartName); - thenSucceed(chartResultCmd); - - chartResultCmd = helmClient.run("install", chartName, chartFolderName); - thenSucceed(chartResultCmd); - } - - @Test - public void shouldInstallNewEmptyHelmChartWithShortcuts() { - QuarkusHelmClient helmClient = getHelmClient(); - String chartName = "mychart-shortcuts"; - QuarkusHelmClient.NewChartResult newChartResult = helmClient.createEmptyChart(chartName); - thenSucceed(newChartResult); - - QuarkusHelmClient.Result chartResultCmd = helmClient.installChart(chartName, newChartResult.getChartFolderPath()); - thenSucceed(chartResultCmd); - - List charts = helmClient.getCharts(); - assertTrue(charts.size() > 0, "Chart " + chartName + " not found. Installation fail"); - List chartNames = charts.stream() - .map(QuarkusHelmClient.ChartListResult::getName) - .map(String::trim) - .collect(Collectors.toList()); - assertThat(chartNames.toArray(), hasItemInArray(chartName)); - } - - @Test - public void shouldUninstallHelmChart() { - QuarkusHelmClient helmClient = getHelmClient(); - String chartName = "mychart-remove"; - QuarkusHelmClient.NewChartResult newChartResult = helmClient.createEmptyChart(chartName); - thenSucceed(newChartResult); - - QuarkusHelmClient.Result chartResultCmd = helmClient.installChart(chartName, newChartResult.getChartFolderPath()); - thenSucceed(chartResultCmd); - List charts = helmClient.getCharts(); - List chartNames = charts.stream() - .map(QuarkusHelmClient.ChartListResult::getName) - .map(String::trim) - .collect(Collectors.toList()); - assertThat(chartNames.toArray(), hasItemInArray(chartName)); - - chartResultCmd = helmClient.uninstallChart(chartName); - thenSucceed(chartResultCmd); - charts = helmClient.getCharts(); - chartNames = charts.stream().map(QuarkusHelmClient.ChartListResult::getName).map(String::trim) - .collect(Collectors.toList()); - assertThat(chartNames, Matchers.not(contains(chartName))); - } - - private void thenSucceed(QuarkusHelmClient.Result chartResultCmd) { - assertTrue( - chartResultCmd.isSuccessful(), - String.format("Command %s fails", chartResultCmd.getCommandExecuted())); - } -} diff --git a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/KubernetesQuarkusHelmClientIT.java b/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/KubernetesQuarkusHelmClientIT.java deleted file mode 100644 index 44f6a379d..000000000 --- a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/KubernetesQuarkusHelmClientIT.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.quarkus.qe.helm; - -import jakarta.inject.Inject; - -import org.junit.jupiter.api.Disabled; - -import io.quarkus.test.bootstrap.QuarkusHelmClient; -import io.quarkus.test.scenarios.KubernetesScenario; -import io.quarkus.test.scenarios.annotations.DisabledOnNative; - -@KubernetesScenario -//TODO OCP user can't create a k8s namespace -@Disabled -@DisabledOnNative // Helm is concerned just about image name, Native compilation is not relevant -public class KubernetesQuarkusHelmClientIT extends CommonHelmScenarios { - - @Inject - static QuarkusHelmClient helmClient; - - @Override - protected QuarkusHelmClient getHelmClient() { - return helmClient; - } - - @Override - protected String getPlatformName() { - return "kubernetes"; - } -} diff --git a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/OpenShiftQuarkusHelmClientIT.java b/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/OpenShiftQuarkusHelmClientIT.java deleted file mode 100644 index 3a13c270a..000000000 --- a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/OpenShiftQuarkusHelmClientIT.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.quarkus.qe.helm; - -import jakarta.inject.Inject; - -import org.junit.jupiter.api.condition.EnabledIf; - -import io.quarkus.test.bootstrap.QuarkusHelmClient; -import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.scenarios.annotations.DisabledOnNative; - -@OpenShiftScenario -@DisabledOnNative // Helm is concerned just about image name, Native compilation is not relevant -@EnabledIf(value = "io.quarkus.test.bootstrap.HelmUtils#isHelmInstalled", disabledReason = "Helm needs to be locally installed") -public class OpenShiftQuarkusHelmClientIT extends CommonHelmScenarios { - - @Inject - static QuarkusHelmClient helmClient; - - @Override - protected QuarkusHelmClient getHelmClient() { - return helmClient; - } - - @Override - protected String getPlatformName() { - return "openshift"; - } -} diff --git a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusHelmFileClientIT.java b/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusHelmFileClientIT.java deleted file mode 100644 index e8acffb10..000000000 --- a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusHelmFileClientIT.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.quarkus.qe.helm; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.nio.file.Path; -import java.nio.file.Paths; - -import jakarta.inject.Inject; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIf; - -import io.quarkus.test.bootstrap.QuarkusHelmFileClient; -import io.quarkus.test.scenarios.QuarkusScenario; -import io.quarkus.test.scenarios.annotations.DisabledOnNative; - -@QuarkusScenario -@DisabledOnNative // Helm is concerned just about image name, Native compilation is not relevant -@EnabledIf(value = "io.quarkus.test.bootstrap.HelmUtils#isHelmFileInstalled", disabledReason = "Helmfile needs to be locally installed") -public class QuarkusHelmFileClientIT { - - private static Path helmfilesFolder; - - @Inject - static QuarkusHelmFileClient helmFileClient; - - @BeforeAll - public static void tearUp() { - helmfilesFolder = Paths.get("src", "test", "resources", "helmfiles").toAbsolutePath(); - } - - @Test - public void verifyHelmFileInjection() { - QuarkusHelmFileClient.Result helmCmdResult = helmFileClient.run(helmfilesFolder.toAbsolutePath(), "-version"); - assertTrue( - helmCmdResult.isSuccessful(), - String.format("Command %s fails", helmCmdResult.getCommandExecuted())); - assertFalse( - helmCmdResult.getOutput().isEmpty(), - "Unexpected helm version"); - } -} diff --git a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusKubernetesHelmClientIT.java b/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusKubernetesHelmClientIT.java deleted file mode 100644 index a05246e63..000000000 --- a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusKubernetesHelmClientIT.java +++ /dev/null @@ -1,52 +0,0 @@ -package io.quarkus.qe.helm; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertFalse; - -import java.io.FileNotFoundException; -import java.util.Map; - -import jakarta.inject.Inject; - -import org.junit.jupiter.api.Test; - -import io.quarkus.test.bootstrap.QuarkusHelmClient; -import io.quarkus.test.scenarios.QuarkusScenario; -import io.quarkus.test.scenarios.annotations.DisabledOnNative; - -@QuarkusScenario -@DisabledOnNative // Helm is concerned just about image name, Native compilation is not relevant -public class QuarkusKubernetesHelmClientIT { - - @Inject - static QuarkusHelmClient helmClient; - - @Test - public void verifyChartValuesYamlContent() throws FileNotFoundException { - String chartName = "examples-quarkus-helm"; - String chartFolderName = helmClient.getWorkingDirectory().getAbsolutePath() + "/helm/kubernetes/" + chartName; - Map values = (Map) helmClient.getChartValues(chartFolderName).get("app"); - assertFalse(values.get("image").isEmpty(), "Chart values.yaml host should not be empty"); - } - - @Test - public void verifyIngressExist() throws FileNotFoundException { - String chartName = "examples-quarkus-helm"; - String templates = helmClient.getWorkingDirectory().getAbsolutePath() + "/helm/kubernetes/" + chartName + "/templates"; - assertDoesNotThrow(() -> helmClient.getRawYaml("ingress.yaml", templates), "Ingress not generated"); - } - - @Test - public void verifyDeploymentExist() { - String chartName = "examples-quarkus-helm"; - String templates = helmClient.getWorkingDirectory().getAbsolutePath() + "/helm/kubernetes/" + chartName + "/templates"; - assertDoesNotThrow(() -> helmClient.getRawYaml("deployment.yaml", templates), "Deployment not generated"); - } - - @Test - public void verifyServiceExist() { - String chartName = "examples-quarkus-helm"; - String templates = helmClient.getWorkingDirectory().getAbsolutePath() + "/helm/kubernetes/" + chartName + "/templates"; - assertDoesNotThrow(() -> helmClient.getRawYaml("service.yaml", templates), "Service not generated"); - } -} diff --git a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusOpenShiftHelmClientIT.java b/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusOpenShiftHelmClientIT.java deleted file mode 100644 index 6be367c6f..000000000 --- a/examples/quarkus-helm/src/test/java/io/quarkus/qe/helm/QuarkusOpenShiftHelmClientIT.java +++ /dev/null @@ -1,64 +0,0 @@ -package io.quarkus.qe.helm; - -import static org.junit.jupiter.api.Assertions.*; - -import java.io.FileNotFoundException; -import java.util.Map; - -import jakarta.inject.Inject; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIf; - -import io.quarkus.test.bootstrap.QuarkusHelmClient; -import io.quarkus.test.scenarios.QuarkusScenario; -import io.quarkus.test.scenarios.annotations.DisabledOnNative; - -@QuarkusScenario -@DisabledOnNative // Helm is concerned just about image name, Native compilation is not relevant -public class QuarkusOpenShiftHelmClientIT { - - @Inject - static QuarkusHelmClient helmClient; - - @Test - @EnabledIf(value = "io.quarkus.test.bootstrap.HelmUtils#isHelmInstalled", disabledReason = "Helm needs to be locally installed") - public void verifyHelmInjection() { - QuarkusHelmClient.Result helmCmdResult = helmClient.run("version"); - assertTrue( - helmCmdResult.isSuccessful(), - String.format("Command %s fails", helmCmdResult.getCommandExecuted())); - assertFalse( - helmCmdResult.getOutput().isEmpty(), - "Unexpected helm version"); - } - - @Test - public void verifyChartValuesYamlContent() throws FileNotFoundException { - String chartName = "examples-quarkus-helm"; - String chartFolderName = helmClient.getWorkingDirectory().getAbsolutePath() + "/helm/openshift/" + chartName; - Map values = (Map) helmClient.getChartValues(chartFolderName).get("app"); - assertFalse(values.get("image").isEmpty(), "Chart values.yaml host should not be empty"); - } - - @Test - public void verifyRouteExist() { - String chartName = "examples-quarkus-helm"; - String templates = helmClient.getWorkingDirectory().getAbsolutePath() + "/helm/openshift/" + chartName + "/templates"; - assertDoesNotThrow(() -> helmClient.getRawYaml("route.yaml", templates), "Route not generated"); - } - - @Test - public void verifyDeploymentExist() { - String chartName = "examples-quarkus-helm"; - String templates = helmClient.getWorkingDirectory().getAbsolutePath() + "/helm/openshift/" + chartName + "/templates"; - assertDoesNotThrow(() -> helmClient.getRawYaml("deploymentconfig.yaml", templates), "Deployment config not generated"); - } - - @Test - public void verifyServiceExist() { - String chartName = "examples-quarkus-helm"; - String templates = helmClient.getWorkingDirectory().getAbsolutePath() + "/helm/openshift/" + chartName + "/templates"; - assertDoesNotThrow(() -> helmClient.getRawYaml("service.yaml", templates), "Service not generated"); - } -} diff --git a/examples/quarkus-helm/src/test/resources/helmfiles/helmfile.yaml b/examples/quarkus-helm/src/test/resources/helmfiles/helmfile.yaml deleted file mode 100644 index 7467d5993..000000000 --- a/examples/quarkus-helm/src/test/resources/helmfiles/helmfile.yaml +++ /dev/null @@ -1,10 +0,0 @@ -repositories: - - name: bitnami - url: https://charts.bitnami.com/bitnami - -charts: - - name: postgresql - chart: "bitnami/postgresql" - values: - - postgresql-values.yaml - diff --git a/examples/quarkus-helm/src/test/resources/helmfiles/postgresql-values.yaml b/examples/quarkus-helm/src/test/resources/helmfiles/postgresql-values.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/quarkus-helm/src/test/resources/test.properties b/examples/quarkus-helm/src/test/resources/test.properties deleted file mode 100644 index f0176304c..000000000 --- a/examples/quarkus-helm/src/test/resources/test.properties +++ /dev/null @@ -1,2 +0,0 @@ -ts.app.log.enable=false -ts.global.generated-service.enabled=false diff --git a/pom.xml b/pom.xml index 9aae7b13f..1f604b8a4 100644 --- a/pom.xml +++ b/pom.xml @@ -104,11 +104,6 @@ quarkus-test-cli ${project.version} - - io.quarkus.qe - quarkus-test-helm - ${project.version} - io.quarkus.qe quarkus-test-images @@ -392,7 +387,6 @@ quarkus-test-core quarkus-test-cli - quarkus-test-helm quarkus-test-containers quarkus-test-images quarkus-test-kubernetes diff --git a/quarkus-test-helm/pom.xml b/quarkus-test-helm/pom.xml deleted file mode 100644 index d8db6c4d8..000000000 --- a/quarkus-test-helm/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - 4.0.0 - - io.quarkus.qe - quarkus-test-parent - 1.4.3.Beta8-SNAPSHOT - - quarkus-test-helm - Quarkus - Test Framework - HELM - - - io.quarkus.qe - quarkus-test-core - - - org.yaml - snakeyaml - - - io.quarkus - quarkus-builder - provided - - - io.quarkus.qe - quarkus-test-openshift - true - provided - - - io.quarkus.qe - quarkus-test-kubernetes - true - provided - - - \ No newline at end of file diff --git a/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/HelmUtils.java b/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/HelmUtils.java deleted file mode 100644 index d911894bf..000000000 --- a/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/HelmUtils.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.quarkus.test.bootstrap; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.jupiter.api.condition.OS; - -import io.quarkus.test.utils.Command; - -public final class HelmUtils { - - private HelmUtils() { - } - - public static boolean isHelmInstalled() { - return validateCommandExecution(QuarkusHelmClient.COMMAND.get(), "version"); - } - - public static boolean isHelmFileInstalled() { - return validateCommandExecution(QuarkusHelmFileClient.COMMAND.get(), "-version"); - } - - private static boolean validateCommandExecution(String command, String... args) { - if (OS.WINDOWS.isCurrentOs()) { - command += ".exe"; - } - - List effectiveCommand = new ArrayList<>(); - effectiveCommand.add(command); - effectiveCommand.addAll(1, Arrays.asList(args)); - - try { - new Command(effectiveCommand).runAndWait(); - return true; - } catch (IOException | InterruptedException e) { - return false; - } - } -} diff --git a/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmClient.java b/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmClient.java deleted file mode 100644 index d884d4e80..000000000 --- a/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmClient.java +++ /dev/null @@ -1,293 +0,0 @@ -package io.quarkus.test.bootstrap; - -import static org.awaitility.Awaitility.await; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URI; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.time.Duration; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.junit.jupiter.api.Assertions; -import org.yaml.snakeyaml.Yaml; - -import io.quarkus.test.configuration.PropertyLookup; -import io.quarkus.test.logging.FileLoggingHandler; -import io.quarkus.test.logging.Log; -import io.quarkus.test.utils.FileUtils; -import io.quarkus.test.utils.ProcessBuilderProvider; - -public class QuarkusHelmClient { - - public static final String COMMAND_LOG_FILE = "quarkus-helm-command.out"; - static final PropertyLookup COMMAND = new PropertyLookup("ts.quarkus.helm.cmd", "helm"); - private static final Path TARGET = Paths.get("target"); - private static final int NAME_POS = 0; - private static final int NAMESPACE_POS = 1; - private static final int REVISION_POS = 2; - private static final int UPDATED_POS = 3; - private static final int STATUS_POS = 4; - private static final int CHART_VERSION_POS = 5; - private static final int EXPECTED_CHART_FIELDS_AMOUNT = 5; - - private final ScenarioContext context; - private Yaml yaml = new Yaml(); - - public QuarkusHelmClient(ScenarioContext ctx) { - this.context = ctx; - } - - public Result run(String... args) { - return runCliAndWait(args); - } - - public File getWorkingDirectory() { - return TARGET.toFile(); - } - - public NewChartResult createEmptyChart(String chartName) { - Result chartResultCmd = runCliAndWait("create", chartName); - return new NewChartResult(chartResultCmd, chartName, getWorkingDirectory().getAbsolutePath()); - } - - public Result installChart(String chartName, String chartFolderPath) { - return runCliAndWait("install", chartName, chartFolderPath); - } - - public Result updateChart(String chartName, String chartFolderPath) { - return runCliAndWait("update", chartName, chartFolderPath); - } - - public Result uninstallChart(String chartName) { - return runCliAndWait("uninstall", chartName); - } - - public List getCharts() { - Result result = runCliAndWait("list"); - String[] charts = result.getOutput().split(System.lineSeparator()); - List chartList = new ArrayList<>(); - if (charts.length > 0) { - // skip helm.list header -> pos(0) - for (int i = 1; i < charts.length; i++) { - String[] chartContent = charts[i].split("\t"); - if (chartContent.length >= EXPECTED_CHART_FIELDS_AMOUNT) { - ChartListResult chartItem = new ChartListResult(result); - chartItem.setName(chartContent[NAME_POS]); - chartItem.setNamespace(chartContent[NAMESPACE_POS]); - chartItem.setRevision(chartContent[REVISION_POS]); - chartItem.setUpdated(chartContent[UPDATED_POS]); - chartItem.setStatus(chartContent[STATUS_POS]); - chartItem.setChartVersion(chartContent[CHART_VERSION_POS]); - chartList.add(chartItem); - } else { - Log.warn("Unexpected 'helm list' response format"); - } - } - } - return chartList; - } - - public List getChartsNames(String chartName) { - List charts = getCharts(); - return charts.stream() - .map(QuarkusHelmClient.ChartListResult::getName) - .map(String::trim) - .collect(Collectors.toList()); - } - - public Result chartDependencyUpdate(String chartFullPath) { - return runCliAndWait("dependency", "update", chartFullPath); - } - - public Result chartDependencyBuild(String chartFullPath) { - return runCliAndWait("dependency", "build", chartFullPath); - } - - public Map getChartValues(String chartFolderPath) throws FileNotFoundException { - return getRawYaml("values.yaml", chartFolderPath); - } - - public Map getRawYaml(String yamlNameExtension, String chartFolderPath) throws FileNotFoundException { - InputStream inputStream = new FileInputStream(chartFolderPath + "/" + yamlNameExtension); - return yaml.load(inputStream); - } - - public void waitToReadiness(String fullReadinessPath, Duration atMost) { - await().ignoreExceptions().atMost(atMost) - .untilAsserted(() -> { - URI uri = URI.create(fullReadinessPath); - HttpURLConnection con = (HttpURLConnection) uri.toURL().openConnection(); - try { - con.setRequestMethod("GET"); - con.connect(); - Assertions.assertTrue(con.getResponseCode() == HttpURLConnection.HTTP_OK); - } finally { - con.disconnect(); - } - }); - } - - private Result runCliAndWait(String... args) { - return runCliAndWait(TARGET, args); - } - - private Result runCliAndWait(Path workingDirectory, String... args) { - Result result = new Result(); - File output = workingDirectory.resolve(COMMAND_LOG_FILE).toFile(); - - try (FileLoggingHandler loggingHandler = new FileLoggingHandler(output)) { - loggingHandler.startWatching(); - List cmd = buildCmd(args); - result.commandExecuted = cmd.stream().collect(Collectors.joining(" ")); - Log.info(result.commandExecuted); - Process process = runCli(workingDirectory, output, cmd); - result.exitCode = process.waitFor(); - } catch (Exception e) { - e.printStackTrace(); - Log.warn("Failed to run Quarkus Helm command. Caused by: " + e.getMessage()); - result.exitCode = 1; - } - - result.output = FileUtils.loadFile(output).trim(); - FileUtils.deleteFileContent(output); - return result; - } - - private List buildCmd(String... args) { - List cmd = new ArrayList<>(); - cmd.addAll(Arrays.asList(COMMAND.get().split(" "))); - cmd.addAll(Arrays.asList(args)); - return cmd; - } - - private Process runCli(Path workingDirectory, File logOutput, List cmd) { - try { - return ProcessBuilderProvider.command(cmd) - .redirectErrorStream(true) - .redirectOutput(logOutput) - .directory(workingDirectory.toFile()) - .start(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public class Result { - - private static final int EXIT_SUCCESS = 0; - - protected int exitCode; - protected String output; - protected String commandExecuted; - - public int getExitCode() { - return exitCode; - } - - public String getOutput() { - return output; - } - - public boolean isSuccessful() { - return EXIT_SUCCESS == exitCode; - } - - public String getCommandExecuted() { - return commandExecuted; - } - } - - public class NewChartResult extends Result { - - private String chartFolderPath; - private String chartName; - - public NewChartResult(Result result, String chartPath, String chartName) { - this.exitCode = result.exitCode; - this.output = result.output; - this.commandExecuted = result.commandExecuted; - this.chartName = chartName; - this.chartFolderPath = chartPath; - } - - public String getChartFolderPath() { - return chartFolderPath; - } - - public String getChartName() { - return chartName; - } - } - - public class ChartListResult extends Result { - - private String name; - private String namespace; - private String revision; - private String updated; - private String status; - private String chartVersion; - - public ChartListResult(Result result) { - this.exitCode = result.exitCode; - this.output = result.output; - } - - public void setName(String name) { - this.name = name; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - public void setRevision(String revision) { - this.revision = revision; - } - - public void setUpdated(String updated) { - this.updated = updated; - } - - public void setStatus(String status) { - this.status = status; - } - - public void setChartVersion(String chartVersion) { - this.chartVersion = chartVersion; - } - - public String getName() { - return name; - } - - public String getNamespace() { - return namespace; - } - - public String getRevision() { - return revision; - } - - public String getUpdated() { - return updated; - } - - public String getStatus() { - return status; - } - - public String getChartVersion() { - return chartVersion; - } - } -} diff --git a/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmExtensionBootstrap.java b/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmExtensionBootstrap.java deleted file mode 100644 index e2c8e1634..000000000 --- a/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmExtensionBootstrap.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.quarkus.test.bootstrap; - -import java.util.Optional; - -import io.quarkus.test.scenarios.KubernetesScenario; -import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.scenarios.QuarkusScenario; - -public class QuarkusHelmExtensionBootstrap implements ExtensionBootstrap { - - private ScenarioContext context; - private QuarkusHelmClient client; - - @Override - public boolean appliesFor(ScenarioContext context) { - this.context = context; - return context.isAnnotationPresent(QuarkusScenario.class) - || context.isAnnotationPresent(OpenShiftScenario.class) - || context.isAnnotationPresent(KubernetesScenario.class); - } - - @Override - public void beforeAll(ScenarioContext context) { - this.client = new QuarkusHelmClient(context); - } - - @Override - public Optional getParameter(Class clazz) { - if (clazz == QuarkusHelmClient.class) { - return Optional.of(client); - } - - return Optional.empty(); - } -} diff --git a/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmFileClient.java b/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmFileClient.java deleted file mode 100644 index bd4117d67..000000000 --- a/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmFileClient.java +++ /dev/null @@ -1,101 +0,0 @@ -package io.quarkus.test.bootstrap; - -import java.io.File; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import io.quarkus.test.configuration.PropertyLookup; -import io.quarkus.test.logging.FileLoggingHandler; -import io.quarkus.test.logging.Log; -import io.quarkus.test.utils.FileUtils; -import io.quarkus.test.utils.ProcessBuilderProvider; - -public class QuarkusHelmFileClient { - public static final String COMMAND_LOG_FILE = "quarkus-helmfile-command.out"; - static final PropertyLookup COMMAND = new PropertyLookup("ts.quarkus.helmfile.cmd", "helmfile"); - private static final Path TARGET = Paths.get("target"); - - private final ScenarioContext context; - - public QuarkusHelmFileClient(ScenarioContext ctx) { - this.context = ctx; - } - - public QuarkusHelmFileClient.Result sync(Path helmFileDirectory, String helmfileName) { - return run(helmFileDirectory, "-f", helmfileName, "sync"); - } - - public QuarkusHelmFileClient.Result uninstall(Path helmFileDirectory, String helmfileName) { - return run(helmFileDirectory, "-f", helmfileName, "destroy"); - } - - public QuarkusHelmFileClient.Result run(Path helmFileDirectory, String... args) { - QuarkusHelmFileClient.Result result = new QuarkusHelmFileClient.Result(); - File output = TARGET.resolve(COMMAND_LOG_FILE).toFile(); - - try (FileLoggingHandler loggingHandler = new FileLoggingHandler(output)) { - loggingHandler.startWatching(); - List cmd = buildCmd(args); - result.commandExecuted = cmd.stream().collect(Collectors.joining(" ")); - Log.info(result.commandExecuted); - Process process = runCli(helmFileDirectory, output, cmd); - result.exitCode = process.waitFor(); - } catch (Exception e) { - e.printStackTrace(); - Log.warn("Failed to run Quarkus Helm command. Caused by: " + e.getMessage()); - result.exitCode = 1; - } - - result.output = FileUtils.loadFile(output).trim(); - FileUtils.deleteFileContent(output); - return result; - } - - private List buildCmd(String... args) { - List cmd = new ArrayList<>(); - cmd.addAll(Arrays.asList(COMMAND.get().split(" "))); - cmd.addAll(Arrays.asList(args)); - return cmd; - } - - private Process runCli(Path workingDirectory, File logOutput, List cmd) { - try { - return ProcessBuilderProvider.command(cmd) - .redirectErrorStream(true) - .redirectOutput(logOutput) - .directory(workingDirectory.toFile()) - .start(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public class Result { - - private static final int EXIT_SUCCESS = 0; - - protected int exitCode; - protected String output; - protected String commandExecuted; - - public int getExitCode() { - return exitCode; - } - - public String getOutput() { - return output; - } - - public boolean isSuccessful() { - return EXIT_SUCCESS == exitCode; - } - - public String getCommandExecuted() { - return commandExecuted; - } - } -} diff --git a/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmFileExtensionBootstrap.java b/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmFileExtensionBootstrap.java deleted file mode 100644 index bb0f3dcc0..000000000 --- a/quarkus-test-helm/src/main/java/io/quarkus/test/bootstrap/QuarkusHelmFileExtensionBootstrap.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.quarkus.test.bootstrap; - -import java.util.Optional; - -import io.quarkus.test.scenarios.KubernetesScenario; -import io.quarkus.test.scenarios.OpenShiftScenario; -import io.quarkus.test.scenarios.QuarkusScenario; - -public class QuarkusHelmFileExtensionBootstrap implements ExtensionBootstrap { - private ScenarioContext context; - private QuarkusHelmFileClient client; - - @Override - public boolean appliesFor(ScenarioContext context) { - this.context = context; - return context.isAnnotationPresent(QuarkusScenario.class) - || context.isAnnotationPresent(OpenShiftScenario.class) - || context.isAnnotationPresent(KubernetesScenario.class); - } - - @Override - public void beforeAll(ScenarioContext context) { - this.client = new QuarkusHelmFileClient(context); - } - - @Override - public Optional getParameter(Class clazz) { - if (clazz == QuarkusHelmFileClient.class) { - return Optional.of(client); - } - - return Optional.empty(); - } -} diff --git a/quarkus-test-helm/src/main/resources/META-INF/services/io.quarkus.test.bootstrap.ExtensionBootstrap b/quarkus-test-helm/src/main/resources/META-INF/services/io.quarkus.test.bootstrap.ExtensionBootstrap deleted file mode 100644 index 302fdd9f6..000000000 --- a/quarkus-test-helm/src/main/resources/META-INF/services/io.quarkus.test.bootstrap.ExtensionBootstrap +++ /dev/null @@ -1,2 +0,0 @@ -io.quarkus.test.bootstrap.QuarkusHelmExtensionBootstrap -io.quarkus.test.bootstrap.QuarkusHelmFileExtensionBootstrap \ No newline at end of file diff --git a/quarkus-test-helm/src/test/java/io/quarkus/test/QuarkusHelmClientIT.java b/quarkus-test-helm/src/test/java/io/quarkus/test/QuarkusHelmClientIT.java deleted file mode 100644 index ebb8d1dd2..000000000 --- a/quarkus-test-helm/src/test/java/io/quarkus/test/QuarkusHelmClientIT.java +++ /dev/null @@ -1,31 +0,0 @@ -package io.quarkus.test; - -import jakarta.inject.Inject; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIf; - -import io.quarkus.test.bootstrap.QuarkusHelmClient; -import io.quarkus.test.scenarios.QuarkusScenario; - -@Tag("quarkus-helm") -@QuarkusScenario -@EnabledIf(value = "io.quarkus.test.bootstrap.HelmUtils#isHelmInstalled", disabledReason = "Helm needs to be locally installed") -public class QuarkusHelmClientIT { - - @Inject - static QuarkusHelmClient helmClient; - - @Test - public void verifyHelmVersionExist() { - QuarkusHelmClient.Result helmCmdResult = helmClient.run("version"); - Assertions.assertTrue( - helmCmdResult.isSuccessful(), - String.format("Command %s fails", helmCmdResult.getCommandExecuted())); - Assertions.assertFalse( - helmCmdResult.getOutput().isEmpty(), - "Unexpected helm version"); - } -} diff --git a/quarkus-test-helm/src/test/resources/test.properties b/quarkus-test-helm/src/test/resources/test.properties deleted file mode 100644 index a4414abc6..000000000 --- a/quarkus-test-helm/src/test/resources/test.properties +++ /dev/null @@ -1,2 +0,0 @@ -ts.app.log.enable=true -ts.global.generated-service.enabled=false