Introducing the Apache JMeter Docker Extension
Tags: docker, testing, performance, tutorial
Published: 2023-11-06 14:18:00

<!-- wp:paragraph -->
<p>Docker Extensions was announced as a beta at DockerCon 2022. Docker Extensions became generally available in January 2023. Developing performance tools' related extensions was on my to-do list for a long time. Due to my master's degree I couldn't spend time learning Docker Extensions SDK. I expected someone would have created the extension by now, considering it's almost 2024. It's surprising to me that none has been developed as far as I know. But no more. Introducing the Apache JMeter Docker Extension. Now you can run Apache JMeter tests in Docker Desktop without installing JMeter locally. In this blog post, we will explore how to get started with this extension and understand its functionality. We will also cover generating HTML reports and other related topics.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">About Docker Extensions</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Docker Extensions enables third parties to extend the functionalities of Docker by integrating their tools. Think of it like a mobile app store, but for Docker. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I frequently use the official Docker <strong>Disk Usage</strong> extension to analyze disk usage and free up unused space.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":17693,"width":"739px","height":"auto","aspectRatio":"2.9340974212034383","sizeSlug":"large","linkDestination":"media"} -->
<figure class="wp-block-image size-large is-resized"><a href="https://qainsights.com/wp-content/uploads/2023/11/image.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-1024x349.png" alt="Disk Usage Docker Extension" class="wp-image-17693" style="aspect-ratio:2.9340974212034383;width:739px;height:auto"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Extensions enhance the productivity and workflow of developers. Check out the Docker Extension marketplace for some truly amazing extensions. Go see it for yourself! </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Prerequisite for Docker Extension</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The only prerequisite for Docker Extension is to have <strong>Docker Desktop 4.8.0 and later</strong> installed in your local. </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Apache JMeter Docker Extension</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Apache JMeter Docker Extension is an open source, lightweight extension and the only extension is available as of this writing. It will help you to run JMeter tests on Docker without installing JMeter locally. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>This extension simplifies the process of setting up and executing JMeter tests within Docker containers, streamlining your performance testing workflow. Whether you're a seasoned JMeter pro or just getting started, this tool can help you save time and resources.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Features</h3>
<!-- /wp:heading -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Includes base image <strong>qainsights/jmeter:latest</strong> by default.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Light-weight and secured container</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Supports JMeter plugins</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Mount volume for easy management</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Supports property files</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Supports proxy configuration</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Generates logs and results</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Intuitive HTML report</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Displays runtime console logs</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Timely notifications</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">How to install Apache JMeter Docker extension?</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Installation is a breeze. There are two ways you can install the extension.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading">Command Line</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Run <code>docker extension install qainsights/jmeter-docker-extension:0.0.1</code> in your terminal and follow the prompts.</p>
<!-- /wp:paragraph -->

<!-- wp:code -->
<pre class="wp-block-code"><code>$&gt; docker extension install qainsights/jmeter-docker-extension:0.0.1     
                                                            
Extensions can install binaries, invoke commands, access files on your machine and connect to remote URLs. 
Are you sure you want to continue? &#91;y/N] y

Image not available locally, pulling qainsights/jmeter-docker-extension:0.0.1...
Extracting metadata and files for the extension "qainsights/jmeter-docker-extension:0.0.1"
Installing service in Desktop VM...
Setting additional compose attributes
Installing Desktop extension UI for tab "JMeter"...
Extension UI tab "JMeter" added.
Starting service in Desktop VM......
Service in Desktop VM started
Extension "JMeter" installed successfully</code></pre>
<!-- /wp:code -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading">Web</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Here is the <a href="https://open.docker.com/extensions/marketplace?extensionId=qainsights/jmeter-docker-extension&amp;tag=0.0.1">direct link</a> to install the JMeter extension. Follow the prompts to get it installed.</p>
<!-- /wp:paragraph -->

