March 3, 2022

What Is CircleCI Used For? Plus CircleCI and JMeter Integration Tips

Open Source Automation
DevOps

CircleCI is emerging in popularity. But what is CircleCI used for? In this post we will be discussing the CircleCI platform. We will quickly introduce the tool and explain how to integrate it with open source JMeter so you can execute load tests in your CI process.

Back to top

What is CircleCI Used For?

CircleCI is a continuous integration tool. CircleCI is used for building, testing, and deploying a project, by using automation. This automation takes place in pipelines with jobs.

 

These jobs include: 

  • A pipeline is a set of instructions or steps that our CI tool will execute each time our code is updated.
  • Jobs are a set of specific tasks for the building, testing and deploying stages. Each job is executed in a separate container or virtual machine.

After completion, CircleCI sends an email notification. For example, notifying of the success or failure after performance tests complete. 

CircleCI also includes integrated Slack and IRC notifications. You can configure CircleCI manually as you please or you can choose from the many available “orbs” in its orb registry to reuse configurations and simplify your work.

Back to top

Why Is CircleCI Important?

 

Nowadays, it is rare to find a company that does not use a continuous integration (CI) approach in their development processes. In case you are not familiar with it, continuous integration is a practice that encourages developers to integrate their code early and often into a shared repository.

CI tools can be configured to trigger your build and execute various sets of automated tests before merging. Depending on the configuration defined, they can even stop the integration if any failures are detected. This information will help the team identify issues early and fix them quickly, preventing bugs in your code. In other words, continuous integration improves team productivity, efficiency and confidence, so you can find problems and solve them quickly, to release higher quality and more stable products.

There are many tools that can help us implement a continuous integration approach in the development of our products. CircleCI is one of them.

Back to top

How to Create Pipelines in CircleCI

We will execute a JMeter testing script stored in a GitHub repository to test our application. You can access the repository used for this example here.

To create a pipeline in CircleCI follow these simple steps:

Step 1: Create a sample project in GitHub and upload your JMeter script there.

 

A screenshot of GitHub.

 

Step 2: Login to CircleCI using GitHub

 

 

A screenshot of logging into CircleCI.

 

Step 3a: Click on “Add Projects”

 

A screenshot of projects in CircleCI.

 

Step 3b: Select the created project

 

A screenshot of projects within CircleCI.


 

Step 3c: Select “Write your own config file”

 

A screenshot of a config.yml file.

 

Step 3d: Select “Skip this step”

 

A screenshot of config for CircleCI and JMeter.

Step 3e: Click on “Commit and Run”

 

A screenshot of the CircleCI and JMeter integration.

 

After this, your new pipeline will be triggered and a new branch will be created on your sample repository called “circleci-project-setup”.

That branch will contain a “.circleci” folder and inside that folder a file called “config.yml”, which will be in charge of telling our pipeline which steps to execute. Up next we will break down that file to understand how it works.

 

 

A screenshot of the CircleCI JMeter project.

The config.yml file

Your config.yml file should look something like this.

 

version: 2.1
    jobs:
      say-hello:
        docker:
          - image: cimg/base:stable
       steps:
          - checkout
          - run:
              name: "Say hello"
              command: "echo Hello, World!"
    workflows:
      say-hello-workflow:
        jobs:
          - say-hello
    

 

This sample configuration created by CircleCI has one simple step, that will print “Hello, World!” in the console. This is the default by CircleCI.

Let’s break down the different sections of this file:

 

A marked up screenshot of code.

 

In the next chapter we will tweak this config file to integrate our JMeter test to our pipeline.

 

Back to top

How to Integrate CircleCI and JMeter

In the following screenshot you can see the modified config.yml file that will set up our pipeline. 

 

A screenshot of the config.yml file.

 

Let’s talk about what this file is meant to accomplish.

Executor

First of all, we need to be able to execute our JMeter script on CircleCI. One of the easiest ways to accomplish this is to use a Docker image as our executor, with JMeter already configured on it. What it means is that when running our circleci-jmeter job, it will have all the configuration needed to run the JMeter script. 

You can search and choose from all Docker images available on this link. We recommend choosing among the images latest updated. In this case, we decided to use an image called “justb4/jmeter” for this example, which is declared in item 1 on the screenshot.

Steps

After setting up the executor to run our tests, we need to set the test steps according to our needs. For this example, we will do it in the following way: 

  • Create a “results” folder as we see in item 2 on the screenshot.
  • Run the tests using JMeter storing the results in a HTML report with the command seen in item 3 on the screenshot. (To learn more please visit this link.)
  • Store the results on our pipeline run artifacts as we see done on item 4 on the screenshot.

 

Lastly, we changed the job and workflow names in order to give more information about our pipeline’s steps and that’s it. We now have a fully functional pipeline that will trigger the execution of our JMeter script and automatically store its results.

 

Results in CircleCI

Now, if we go back to our pipeline in CircleCI we will see the execution with all the changes that we made in the config.yml file. If we open a pipe execution and go to the Artifacts tab, we’ll find a file called “index.html” containing the test results.

A screenshot of artifacts for the CircleCI JMeter project.
A screenshot of the JMeter dashboard.

 

If you want to read more about the information shown in this HTML report visit this link.

By following all these steps, you now have a basic CircleCI pipeline with a JMeter execution and a HTML report with the results.

You can access the repository used for this example here.

Try BlazeMeter, which runs JMeter tests easily and in the cloud and also integrates with CircleCI today!

START TESTING NOW

 

Back to top