This article represents some of the key reasons on why one should consider using dockers for testing their applications. Some of the points in this blog is taken from the video, Stop being Lazy and Test your Software presented by Laura Frank, currently working in CodeShip. Do check out videos for gathering greater details. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos.
Following are the key points described later in this article:
- What are key testing bottlenecks?
- How could Dockers alleviate Testing Bottlenecks
Key Testing Bottlenecks
- Slower performing tests or slower running tests due to bad coding or not sufficient infrastructure
- Traditional testing methodologies adopted for testing which slows down the code from going to production
- Not appropriately skilled testing team to take up all aspects of testing including building/configuring test environments etc
- Setting up test environment is complex and slower process
- Takes too long to deploy in case of complex builds and huge test suites
How could Dockers alleviate Testing Bottlenecks
- One of the key testing challenges or testing bottlenecks is creating test environment comprising of several applications/services & their dependencies. This gets nailed using Docker-compose utility. Docker-compose could be used to automate the test environment. Docker-compose allows one to build different images for different application dependencies such as server, database etc, link them together and get the service up and running. Following is definition from Docker-compose page from Docker website: Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration.. Following is a sample docker compose file (docker-compose.yml):
web: build: . ports: - "5000:5000" volumes: - .:/code links: - redis redis: image: redis
In above sample docker compose file, observe following:
- Web image is built from dockerfile found in current directory. The Web image is linked with redis container.
- Redis image is built from “redis” which is retrieved from Dockerhub.
- Parallel tests could be run easily by having multiple docker containers running different test suites in parallel and then combining the results at a later stage. This could really make the tests complete in a very fast time. Thus, dockers can help tests suite run faster.
- Dockers can help achieve service virtualization in a much simpler way owing to the fact that one could easily spin-off virtualized services and real service interchangeably by making use of docker images and utility such as docker-compose.
- Docker containers could be used to containerize the test automation tools such as Selenium by making use of one or more containers hosting Selenium hub and selenium nodes.
- Create customized test databases could be easily achieved with Dockers by creating/running appropriate docker containers having different datasets to tests different features/dunctionality.
- Shuffle between Dev and Test environments in easy manner using Docker-compose. One of need for developers is to have easy access to their Test and Dev environments. This is pretty easy with Dockers and Docker-compose proves very helpful to achieve this.
- Knoweldge-gaps for Test Engineers to setup Test Environment is filled easiry with Dockers. Dockers nails the need for test engineers/developers sit together, understand the setup and, then build the test environment for new builds. All it requires to be done is write one or more Dockerfile and start the applications all together or independently using Docker-compose. This eliminate the time spent on collaboration and communication between Test and Dev engineers and make things faster.