Skip to content

Commit

Permalink
chore: refactors content with additional headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
hemanik committed Dec 15, 2017
1 parent 32442f4 commit 9bd118f
Showing 1 changed file with 49 additions and 45 deletions.
94 changes: 49 additions & 45 deletions blog/2017-12-11-end-to-end-testing-kubernetes-openshift.textile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Moving a step further, we also demonstrate building and deploying from scratch,
deployment configuration, leveraging the power of "Fabric8 Maven Plugin":https://maven.fabric8.io/ along with the Arquillian Kube
Extension.

h2. Deployment Testing Recipes

*If, you wish to read no more and see it all in action, head straight to our specially curated
examples to help you get started with ease.*

Expand Down Expand Up @@ -56,52 +58,18 @@ Kube Extension deploys the application from the generated resource descriptors a

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

*For a more in-depth step by step coverage of deployment testing, continue reading below.*

*Step 1: Building Docker Images and creating Resource Descriptors.*

Just have a java application that you wish you to bring to Kubernetes or OpenShift, use Fabric8 Maven Plugin
to create docker images and resource descriptors for you.

bq. 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.

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:

bc(prettify).. <plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>3.5.32</version>

<!-- Connect fabric8:resource and fabric8:build to lifecycle phases -->
<executions>
<execution>
<id>fmp</id>
<phase>package</phase>
<goals>
<goal>resource</goal>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>

p. For more and complete configuration details check out "fabric8 maven plugin documentation":https://maven.fabric8.io/.
h2. Step By Step Guide To Writing Deployment Tests

If you are an advanced user and already have Kubernetes/OpenShift resources descriptors handy, skip this step.
*For a more in-depth step by step coverage of deployment testing, continue reading below.*

*Step 2: Setting Up Kubernetes/OpenShift Cluster*
h3. Step 1: Setting Up Kubernetes/OpenShift Cluster

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

An easy way to setup Kubernetes or OpenShift cluster locally is using "Minikube":https://github.com/kubernetes/minikube and "Minishift":https://github.com/minishift/minishift respectively.

*Step 3: Adding Arquillian Kube Dependencies to your project*
h3. Step 2: Adding Arquillian Kube Dependencies to your project

bq.. 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.
Expand Down Expand Up @@ -174,7 +142,7 @@ bc(prettify).. <dependency>

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

*Step 4: Writing Deployment Tests*
h3. Step 3: 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
Expand All @@ -186,14 +154,14 @@ Arquillian’s *@ArquillianResources* annotation (see example test below).
bc(prettify).. @RunWith(Arquillian.class) (1)
public class ExampleTest {

@ArquillianResource (2)
OpenShiftClient client;

@Named("dummy") (3)
@Named("dummy") (2)
@PortForward
@ArquillianResource
Service dummyService;

@ArquillianResource (3)
OpenShiftClient client;

@RouteURL("application") (4)
@AwaitRoute
private URL route;
Expand All @@ -205,7 +173,7 @@ public class ExampleTest {

@Test
public void test_at_least_one_pod() throws Exception {
assertThat(client).pods().runningStatus().filterNamespace(session.getNamespace()).hasSize(1); (5)
assertThat(client).pods().runningStatus().filterNamespace(session.getNamespace()).hasSize(1);
}

@Test
Expand Down Expand Up @@ -248,7 +216,8 @@ For farbric8 maven plugin to identify the route, @RouteURL should be set to arti
default, or explicity configured otherwise.
# *Adding Test Cases that assert environment is in the expected state*.

*Step 5: Using Assertion Libraries*
h3. Step 4: Using Assertion Libraries

Optionally, using "Fabric8 Kubernetes Assertions":https://github.com/fabric8io/fabric8/tree/master/components/kubernetes-assertions , a nice library based on assert4j, aids in performing
meaningful and expressive assertions on top of the Kubernetes/OpenShift model.

Expand All @@ -265,3 +234,38 @@ p. Once everything is ready, Arquillian Kube runs your tests, enriched with reso
and finally cleaning up everything after the testing is over.

For more details and available configuration options check "arquillian kube documentation":http://arquillian.org/arquillian-cube/#_kubernetes.

h3. Building Docker Images and creating Resource Descriptors.

Optionally, if you just have a java application that you wish you to bring to Kubernetes or OpenShift,
use Fabric8 Maven Plugin to create docker images and resource descriptors for you.

bq. 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.

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:

bc(prettify).. <plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>3.5.32</version>

<!-- Connect fabric8:resource and fabric8:build to lifecycle phases -->
<executions>
<execution>
<id>fmp</id>
<phase>package</phase>
<goals>
<goal>resource</goal>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>

p. For more and complete configuration details check out "fabric8 maven plugin documentation":https://maven.fabric8.io/.

0 comments on commit 9bd118f

Please sign in to comment.