Skip to content

Commit

Permalink
Merge pull request #31838 from Sgitario/cover_knative
Browse files Browse the repository at this point in the history
Cover Knative deployment integration tests
  • Loading branch information
gsmet committed Mar 15, 2023
2 parents d40800d + 64fc1fa commit 819a7eb
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/ci-kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,61 @@ jobs:
issueRepo=${{ github.repository }} \
thisRepo=${{ github.repository }}
knative:
name: Knative Integration Tests
needs: cache
runs-on: ubuntu-latest
if: "github.repository == 'quarkusio/quarkus' || github.event_name == 'workflow_dispatch'"
strategy:
fail-fast: false
matrix:
kubernetes: [v1.20.1]
knative: [v1.2.0]
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Download Maven repository
uses: actions/download-artifact@v3
with:
name: maven-repo
path: .
- name: Extract Maven repository
shell: bash
run: tar -xzf maven-repo.tgz -C ~
- name: Kubernetes KinD Cluster
uses: container-tools/kind-action@v2
with:
version: v0.11.1
registry: true
kubectl_version: ${{ matrix.kubernetes }}
knative_serving: ${{ matrix.knative }}
- name: Run Knative Invoker Tests
run: |
kubectl create namespace knative-tests
kubectl config set-context --current --namespace=knative-tests
export QUARKUS_CONTAINER_IMAGE_GROUP=quarkustesting
export QUARKUS_CONTAINER_IMAGE_TAG=${{ github.sha }}
export QUARKUS_CONTAINER_IMAGE_REGISTRY=$KIND_REGISTRY
export QUARKUS_CONTAINER_IMAGE_INSECURE=true
./mvnw ${MAVEN_ARGS} clean install -pl :quarkus-integration-test-kubernetes-invoker -De2e-tests -Dknative-e2e-tests
- name: Report status
if: "always() && github.repository == 'quarkusio/quarkus'"
shell: bash
run: |
curl -Ls https://sh.jbang.dev | bash -s - app setup
~/.jbang/bin/jbang .github/NativeBuildReport.java \
issueNumber=31837 \
runId=${{ github.run_id }} \
status=${{ job.status }} \
token=${{ secrets.GITHUB_API_TOKEN }} \
issueRepo=${{ github.repository }} \
thisRepo=${{ github.repository }}
openshift:
name: OpenShift Integration Tests
needs: cache
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
invoker.goals=clean package -Dquarkus.kubernetes.deploy=true
# expect a failure since there is no Kubernetes cluster to deploy to
invoker.buildResult = ${build-result}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.acme</groupId>
<artifactId>knative-jib-build-and-deploy</artifactId>
<version>0.1-SNAPSHOT</version>
<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<surefire-plugin.version>3.0.0-M9</surefire-plugin.version>
<maven.compiler.source>11</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bom</artifactId>
<version>@project.version@</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-jib</artifactId>
</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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${native.surefire.skip}</skipTests>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.acme;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("/hello")
public class Hello {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "hello";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quarkus.container-image.registry=docker.io
quarkus.kubernetes.deployment-target=knative
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import io.dekorate.utils.Serialization
import io.fabric8.knative.serving.v1.Service;
import io.fabric8.kubernetes.api.model.KubernetesList

//Check that file exits
String base = basedir
File knativeYml = new File(base, "target/kubernetes/knative.yml")
assert knativeYml.exists()
knativeYml.withInputStream { stream ->
//Check that its parse-able
KubernetesList list = Serialization.unmarshalAsList(stream)
assert list != null

Service service = list.items.find{r -> r.kind == "Service"}

//Check that ti contains a Service named after the project
assert service != null
assert service.metadata.name == "knative-jib-build-and-deploy"
}

0 comments on commit 819a7eb

Please sign in to comment.