<!-- wp:generateblocks/button {"uniqueId":"b856bf46","hasUrl":true,"target":true,"blockVersion":4,"display":"inline-flex","spacing":{"paddingTop":"15px","paddingRight":"20px","paddingBottom":"15px","paddingLeft":"20px"},"backgroundColor":"#0366d6","backgroundColorHover":"#222222","textColor":"#ffffff","textColorHover":"#ffffff"} -->
<a class="gb-button gb-button-b856bf46 gb-button-text" href="https://open.docker.com/extensions/marketplace?extensionId=qainsights/jmeter-docker-extension&amp;tag=0.0.1" target="_blank" rel="noopener noreferrer">Install JMeter Docker Extension</a>
<!-- /wp:generateblocks/button -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Click on <strong>Install anyway</strong> to install the extension.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":17699,"sizeSlug":"large","linkDestination":"media"} -->
<figure class="wp-block-image size-large"><a href="https://qainsights.com/wp-content/uploads/2023/11/image-1.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-1-1024x263.png" alt="Install Apache JMeter Docker Extension" class="wp-image-17699"/></a></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">How to get started with JMeter Docker Extension?</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>After installing the JMeter Docker extension, navigate to the left sidebar as shown below, then click on <strong>JMeter</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":17701,"width":"265px","height":"auto","aspectRatio":"0.5146484375","sizeSlug":"large","linkDestination":"media","className":"is-style-default"} -->
<figure class="wp-block-image aligncenter size-large is-resized is-style-default"><a href="https://qainsights.com/wp-content/uploads/2023/11/image-2.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-2-527x1024.png" alt="Launch Apache JMeter Docker Extension" class="wp-image-17701" style="aspect-ratio:0.5146484375;width:265px;height:auto"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Now it is time to execute our first tests on Docker using JMeter extension.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The following are the prerequisites to execute the JMeter tests.</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><!-- wp:list-item -->
<li>valid JMeter test plan</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>optional proxy credentials</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>optional JMeter properties file</li>
<!-- /wp:list-item --></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>The user interface is pretty simple, intuitive, and self-explanatory. All it has is text fields, buttons, and the output console log. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The extension has the following sections:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><!-- wp:list-item -->
<li>Image and Volume<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>This extension works well with the <code>qainsights/jmeter:latest</code> image</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Other images might not work; I have not tested it.</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Mapping the volume from the host to the Docker container is crucial to share the test plan, CSV test data, other dependencies, property files, results, and other files.</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Test Plan<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>A valid test plan must be kept inside the shared volume.</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Property Files<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>This section helps you to pass the runtime parameters to the JMeter test plan.</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Logs and Results<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>This section helps you to configure the logs and results. After each successful test, logs and an HTML report will be generated and saved in a shared volume.</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Proxy and its credentials<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Optionally you can send a proxy and its credentials. This is helpful when you are on the corporate network so that the container can access the application being tested.</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list --></li>
<!-- /wp:list-item --></ol>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Below is the example test where the local volume <code>/Users/naveenkumar/Tools/apache-jmeter-5.6.2/bin/jmeter-tests</code> is mapped to the container volume <code>jmeter-tests</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Here is the content in <code>/Users/naveenkumar/Tools/apache-jmeter-5.6.2/bin/jmeter-tests</code> folder in my local.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":17707,"width":"640px","height":"auto","aspectRatio":"2.0717131474103585","sizeSlug":"full","linkDestination":"media"} -->
<figure class="wp-block-image aligncenter size-full is-resized"><a href="https://qainsights.com/wp-content/uploads/2023/11/image-4.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-4.png" alt="JMeter tests" class="wp-image-17707" style="aspect-ratio:2.0717131474103585;width:640px;height:auto"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Above artifacts will be shared with the Docker container once it is up and running. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":17706,"width":"712px","height":"auto","aspectRatio":"1.8156028368794326","sizeSlug":"large","linkDestination":"media"} -->
<figure class="wp-block-image aligncenter size-large is-resized"><a href="https://qainsights.com/wp-content/uploads/2023/11/image-3.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-3-1024x564.png" alt="Run JMeter Tests" class="wp-image-17706" style="aspect-ratio:1.8156028368794326;width:712px;height:auto"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In the above example, <code>/jmeter-tests/CSVSample.jmx</code> will be executed inside the container. It will use the below <code>loadtest.properties</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":17708,"sizeSlug":"full","linkDestination":"media"} -->
<figure class="wp-block-image aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2023/11/image-5.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-5.png" alt="Sample loadtest.properties" class="wp-image-17708"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Once all the values are configured, hit the <code>Run JMeter Test</code> button.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>During the test you can pay attention to a couple of sections. One is console logs. For each test, the runtime logs will be streamed from the Docker container as shown below.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":17710,"sizeSlug":"full","linkDestination":"media"} -->
<figure class="wp-block-image aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2023/11/image-6.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-6.png" alt="Output Console Logs" class="wp-image-17710"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In case there are any errors, you can check them under <strong>Notifications</strong> section.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":17711,"sizeSlug":"full","linkDestination":"media"} -->
<figure class="wp-block-image aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2023/11/image-7.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-7.png" alt="Docker Extension Notifications" class="wp-image-17711"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Once the test is done, <strong>Notifications </strong>will display the status and the location of HTML report (your mapped volume). </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":17712,"sizeSlug":"large","linkDestination":"media"} -->
<figure class="wp-block-image size-large"><a href="https://qainsights.com/wp-content/uploads/2023/11/image-8.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-8-1024x611.png" alt="After the test" class="wp-image-17712"/></a></figure>
<!-- /wp:image -->

