Short notes on K6 load test

If you find this free website useful – why don’t you support this with a donation? It is easy…. read more ….

Load test a form

Install K6
Install influxdb

Install grafana

Set up script e.g

import http from 'k6/http';

export let options = {
  scenarios: {
    constant_request_rate: {
      executor: 'constant-arrival-rate',
      rate: 3,
      timeUnit: '1s',
      duration: '1m',
      preAllocatedVUs: 50,
      maxVUs: 100,
    },
  },
};

export default function () {
  var url = 'https://domain-test';
// if you need to post stuff to make a form work
  var payload = {
    __nonce: 'load_test', // code a nonce bypass
    'param1': 'value1',
  };

  var params = {
    headers: {
// for form
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  };

  http.post(url, payload, params);
}

Start services

sudo service grafana-server start
sudo service influxdb start

Run test

k6 run -o influxdb=http://localhost:8086/mydb test.js

Watch in graphana, user admin, pass admin

http://localhost:3000

Shut services

sudo service grafana-server stop
sudo service influxdb stop


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *