JMETER -DOCKER -GITLAB INTEGRATION:

Muneera Shaik
3 min readDec 15, 2023

--

Summary:

This is a scenario where we will use custom jmeter image to run on gitlab using docker for execution of UI [groovy + selenium + chromium] based performance test scenarios

What’s New?

Although there are many separate reads across google this article uniquely shows how to Integrate Front end based jmeter tests in to gitlab using docker.

Said so, we need selenium dependencies along with chrome browser installation etc.

So the docker file is specific to cater the configurations with respect to this scenario along with considering alpine linux where in chrome driver installation is quite different compared to other os flavours.

Apart from this the article also covers how a csv file created and updated at runtime during test execution inside docker container of gitlab runner can be retrieved as artifact in pipeline using volumes

Custom steps to update image and run Jmeter tests:

Pre-requisites:

  • Create a repo with updated docker file to install all the required configurations inside container as per our test scenario

My docker file for selenium and chrome configuration specific to alpine linux docker environment:

  • Add plugins folder inside repo
  • update run.sh with command to run tests
run command with options explained in detail

Note: Docker volumes usage of /builds directory explained in detail below

Basing on bel structure the files generated at run time must be created under “/builds” directory and mapped properly in the image.

Structure of volumes in Docker inside gitlab
  • upload repo to gitlab

Once the Repository is all setup in gitlab as mentioned above now its time to run the tests from gitlab.

create gitlab-ci.yml File :

The Key driver to run tests from Gitlab, will be based on creating the gitlab-ci.yml file, which will implement steps to run tests from the repo and enable user to manage the test execution workflow

Final gitlab-ci.yml file to succesfully run the jmeter tests with defined volume & options to run tests and generate reports

gitlab-ci.yml

gitlab-ci.yml file Explained:

  • stage => Name of test
  • service => is docker dind (service here) to install and run docker inside gitlab runner
  • tags => gitlab runner to execute the tests
  • before script => volume is created to capture the csv generated at run time
  • script => build jmeter image and run tests
  • Artifacts => Generate reports and retrieve csv from docker container via docker volumes mapping

Reports:

Artifacts in gitlab:

Artifacts

Report

Jmeter Test Html Report:

Sample successful report generated under Artifacts in gitlab under tests/reports/html

Runtime CSV generated during test execution:

As CSV creation and updation is part of jmeter test its critical to know docker volumes and mapping in gitlab runner

Summary: This is a custom approach to run jmeter UI tests succesfully in gitlab using docker and generating custom csv reports along with generic jmeter html reports.

--

--