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.


Zero Config Deployment Test

The project aims at demonstrating how to bring your Java applications on to Kubernetes and OpenShift by building Docker images and creating Kubernetes and OpenShift resource descriptors with a Zero-Config setup that allows for a quick ramp-up with some opinionated defaults using Fabric8 Maven Plugin and executing deployment tests using Arquillian Kube for a SpringBoot GuestBook Application to ensure that the application will work correcty when deployed on an OpenShift cluster.

How To Build And Deploy Your Application ?

Fabric8 Maven Plugin makes Kubernetes/OpenShift look and feel like an application server to a Java developer by letting you build and deploy your application from maven just like you would with other maven plugins.

Setup your maven project

To enable fabric8 on your existing maven project just type fabric8:setup command which adds the fabric8-maven-plugin to your pom.xml.

Alternatively, you can manually add the following plugin definition to your pom.xml file:


    <!-- Connect fabric8:resource and fabric8:build to lifecycle phases -->

It enables automatic generation of a Docker image and Kubernetes / OpenShift descriptors including the application.

For more and complete configuration details check out fabric8 maven plugin documentation.

How Do You Test The Deployment ?

Arquillian Kube Extension provides a black box approach to testing your deployment that neither mutates the containers (by deploying, reconfiguring etc) nor the Kubernetes/OpenShift resources.

It is used for 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.

Preparing the Environment

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

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

Setup Maven Project Dependencies For Assertion Libraries

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 resource descriptors generated by fabric8 maven plugin for your environment.

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;

    @RouteURL("guestbook")    (3)
    private URL route;

    public void service_instance_should_not_be_null() throws Exception {

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

    public void verify_route_is_configured_and_service_is_accessible() throws IOException {
        OkHttpClient okHttpClient = new OkHttpClient();
        Request request = new Request.Builder().get().url(route).build();
        Response response = okHttpClient.newCall(request).execute();

  1. 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)

  2. Resources can be injected into test cases by id or as a list of all deployments created during the session, optionally filtered by label.

  3. Test Enrichers like @RouteURL further aid in injection of container resources like route to the deployed service.

    For farbric8 maven plugin to identify the route, @RouteURL should be set to artifactId of the project by default, or explicity configured otherwise.

  4. 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:


  • minishift start (tested with OpenShift Origin 3.6.0)

  • oc login

  • mvn clean verify -Denv.init.enabled=true -DenableImageStreamDetection=true