No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


OpenShift Deployment Testing

The project aims at executing deployment tests using Arquillian Kube together with Fabric8 OpenShift Client for a WordPress and MySQL Application to ensure that the application will work correcty when deployed on an OpenShift cluster.

What Do You Test ?

The project aims at demonstrating a black box approach to testing your deployment that neither mutates the containers (by deploying, reconfiguring etc) nor the Kubernetes/OpenShift resources.

The focus of the project is on immutable infrastructure and integration testing, wherein the test cases are meant to, consume and test the provided services and assert that the environment is in the expected state, providing you with the confidence that your application will work correctly when deployed on an OpenShift cluster.

How Do You Test The Deployment ?

The following sections explain how to leverage the Arquillian Kube Extension and Fabric8 OpenShift Client to test your OpenShift deployments.

Preparing the Environment

Setup OpenShift Cluster Locally

One of the pre-requisites to use Arquillian Kube Extension, is to have the OpenShift cluster running on your host machine.

An easier way to setup and start the OpenShift cluter on your local host is to use MiniShift.

Setup Maven Project Dependencies

For OpenShift deployment testing using Arquillian Kube extension, include the following dependencies in pom.xml:

Arquillian Cube BOM - Unified Dependencies

Arquillian Cube Requirement
Arquillian Cube OpenShift
Arquillian Junit

For Fabric8 OpenShift Client, include the following dependency in the pom.xml

Fabric8 OpenShift Client

For fabric8 kubernetes assertions, include the following dependency in the pom.xml

Fabric8 Kubernetes Assertions

Writing Deployment Tests

Arquillian Kube extension provides out of the box functionality to create and manage a temporary namespace per test suite for your tests and then applies all the required kubernetes/openshift resources as defined in the OpenShift manifest/template file provided by you to create your environment.

The extension by default looks for the manifest file named kubernetes.json or kubernetes.yaml in the classpath.

The name of the manifest/template file can be changed by setting the property either as an environment variable or as system property or by defining it in the arquillian.xml as shown below with latter having the maximum priority.

<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns:xsi=""

    <extension qualifier="kubernetes">
        <property name="">sample-template.yaml</property>


Kubernetes/OpenShift resources can then be made accessible within the Test Cases by injecting them using Arquillian’s @ArquillianResources annotation (see example test below).
public class ExampleTest {

    @ArquillianResource       (1)
    OpenShiftClient client;

    @Named("dummy")           (2)
    Service dummyService;

    public void service_instance_should_not_be_null() throws Exception {
        assertThat(service).isNotNull();                                                              (3)

    public void test_at_least_one_pod() throws Exception {
       assertThat(client).pods().runningStatus().filterNamespace(session.getNamespace()).hasSize(1);  (4)

The resource providers available, can be used to inject to your test cases the following resources:

  • A kubernetes client as an instance of KubernetesClient.

  • Session object that contains information (e.g. the namespace) or the uuid of the test session.

  • Services (by id or as a list of all services created during the session, optionally filtered by label)

  • Deployments (by id or as a list of all deployments created during the session, optionally filtered by label)

  • Pods (by id or as a list of all pods created during the session, optionally filtered by label)

  • Replication Controllers (by id or as a list of all replication controllers created during the session, optionally filtered by label)

  • Replica Sets (by id or as a list of all replica sets created during the session, optionally filtered by label)

The OpenShift extension also provides:

  • An openshift client as an instance of OpenShiftClient.

  • Deployment Configs (by id or as a list of all deployment configs created during the session)

Further, using Fabric8 Kubernetes Assertions, a nice library based on assert4j, aids in performing meaningful and expressive assertions on top of the Kubernetes/OpenShift model.

Once everything is ready, Arquillian Kube runs your tests, enriched with resources required to access service and finally cleaning up everything after the testing is over.

For more details and available configuration options check arquillian kube documentation.

Running Sample Tests

To run the sample deployment tests in this project follow the steps below:

  • git clone

  • minishift start (tested with OpenShift Origin 3.6.0)

  • oc login

  • mvn clean verify