JMETER -DOCKER -GITLAB INTEGRATION:
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
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.
- 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 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:
Report
Jmeter Test Html Report:
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.