<!-- wp:image {"id":17713,"sizeSlug":"large","linkDestination":"media"} -->
<figure class="wp-block-image size-large"><a href="https://qainsights.com/wp-content/uploads/2023/11/image-9.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-9-1024x232.png" alt="JTL report" class="wp-image-17713"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Here is the auto-generated HTML report.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":17715,"width":"686px","height":"auto","aspectRatio":"1.9883495145631067","sizeSlug":"large","linkDestination":"media"} -->
<figure class="wp-block-image size-large is-resized"><a href="https://qainsights.com/wp-content/uploads/2023/11/image-10.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-10-1024x515.png" alt="HTML Report" class="wp-image-17715" style="aspect-ratio:1.9883495145631067;width:686px;height:auto"/></a></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2 class="wp-block-heading">How JMeter Docker Extension works and its architecture?</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>On a high level, how this extension is simple as shown in the below diagram. Once you click on the <strong>Run</strong> button, the extension first validates all the input and the required fields. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If the validation check passes, then the extension will look up the artifacts from the mapped volume. Then it passes all respective JMeter arguments to the image <code>qainsights/jmeter:latest</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>If the image is not present, it will get pulled from the Docker container registry. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Then the container will be created up by Docker and perform the test execution. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>During the test execution, container logs will be streamed to the output console logs.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>To stop the test, click the <strong>Terminate </strong>button to nuke the container. This action is irreversible and will not generate any test results.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":17717,"sizeSlug":"large","linkDestination":"media"} -->
<figure class="wp-block-image size-large"><a href="https://qainsights.com/wp-content/uploads/2023/11/JMeter-Docker-Extension-Architecture.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/JMeter-Docker-Extension-Architecture-1024x604.png" alt="JMeter Docke Extension Architecture" class="wp-image-17717"/></a></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Once the test is done, HTML report and the logs will be shared with the mapped volume.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">How to uninstall the extension?</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>There are two ways to uninstall the extension. Using the CLI, issue <code>docker extension uninstall qainsights/jmeter-docker-extension:0.0.1</code> or from the Docker Desktop.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Navigate to Docker Desktop &gt; Extensions &gt; JMeter, then click on the menu to uninstall as shown below.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":17726,"sizeSlug":"full","linkDestination":"media"} -->
<figure class="wp-block-image aligncenter size-full"><a href="https://qainsights.com/wp-content/uploads/2023/11/image-11.png"><img src="https://qainsights.com/wp-content/uploads/2023/11/image-11.png" alt="Uninstall JMeter Docker Extension" class="wp-image-17726"/></a></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Known Issues</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>There are a couple of issues (or more :) if you find) you can start the test as much as you want to generate more load to the target under test. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Supports only frequently used JMeter arguments. If you would like to add more arguments, please raise an issue in the <a href="https://github.com/qainsights/jmeter-docker-extension">GitHub</a> repo.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Upcoming Features</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>There are a couple of features I am planning to implement based on the reception. </p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Add a dashboard to track the tests</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Display graphs/charts runtime</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>Way to add JMeter plugins on the fly</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>If you have any other exciting ideas, please let me know.</p>
<!-- /wp:paragraph -->

<!-- wp:generateblocks/button {"uniqueId":"ea0a0ded","hasUrl":true,"blockVersion":4,"display":"inline-flex","spacing":{"paddingTop":"15px","paddingRight":"20px","paddingBottom":"15px","paddingLeft":"20px"},"backgroundColor":"#0366d6","backgroundColorHover":"#222222","textColor":"#ffffff","textColorHover":"#ffffff"} -->
<a class="gb-button gb-button-ea0a0ded gb-button-text" href="https://github.com/qainsights/jmeter-docker-extension">JMeter Docker Extension GitHub Repo</a>
<!-- /wp:generateblocks/button -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Conclusion</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>In conclusion, the introduction of the Apache JMeter Docker Extension is a significant step forward for developers and testers looking to streamline their performance testing workflow. With this open-source and lightweight extension, you can run JMeter tests in Docker without the need to install JMeter locally, saving you time and resources.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Despite a few known issues and limitations, such as supporting only frequently used JMeter arguments, the extension holds promise for the future.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>In summary, the Apache JMeter Docker Extension provides a valuable tool for developers and testers, enabling them to perform JMeter tests efficiently within Docker containers, and it's a welcome addition to the Docker Extension ecosystem. It's worth exploring for anyone involved in performance testing and looking to simplify their workflow.</p>
<!-- /wp:paragraph -->