Skip to content

Commit

Permalink
Update OpenShift integration and restore itegration tests (#1339)
Browse files Browse the repository at this point in the history
Updating OpenShift integration, restoring related functional tests and add an OpenShift (v3) execution to the GitHub workflow, to enable OpenShift functional tests execution in CI checks.
  • Loading branch information
fabiobrz authored Jan 4, 2025
1 parent 3ab43ce commit e707ed3
Show file tree
Hide file tree
Showing 64 changed files with 1,041 additions and 631 deletions.
43 changes: 33 additions & 10 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ env:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
java: ['11']
target: ['docker', 'kubernetes']
target: ['docker', 'kubernetes', 'openshift']
env:
# failsafe.groups configuration depends on the env setup.
FAILSAFE_GROUPS: ''
steps:
- name: Checkout arquillian-cube
uses: actions/checkout@v4
- name: Setup Minikube
if: ${{ matrix.target == 'kubernetes' }}
uses: manusa/[email protected]
Expand All @@ -41,22 +43,39 @@ jobs:
run: |
minikube addons enable registry
kubectl port-forward --namespace kube-system service/registry 5000:80 &
- name: Checkout arquillian-cube
uses: actions/checkout@v4
- uses: actions/cache@v4
- name: Setup OpenShift
if: ${{ matrix.target == 'openshift' }}
uses: manusa/[email protected]
with:
oc version: 'v3.10.0'
github token: ${{ secrets.GITHUB_TOKEN }}
# - name: Setup OLM on OpenShift v3.z
# if: ${{ matrix.target == 'openshift' }}
# run: |
# set -x
# # operator-sdk must be installed manually on OpenShift v3
# oc version
# oc create -f https://github.com/operator-framework/operator-lifecycle-manager/tree/master/deploy/upstream/manifests/0.6.0/
# # OR...
# 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.37.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
- name: Cache .m2 registry
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
key: cache-e2e-${{ github.sha }}-${{ github.run_id }}
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
distribution: 'temurin'
- name: Maven pre-fetch dependencies ${{ matrix.java }}
run: |
./mvnw clean package -q -U -DskipTests # pre-fetch dependencies
./mvnw clean install -q -U -DskipTests
- name: Build and run integration tests for Docker target (${{ matrix.java }})
if: ${{ matrix.target == 'docker' }}
run: |
Expand All @@ -65,6 +84,10 @@ jobs:
if: ${{ matrix.target == 'kubernetes' }}
run: |
./mvnw verify -Dfailsafe.groups=org.arquillian.cube.kubernetes.impl.requirement.RequiresKubernetes -Dcontainerless.skip.tests=true
- name: Build and run integration tests for OpenShift target (${{ matrix.java }})
if: ${{ matrix.target == 'openshift' }}
run: |
./mvnw verify -pl openshift -amd -Dfailsafe.groups=org.arquillian.cube.openshift.impl.requirement.RequiresOpenshift -Dfailsafe.excludedGroups=org.arquillian.cube.openshift.impl.requirement.RequiresOpenshift4 -Dcontainerless.skip.tests=true
- uses: actions/upload-artifact@v4
if: failure()
with:
Expand Down
59 changes: 38 additions & 21 deletions docs/fabric8.adoc
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
== Fabric8

The Fabric8 extension can be used along with the Kubernetes extension to provide a tighter integration with the link:https://fabric8.io/guide/fabric8DevOps.html[Fabric8 Microservices Platform]
The Fabric8 extension can be used along with the Kubernetes extension to provide a tighter integration with the link:https://github.com/fabric8io/kubernetes-client[Fabric8 Kubernetes Client]

=== Additional Features
- Integration with link:https://fabric8.io/guide/cdelivery.html[Fabric8 CI/CID]
- Management of Secrets via link:https://fabric8.io/guide/secretAnnotations.html[Secret Annotations]
- Integration with Fabric8 Modules:
- link:https://fabric8.io/guide/mavenPlugin.html[Fabric8 Maven Plugin]
- link:https://fabric8.io/guide/fabric8DevOps.html[Microservices Platform]
- Integration with link:https://eclipse.dev/jkube/docs/kubernetes-maven-plugin/[JKube Kubernetes Maven Plugin]
- Integration with link:https://eclipse.dev/jkube/docs/openshift-maven-plugin/[JKube OpenShift Maven Plugin]

=== Fabric8 Maven Plugin Integration With Cube
=== JKube Kubernetes & OpenShift Maven Plugin Integration With Cube

If you are using https://maven.fabric8.io/[fabric8-maven-plugin] to build images, generate resources and deploy your application to cluster, then you should use the same approach for integration testing using cube.
If you are using link:https://eclipse.dev/jkube/docs/kubernetes-maven-plugin/[JKube Kubernetes Maven Plugin] or
link:https://eclipse.dev/jkube/docs/openshift-maven-plugin/[JKube OpenShift Maven Plugin] to build images, generate
resources and deploy your application to cluster, then you should use the same approach for integration testing using Cube.

However there is way to build images and generate resources using `fabric8-maven-plugin` as a part of test execution.
If you enable `cube.fmp.build` property, cube will build image and generate resources for you by running embedded maven build as per options provided in
`arquillian.xml` using `mvn package fabric8:build fabric8:resource -Dfabric8.namespace=${namespace_configured_for_cube}`.
However, there is way to build images and generate resources using the JKube `kubernetes-maven-plugin` or
`openshift-maven-plugin` as a part of test execution.
If you enable `cube.fmp.build` property, cube will build image and generate resources for you by running embedded maven
build as per options provided in `arquillian.xml` using either:
- `mvn package k8s:build k8s:resource -Dfabric8.namespace=${namespace_configured_for_cube}`, or
- `mvn package oc:build oc:resource -Dfabric8.namespace=${namespace_configured_for_cube}`

You can use following configuration options with kubernetes and openshift extension to enable fabric8 maven plugin build in test execution.
You can use the following configuration options with Kubernetes and OpenShift extension to enable
link:https://eclipse.dev/jkube/docs/kubernetes-maven-plugin/[JKube Kubernetes Maven Plugin] or
link:https://eclipse.dev/jkube/docs/openshift-maven-plugin/[JKube OpenShift Maven Plugin] build in test execution.

*Configuration Options*
[cols="2,1,1,3", options="header"]
Expand All @@ -27,27 +31,40 @@ You can use following configuration options with kubernetes and openshift extens
| cube.fmp.build.disable.for.mvn | Bool (false) | Any | Whether to generate resources using fmp only when running test from IDE, not from maven
| cube.fmp.pom.path | String | Any | Path to pom.xml where fmp plugin configuration is present. Defaults to `pom.xml`
| cube.fmp.build.options | String | Any | Parameters used to start up the JVM running Embedded Maven and can be used to supply additional options to Embedded Maven.
| cube.fmp.debug.output | Bool (false) | Any | Whether to show debug output(-X) for generating resources using fabric8 maven plugin
| cube.fmp.logs | Bool (true) | Any | Whether to show logs for generating resources using fabric8 maven plugin
| cube.fmp.debug.output | Bool (false) | Any | Whether to show debug output(-X) for generating resources using JKube Kubernetes or OpenShift maven plugin
| cube.fmp.logs | Bool (true) | Any | Whether to show logs for generating resources using JKube Kubernetes or OpenShift maven plugin
| cube.fmp.profiles | List | Any | Comma-separated list of profiles which you want to activate while generating resources
| cube.fmp.system.properties | List | Any | Comma-separated key value pair to use for maven build
|===

*IMPORTANT*

- Make sure you have fabric8-maven-plugin dependency in plugin section.
- Make sure you have either the JKube `kubernetes-maven-plugin` or `openshift-maven-plugin` dependency in plugin section:
```xml
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${version.fabric8.maven.plugin}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${version.jkube}</version>
</plugin>
</plugins>
</build>
```
- If you have multiple profiles defined in your pom.xml, you can enable profile in which you have
fabric8-maven-plugin dependency by using `cube.fmp.profiles` in arquillian.xml.

You can see the example using `fabric8-maven-plugin` at: https://github.com/arquillian/arquillian-cube/tree/main/openshift/ftest-openshift-fabric8-maven-plugin
```xml
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>openshift-maven-plugin</artifactId>
<version>${version.jkube}</version>
</plugin>
</plugins>
</build>
```

- If you have multiple profiles defined in your pom.xml, you can enable profile in which you have the JKube
`kubernetes-maven-plugin` or the `openshift-maven-plugin` dependency by using `cube.fmp.profiles` in arquillian.xml.

You can see the example using `openshift-maven-plugin` at: https://github.com/arquillian/arquillian-cube/tree/main/openshift/ftest-openshift-jkube-maven-plugin
19 changes: 3 additions & 16 deletions docs/kubernetes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The main modules of this extension are the following:

- Kubernetes
- Openshift
- Fabric8 Microservices Platform (Fabric8 label and annotation support)
- Fabric8 Kubernetes Client integration

=== Features
- Hybrid *(in or out of Kubernetes/Openshift)*
Expand All @@ -32,9 +32,8 @@ The main modules of this extension are the following:
** Pods
** Replication Controllers
** Services
- Integration with Fabric8 Modules:
** link:https://fabric8.io/guide/mavenPlugin.html[Fabric8 Maven Plugin]
** link:https://fabric8.io/guide/fabric8DevOps.html[Microservices Platform]
- Integration with link:https://eclipse.dev/jkube/docs/kubernetes-maven-plugin/[JKube Kubernetes Maven Plugin]
- Integration with link:https://eclipse.dev/jkube/docs/openshift-maven-plugin/[JKube OpenShift Maven Plugin]
- "Bring your own client" support

=== Pre-requisites
Expand Down Expand Up @@ -857,18 +856,6 @@ Cube Extension for OpenShift and Fabric8 OpenShift Client.

Source: https://github.com/arquillian-testing-microservices/openshift-deployment-testing[arquillian-testing-microservices/openshift-deployment-testing]

==== Example 3

Building and deploying a sample SpringBoot GuestBook application with zero deployment configuration using
https://maven.fabric8.io/[Fabric8 Maven Plugin] and
https://github.com/arquillian/arquillian-cube[Arquillian Cube Extension].

Fabric8 Maven Plugin aids in building Docker images and creating Kubernetes and OpenShift resource
descriptors for the application that allows for a quick ramp-up with some opinionated defaults and Arquillian
Cube Extension deploys the application from the generated resource descriptors and then executes deployment tests.

Source: https://github.com/arquillian-testing-microservices/zero-config-deployment-test[arquillian-testing-microservices/zero-config-deployment-test]

=== Dealing with version conflicts
Arquillian Cube Kubernetes and Openshift modules, heavily rely on the Fabric8 Kubernetes/Openshift client.
This client is also used in wide range of frameworks, so its not that long of a shot to encounter version conflicts.
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit e707ed3

Please sign in to comment.