Running integration test on Kubernetes
Docker containerization had changed the way we build, run, manage applications. More recent cloud-native technology Kubernetes becomes the most popular solution for managing containers. With Kubernetes we can dynamically create a whole environment to run our integration test and discard it afterward.
In this post, I would like to share my personal experience of how we build and run an integration test on Kubernetes pod.
Let’s assume we have a service that depends on other services such as databases, web services, etc.
Traditionally, we need to host those services in a static environment. When any of these services have the code change we will build, push and deploy the changes in the environment, then run integration test again it.
Maintaining a static environment for such tests can be very difficult and a waste of resources. For example, if Service A wants to test its latest change against a stable version of Service B, we may have to create another environment which can host the latest version of Service A and stable version of Service B. This is where the dynamic containers come in handy.
- Jenkins Kubernetes-plugin
- Setup pipeline to produce docker image for Service A
- Setup pipeline to produce docker image for Service A’s integration test
- Setup pipeline to trigger integration test pipeline after the image being pushed to the docker image repository
Repository structure of service A will look like:
4. Setup integration test repository with Jenkins file
Jenkins file for integration test:
That’s it! I didn’t cover all the details but you get the ideas.