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

Draft for k8s support #66

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion .ci/openshift-ci/build-root/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,7 @@ cat test.properties

mkdir local-repo
mvn clean install -Dmaven.repo.local=./local-repo -DskipTests
mvn test -Dmaven.repo.local=./local-repo -pl testsuite/
mvn test -Dmaven.repo.local=./local-repo -pl testsuite/ -Pts.openshift \
-Dintersmash.olm.operators.catalog_source=redhat-operators \
-Dintersmash.olm.operators.namespace=openshift-marketplace \
-Dintersmash.hyperfoil.operators.catalog_source=community-operators
78 changes: 78 additions & 0 deletions .github/workflows/kubernetes-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Kubernetes E2E Tests

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
paths-ignore:
- 'doc/**'
- 'ide-config/**'
- '**.md'

concurrency:
# Only run once for latest commit per ref and cancel other (previous) runs.
group: ci-e2e-intersmash-${{ github.ref }}
cancel-in-progress: true

jobs:
minikube:
name: K8S
runs-on: ubuntu-latest
if: github.repository == 'Intersmash/intersmash'
strategy:
fail-fast: false
matrix:
kubernetes: [v1.25.0, v1.24.0]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Minikube-Kubernetes
uses: manusa/[email protected]
with:
minikube version: v1.25.0
kubernetes version: ${{ matrix.kubernetes }}
github token: ${{ secrets.GITHUB_TOKEN }}
start args: '--force'
- name: Cache .m2 registry
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: cache-e2e-${{ github.sha }}-${{ github.run_id }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Install and Run Integration Tests
run: |
set -x
# cat our ~/.kube/config contents
#
cat ~/.kube/config
#
# operator-sdk must be installed manually, see
#
export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)
export OS=$(uname | awk '{print tolower($0)}')
export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.28.0
curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk
operator-sdk olm install
#
# set the Kubernetes hostname that will resolve to the minikube IP
#
export KUBERNETES_HOSTNAME=host.minikube.internal
#
# run...
#
mkdir local-repo
mvn clean install -Dmaven.repo.local=./local-repo -DskipTests
mvn test -Dmaven.repo.local=./local-repo -pl testsuite/ -Pts.k8s \
-Dintersmash.kubernetes.url=https://$( minikube ip):8443 \
-Dintersmash.kubernetes.hostname=$KUBERNETES_HOSTNAME \
-Dintersmash.kubernetes.namespace=test-k8s-1 \
-Dintersmash.olm.operators.catalog_source=community-operators \
-Dintersmash.olm.operators.namespace=olm \
-Dintersmash.hyperfoil.operators.catalog_source=operatorhubio-catalog
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,35 @@ simulate complex use-cases where multiple Runtime products are involved.

## Platforms

Although Intersmash is designed to allow executions on different platforms, at the moment, we fully focus on OpenShift
support, support for other platforms (Kubernetes, Bare-metal, kubernetes etc.) could be added later on demand.
Although Intersmash is designed to allow executions on different platforms, we fully focus on OpenShift support
currently while Kubernetes support is being introduced. Support for other platforms (Bare-metal etc.) could be added
later on demand.

### Conditional test execution based on test environment platforms

Each test that is annotated by the `@Intersmash` annotation will be managed by the Intersmash test execution engine,
which relies on JUnit5 Jupiter extensions.

This way, any annotated test class which is managed by the Intersmash execution engine can either target an
OpenShift cluster or a Kubernetes one, which is definedby the `@Intersmash` annotation `target` field, allowing for
the following values to be set: `OpenShift`, `Kubernetes`.

By default, the `@Intersmash` annotation will configure the test class for execution on an OpenShift cluster test
environment. Therefore, the test execution engine will try to connect to an existing OpenShift cluster and perform
operations on it.
Similarly, setting `target` to `Kubernetes` will cause the test execution engine to deal with an existing Kubernetes
cluster.

When executing tests, Intersmash can be configured through the `intersmash.junit5.execution.targets` property to
define which platforms the actual target environment supports. The property accepts a comma-separated list
based on the following values: `OpenShift`, `Kubernetes`.
For example, a developer could have one Kubernetes and one OpenShift clusters available, and set the property value
to `OpenShift,Kubernetes`. Instead, it should be set to `OpenShift` for a given CI execution where just an OpenShift
cluster is available.

