BreadcrumbHomeResourcesBlog Tips For Testing With Docker Containers April 7, 2019 Tips For Testing with Docker ContainersPerformance TestingBy Andrey PokhilkoThe Docker approach to virtualization can provide advantages when testing applications with open source performance testing tools. By making it replicable, performance testing with Docker containers enables sharing the tests between users and replicating the test environment. This can be helpful for sharing knowledge between users of different levels, in addition to saving time by not running unnecessary tests.This blog post will cover an overview of Docker, the specifics of using Docker containers for generating load, and how to involve open source Taurus for universal automation of performance tests. We’ll also cover how Dockerization solves specific issues of performance tests inside CI, and how to use the cloud for scaling performance tests for massive loads.Let’s get started.Table of ContentsWhat is Docker?What Are Testing Docker Containers?Key Features of DockerWhy Test Docker Containers?Automating Performance Testing Docker ContainersAdvantages of Using Docker ContainersLimitations of Docker ContainersTest Docker Containers With BlazeMeterTable of Contents1 - What is Docker?2 - What Are Testing Docker Containers?3 - Key Features of Docker4 - Why Test Docker Containers?5 - Automating Performance Testing Docker Containers6 - Advantages of Using Docker Containers7 - Limitations of Docker Containers8 - Test Docker Containers With BlazeMeter Back to topWhat is Docker?Docker is a tool designed to make it easier to create, deploy, and run applications by using containers.Back to topWhat Are Testing Docker Containers?Docker containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.By doing so, thanks to the container, the developer can rest assured that the application will run on any other machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.Back to topKey Features of DockerAn all-inclusive application packaging approach Everything you need to run your application sits within a simple container image. You can copy it, share it with your team, develop it locally, and then put it into production.Resource-efficientWith Docker, you can run many different applications at the same time. For example, you can run a full set of microservices without them interfering with each other. In the past, applications had dependency conflicts, it was challenging to run different applications on the same operating systems. We used to use virtual machines, but that required a lot of hardware to run. With Docker, you can run isolated processes without running virtual machines, so it is resource-efficient.PortableYou can build a Docker container in one environment, and transfer it to another environment. You can also multiply containers and run it on the same image on many different machines. There’s even Windows-based Docker, so it’s not just for Linux users anymore.DisposableDocker containers require minimal effort to shut them down by destroying everything, allowing you to avoid a huge clean-up process.Open SourceDocker is a free open-source solution, which means that you don’t need to pay for licensing, and it is frequently updated with new releases.Back to topWhy Test Docker Containers?There are many benefits to using Docker containers for software performance testing. Firstly, versioned images simplify deployments. This means you can simplify the evolution of your application just by deploying a new version with a new image.Docker also provides a huge repository of free images for popular apps. We will show one of them when we delve deeper using a Taurus image.Finally, Docker’s success has led to additional solutions such as Kubernetes and “Cloud-Native” which have really expanded cloud capabilities for developers and testers.Now that we’ve covered what Docker is, we're going to dig deeper into how to use open-source Taurus to automate performance tests on Docker containers.Back to topAutomating Performance Testing Docker ContainersUse TaurusTaurus an open-source command-line test automation tool. It’s a wrapper on top of JMeter, Gatling, and many others.A typical Taurus-based test starts with creating a YAML file describing the test configuration, like the one below:Then, the YAML file is launched with the help of the Taurus command-line tool, like this:bzt test.ymlAs a result, you see a live dashboard with KPIs of your test, You can also configure Taurus to send these results in a web report.From here, all the nuances of how your test will behave is based on your YAML file instructions.The “bzt” command is used to run the tests and you will see the results in real-time on your dashboard.Before we can run performance testing with Docker containers, we need our Taurus Docker image.Using a Pre-Built Taurus ImageThere are several advantages of using a pre-built Docker image including:not needing to install Taurusno Python requirementno JMeter installation neededno Java requirementpre-installed Seleniumas well as Chrome & FirefoxThe command to run the pre-built Taurus image is very simple, like this:sudo docker run -it blazemeter/taurus http://blazedemo.comDocker will download the image (if it is not present in the cache) and will run Taurus inside the container. Then, Taurus will generate real-time results in its dashboard. Make Your Own Docker ImageIf you want to have your own, maybe customized, version of Docker image with Taurus, it’s not too hard to build one from scratch:Create a file named “Dockerfile” with the following contents:FROM pythonRUN pip install bztRUN apt-get update && apt-get -y install default-jre-headlessRUN bzt -install-tools -o modules.install-checker.include=jmeterENTRYPOINT ["bzt"]Create the Docker image from these instructions by issuing the following command:sudo docker build . -t bzt1This will create the image, based on Alpine with Python, Java, and Taurus inside. Also, JMeter will be pre-installed. The name for the image will be “bzt1”, and we’ll use it to point to this image when we run the container.Now that you’ve created your Docker image, let’s run a test.Test Your Docker ImageTesting our own Docker image will be just the same as with the pre-built one, only the name of the image changes.First, run the following command:sudo docker run -it bzt1 http://blazedemo.comAnd it runs and you will see the results in the dashboard:Now that you’ve run a performance test with a Docker container, how can we use Docker within our continuous integration process?Back to topAdvantages of Using Docker ContainersConflicting dependencies are not a problem anymore when using Docker. For example, if you want to build one project with Java 8, and one project that requires Java 7, Docker can help separate these processes. The resulting images can also be put into a registry for future use and you can use dedicated images for intermediary build steps.Another advantage is you don’t have to build the image as part of your Jenkins job, you can have several images, eg- one for unit testing, one for integration testing etc.Docker layer cache speeds things up. You don’t need to start from scratch, which saves development time. Just be aware of HDD space running out! When you rely heavily on building images as part of your CI integration, you need to keep on top of maintenance for deleting old images.Now we know the advantages, let’s look at how to transfer files in and from your Docker container.Test-related files need to get into your Docker container, and the resulting files need to get out of the container. In order to do this, you can use the following command to mount the local directory into the container directory: docker run -v /local-dir:/container-dir…For example: sudo docker run -it -v `pwd`:/bzt-configs bzt1 requests.jmxWe see our JMeter Script running, but how do we get to the JMeter logs, in order to get to the artifacts?For this we have to add the mount command to the image launch, by adding the following:sudo docker run -it -v `pwd`:/tmp bzt1 /tmp/requests.jmxI can now check in the JMeter logs, and in the Taurus logs to further investigate any problemsAs you can see here, all original files have root permissions:Taurus is a CI-friendly tool, so deleting root permissions shouldn’t add too much work to your flow.Back to topLimitations of Docker ContainersWhile Docker has many advantages, it has its limitations.When you run several programs within the same machine you can consume major CPU, and it can affect other programs while running parallel runs, which can distort your results. Also, Docker does not solve HW scaling problems. So if your computer can only run 1,000 Virtual Users, you can’t run more than that when using Docker Containers.Host OS and container still need settings tunedYou still need to be able to configure your docker image and your host machineDisposable nature => easy to lose resultsYou will need to store your results, because of the disposable nature of DockerLoad Testing Reporting When Using DockerWe usually want proper reporting features and those aren’t available through Docker.The first thing to try is an online web report generated from your Taurus test.In Taurus, there is an additional parameter for the command-line, called “-report”. This parameter makes Taurus to send all report KPIs into cloud storage. Also, those KPIs are presented live on the web report page, which you can share with your colleagues. By using this feature, you avoid Docker’s trap of losing results after the test has been completed.If you have the BlazeMeter API key, you can configure Taurus to store results into your personal workspace, by providing API key via “-o modules.blazemeter.token=...” option.Back to topTest Docker Containers With BlazeMeterWith Docker, you can only scale with the limitations of your machine. By uploading your tests to BlazeMeter you can scale tests with Docker containers up to 2 million virtual users, and share reporting easily.BlazeMeter provides full support for JMeter and Taurus, as well as many other open-source tools.You can share these reports with your team, compare reports from previous tests, etc.START TESTING NOW Related ResourcesJMeter Performance TestingHow to Use Docker with JMeterBack to top
Andrey Pokhilko Chief Scientist, UP9 Inc. Andrey Pokhilko is Chief Scientist at BlazeMeter. Andrey is a renowned thought-leader and innovator within the Apache JMeter performance testing community. He has worked extensively to create and develop tools that enhance the Apache JMeter protocol coverage and analytical reporting capabilities. In 2009, he founded JMeter-Plugins.org and led this open source project to its undisputed status as the premier source of JMeter Plugins in the world. Loadosophia was similarly born from Andrey’s desire to complete JMeter’s offerings. He has world-class experience with large scale performance testing, having led the load testing team for five years at search engine giant Yandex.