Load Testing Tools

Select and configure load testing tools

We use k6 from Load Impact for the following reasons:

Read more about k6’s features and metrics:

Installation

We use Docker Compose for defining and running multi-container Docker applications

docker-compose.yml

version: '3'
services:
  influxdb:
    build:
      context: .
      dockerfile: Dockerfile.influxdb
    ports:
      - "8086:8086"
  grafana:
    build:
      context: .
      dockerfile: Dockerfile.grafana
    links:
      - influxdb
    environment:
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_BASIC_ENABLED=false
    ports:
      - "3000:3000"
  k6:
    build:
      context: .
      dockerfile: Dockerfile.k6
    ports:
      - "6565:6565"
    environment:
      - K6_OUT=influxdb=http://influxdb:8086/k6
    command: 'version'

It builds three Docker images:

And uses these Dockerfiles

Dockerfile.influxdb

FROM influxdb:1.2.2

USER root

# Create db
RUN /bin/bash -c "influxd run & sleep 5 && influx -execute 'CREATE DATABASE k6' && kill %1 && sleep 5"

CMD ["influxd"]

Dockerfile.grafana

FROM grafana/grafana:5.1.3

USER root

RUN apt-get update && apt-get -y install curl

# Change the default data directory (otherwise grafanadb won't persist)
RUN mkdir /var/lib/grafanadb
ENV GF_PATHS_DATA /var/lib/grafanadb

# Init Grafana and preconfigure data source to be influxdb
RUN ./init.sh

CMD ["/run.sh"]

init.sh

#!/bin/bash

# Init Grafana and preconfigure data source to be influxdb
/run.sh

sleep 15

curl -s -H "Content-Type: application/json" -X POST \
    --data '{"name": "myinfluxdb", "type": "influxdb", "access": "proxy", "url": "http://influxdb:8086", "database": "k6", "isDefault": true}' \
    http://admin:[email protected]:3000/api/datasources

kill -SIGINT %%

Dockerfile.k6

FROM loadimpact/k6:0.20.0

USER root

WORKDIR /root/

ENV PATH "$PATH:/root"

ENTRYPOINT ["./k6"]

Run docker-compose up to build the containers and run InfluxDB and Grafana in the background

docker-compose up -d influxdb grafana

Open localhost:3000 to see Grafana running.

By default, Grafana does not come with any pre-configured dashboards.

We will install this dashboard to visualize k6 metrics dashboards-2587

Go to +/Import menu and paste https://grafana.com/dashboards/2587 URL into the Grafana.com Dashboard field, then click Load button. Then select myinfluxdb from the Select a InfluxDB data source dropdown and click Import.

Import Grafana Dashboard