Getting Started with Predator - ruthless API performance testing
Tags: testing, performancetesting, opensource, docker
Published: 2020-05-14 03:01:32

This blog post originally appeared on my blog [QAInsights.com](https://qainsights.com)

<!-- wp:paragraph -->
<p>There are lot of tools, solutions, and framework is available for performance testing. The most well-known tools such as Apache JMeter, Micro Focus LoadRunner, Gatling, Neotys NeoLoad etc., has large user base and community. When I was browsing thru chaos engineering, I landed to <a href="https://www.predator.dev/" target="_blank" rel="noreferrer noopener">predator.dev</a> page accidentally. Later I spent half-a-day to explore about Predator and its features. This blog will feature Predator and how to get started with performance testing using Docker.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>What is Predator?</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Predator is free, open-source, and distributed load testing tool especially for APIs performance testing. The team behind Predator is PayU. Predator supports installation in Docker, Kubernetes, and DC/OS.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>You can run unlimited tests using unlimited resources with unlimited threads/virtual users. Because you will be using your own infrastructure for performance testing.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I am not going to compare Predator with other tools’ features. Each tool comes with its own set of features and limitations.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>More technical definition</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><em>Predator is an open-source performance framework we created for ourselves. We were fed up with the limitations of out-of-the-box solutions and the complication of writing complex custom tests. We designed Predator to manage the entire lifecycle of stress-testing a server, from creating a test file, to running scheduled and on-demand tests, and finally viewing the test results. Bootstrapped with a user-friendly UI alongside a simple REST API, Predator helps developers simplify the performance testing regime.</em></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>On-boarding</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Installing Predator is quite simple if you are already experienced in Docker or k8s or DC/OS.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>For Docker:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>w/o persistent storage, fire the below command</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>docker run -d -e JOB_PLATFORM=DOCKER -e INTERNAL_ADDRESS=http://$MACHINE_IP:80/v1 -p 80:80 --name predator -v /var/run/docker.sock:/var/run/docker.sock zooz/predator</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>w/ persistent storage, use</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>docker run -d -e SQLITE_STORAGE=db/predator -e JOB_PLATFORM=DOCKER -e INTERNAL_ADDRESS=http://$MACHINE_IP:80/v1 -p 80:80 --name predator -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/predator:/usr/db zooz/predator</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>After successful installation, you can access the UI at <a href="http://localhost/UI">http://localhost/UI</a> or <a href="http://%7b$MACHINE_IP%7d/ui">http://{$MACHINE_IP}/ui</a></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>For Kubernetes:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>You can install Predator using the Helm.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>helm repo add zooz <a href="https://zooz.github.io/helm/">https://zooz.github.io/helm/</a></code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>helm install zooz/predator --version 1.3</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>For DC/OS:</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Install thru Universe <a href="https://universe.dcos.io/#/package/predator/version/latest">https://universe.dcos.io/#/package/predator/version/latest</a> within the cluster.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Getting Started</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>To get started, I will be running Predator in Docker in Windows 10 Pro. After successful installation, Predator will be up and running in http://localhost/ui</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":7270,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://qainsights.com/wp-content/uploads/2020/05/image-9.png" alt="Getting Started with Predator - ruthless API performance testing" class="wp-image-7270"/><figcaption>Getting Started with Predator - ruthless API performance testing</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>This is how homepage looks. The user interface is built using React framework.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":7271,"sizeSlug":"large"} -->
<div class="wp-block-image"><figure class="aligncenter size-large"><img src="https://qainsights.com/wp-content/uploads/2020/05/image-10.png" alt="Predator Home Page" class="wp-image-7271"/><figcaption>Predator Home Page</figcaption></figure></div>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Before you start your first test, make sure the Settings are properly configured. Internal address should point to local IP address if you are running Predator locally.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":7290,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://qainsights.com/wp-content/uploads/2020/05/image-26-1024x579.png" alt="Predator Configuration" class="wp-image-7290"/><figcaption>Predator Configuration</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In Settings page, you can configure Benchmarks, SMTP, Metrics, Resource configuration, and you can also do housekeeping the containers.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Sample Demo Application</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Before we begin creating our first test, let us install sample pet store from Swagger docker.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_URL=http://localhost -e SWAGGER_BASE_PATH=/v2 -p 3001:8080 swaggerapi/petstore</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I am using the port 3001 to install the Swagger pet store. Below is my sample API call to the pet’s details.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":7273,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://qainsights.com/wp-content/uploads/2020/05/image-12.png" alt="Sample Demo" class="wp-image-7273"/><figcaption>Sample Demo</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Predator does come with sample pet store docker image. But for me it did not work, hence I installed Swagger pet store.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>First Test</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>To create your first test, click on <strong>Tests </strong>and then click on <strong>Create Test</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":7274,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://qainsights.com/wp-content/uploads/2020/05/image-13.png" alt="Predator Tests" class="wp-image-7274"/><figcaption>Predator Tests</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Let us test our demo API <a href="http://%7bmachineip%7d:3001/v2/pet/10">http://{machineip}:3001/v2/pet/10</a> by configuring below details in Test and then hit Submit. This will create a test and displays it in the Tests page.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>You can create multiple scenarios and multiple API calls based on your test strategy.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":7288,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://qainsights.com/wp-content/uploads/2020/05/image-25-1024x547.png" alt="Create Test in Predator" class="wp-image-7288"/><figcaption>Create Test in Predator</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>To run the test, click on <strong>Run </strong>button as shown below. Predator uses jobs to execute the test.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":7293,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://qainsights.com/wp-content/uploads/2020/05/image-27-1024x284.png" alt="Run Predator Test" class="wp-image-7293"/><figcaption>Run Predator Test</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Configure below job details and then clicking on Submit will trigger the test immediately.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":7286,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://qainsights.com/wp-content/uploads/2020/05/image-23.png" alt="Predator Job" class="wp-image-7286"/><figcaption>Predator Job</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Launch powershell or command prompt and issue <strong>docker ps</strong> command to see the running containers. Predator will create a container which will execute the tests.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":7285,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://qainsights.com/wp-content/uploads/2020/05/image-22-1024x229.png" alt="Predator Running Container" class="wp-image-7285"/><figcaption>Predator Running Container</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>Viewing Report</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>During the test run or after its completed, you can view the report in Last Reports page. Click on View button on the appropriate test name as shown below.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":7284,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://qainsights.com/wp-content/uploads/2020/05/image-21-1024x473.png" alt="Viewing report" class="wp-image-7284"/><figcaption>Viewing report</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2>Sample report</h2>
<!-- /wp:heading -->

<!-- wp:image {"id":7283,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://qainsights.com/wp-content/uploads/2020/05/image-20-1024x546.png" alt="Predator Report" class="wp-image-7283"/><figcaption>Predator Report</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In next blog we will see more details like architecture, Predator background, advanced features in detail. Please let me know if you have any questions. Happy to help you.</p>
<!-- /wp:paragraph -->