Tests are enabled or disabled conditionally, based on such information - i.e. the `target` value on an Intersmash test
_and_ the actual targets that a test environment provides: _if an Intersmash test class is set to target a given
environment, then such target must be configured through the `intersmash.junit5.execution.targets` property_.

### Something more about OpenShift

Expand Down
3 changes: 3 additions & 0 deletions global-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ xtf.record.always=false
# Avoid starting multiple builds at once as it might cause that builds starts to hang
xtf.junit.prebuilder.synchronized=true

# Intersmash JUnit5 execution target environments
intersmash.junit5.execution.targets=OpenShift

# Bootable JAR OpenJDK base image
intersmash.bootable.jar.image=registry.access.redhat.com/ubi8/openjdk-17

Expand Down
31 changes: 28 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
<version.com.fasterxml.jackson>2.13.1</version.com.fasterxml.jackson>
<version.io.fabric8>6.6.0</version.io.fabric8>
<version.openshift-client>5.12.2</version.openshift-client>
<version.io.fabric8.generator>6.6.0</version.io.fabric8.generator>
<version.io.fabric8.kubernetes-client>5.12.2</version.io.fabric8.kubernetes-client>

<!--
Version used for the activemq-artemis-operator;
Expand Down Expand Up @@ -97,6 +99,8 @@
<version.junit5.jupiter.system.stubs>2.0.1</version.junit5.jupiter.system.stubs>
<version.spotless-maven-plugin>2.35.0</version.spotless-maven-plugin>
<version.dev-failsafe.failsafe>3.3.1</version.dev-failsafe.failsafe>
<version.junit5.platform>1.7.0</version.junit5.platform>
<version.assertj-core>3.24.2</version.assertj-core>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -153,6 +157,11 @@
<artifactId>intersmash-tools-provisioners</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.intersmash</groupId>
<artifactId>intersmash-kubernetes-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.intersmash</groupId>
<artifactId>intersmash-deployments-provider</artifactId>
Expand Down Expand Up @@ -195,6 +204,11 @@
<version>${version.dev-failsafe.failsafe}</version>
</dependency>
<!-- JUnit 5 Jupiter -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${version.junit5.platform}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down Expand Up @@ -338,22 +352,33 @@
<artifactId>jsr305</artifactId>
<version>${version.com.google.code.findbugs}</version>
</dependency>

<!-- More deps -->
<dependency>
<groupId>uk.org.webcompere</groupId>
<artifactId>system-stubs-jupiter</artifactId>
<version>${version.junit5.jupiter.system.stubs}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>generator-annotations</artifactId>
<version>${version.io.fabric8}</version>
<version>${version.io.fabric8.generator}</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
<version>${version.io.fabric8.kubernetes-client}</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-client</artifactId>
<version>${version.openshift-client}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${version.assertj-core}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -466,7 +491,7 @@
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>java-generator-maven-plugin</artifactId>
<version>${version.io.fabric8}</version>
<version>${version.io.fabric8.generator}</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down
44 changes: 43 additions & 1 deletion testsuite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,48 @@
<groupId>io.fabric8</groupId>
<artifactId>openshift-client</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.intersmash</groupId>
<artifactId>intersmash-kubernetes-client</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.org.webcompere</groupId>
<artifactId>system-stubs-jupiter</artifactId>
</dependency>
</dependencies>

</project>
<profiles>
<profile>
<id>ts.k8s</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>ts.k8s</groups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ts.openshift</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>ts.openshift</groups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.intersmash.testsuite.k8s;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.junit.jupiter.api.Tag;

/**
* Mark test that runs against Kubernetes.
* Used per class.
*/
@Tag("ts.k8s")
@Retention(RetentionPolicy.RUNTIME)
@Target({ java.lang.annotation.ElementType.TYPE })
public @interface KubernetesTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.intersmash.testsuite.openshift;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.junit.jupiter.api.Tag;

/**
* Mark test that runs against OpenShift.
* Used per class.
*/
@Tag("ts.openshift")
@Retention(RetentionPolicy.RUNTIME)
@Target({ java.lang.annotation.ElementType.TYPE })
public @interface OpenShiftTest {
}
Loading