This blog is all about gatling and Concourse CI. In this short blog, we will try to run our Gatling performance tests on concourse ci. This might seem to be a big task to do but believe me, it is not. We as QA engineers need to walk toe to toe with the new CI/CD tools so that our test cases are not left out and continuous testing takes place automatically with each new iteration.
So, let’s get started. But before that, let’s take a brief overview of the process of setting up Concourse locally.
Setting up Concourse.
Setting up a concourse is not a difficult task, we just need to run a couple of commands and that would suffice. Let me break the process into steps.
- Create a docker-compose.yml file for setting up the concourse. We can do so by executing the following cURL in our terminal
curl -O https://concourse-ci.org/docker-compose.yml
- Do a docker compose up for the YAML file created in the above step
docker-compose up -d
- That’s it, you have now Concourse up and running on port 8080. You can access the pipeline by opening http://localhost:8080/ on your browser.
- After this, you need to install fly. The Fly tool provides a command-line interface to Concourse. To install, execute the following commands.
$ curl 'http://localhost:8080/api/v1/cli?arch=amd64&platform=linux' -o fly \ $ chmod +x ./fly && mv ./fly /usr/local/bin/ $ fly -t tutorial login -c http://localhost:8080 -u test -p test
This will configure fly and that will be it. Now, we can proceed ahead and create a pipeline. But to create the pipeline and have Gatling’s performance tests integrated with it, we need to create a new YAML file for the pipeline. Let’s see how we can do that.
Creating the pipeline for gatling tests.
You may not find much on the web with respect to Gatling and Concourse. To be honest, I didn’t find it much difficult to have Gatling working with the concourse. All you need is a working Gatling project and a suitably configured YAML file for the pipeline. Firstly, the YAML that I’ve used is pulling up an image of sbt because I’m not using maven but sbt as a build tool for this project. You may take a reference from the YAML files mentioned below and can modify that for maven as well.
So, we have all the pre-requisite satisfied now. All we need to do is, provide the run command so that we can run our Gatling tests.
To do so, I’ve created a shell script that has the correct command to run our test. You can find the YAML file and the shell script below.
This is the YAML file that I’ve used to configure the pipeline. Please note that this YAML file will look for another YAML file named test.yml which will take a fresh pull of the sbt docker image and once done it will execute the shell script which will run the test command.
This is the YAML file that I’ve used to configure the pipeline.
resources: - name: gatling type: git source: uri: ((your_repo_URL_goes_here)) branch: master jobs: - name: gatling-test serial: true plan: - get: gatling trigger: true - task: run-test privileged: true file: gatling/test.yml
The test.yml file looks something like this,
platform: linux image_resource: type: docker-image source: repository: mozilla/sbt tag: latest inputs: - name: gatling outputs: - name: sbt-output run: path: /bin/sh args: - gatling/run.sh
The shell script is given below,
cd gatling sbt gatling:test
And that’s it. We have all the things in place to run our tests on the pipeline. The only thing that is left is to send the updated configurations to the pipeline using “fly”. Let’s see how we can do that.
Sending configurations to the pipeline using fly.
Furthermore, we need to send these pipeline jobs and configurations using fly. We can do so, by using the following command.
fly -t tutorial set-pipeline -p demo -c pipeline.yaml
Moving on, once you have executed this command you will see a message on your terminal screen stating something like this.
the pipeline is currently paused. to unpause, either: - run the unpause-pipeline command: fly -t tutorial unpause-pipeline -p demo - click play next to the pipeline in the web ui
On the concourse dashboard, you can see the pipeline that we have just created but the pipeline is paused currently, it won’t execute. To unpause it, use the following command
fly -t tutorial unpause-pipeline -p demo
Now, we have the pipeline ready to be executed.
Just click on the “+” sign. This will trigger the pipeline.
That’s all folks. I hope you may have found this useful. Please do check out our other blogs on a similar tech stack, https://blog.knoldus.com/category/tech-blogs/test-automation/.