@dwp/casa-spiderplan-k6-plugin

0.1.8 • Public • Published

Performance plugin for casa-spiderplan

Add performance testing to your Spiderplan Personas.

Features:

  • Generates a k6 script for each of your personas

Pre-requisites

  • NodeJS 16.17.0+

Getting started

Install the plugin:

npm i -DE @dwp/casa-spiderplan-k6-plugin

Configure your worker bootstrap script to enable this plugin:

const perf = require('@dwp/casa-spiderplan-k6-plugin');

module.exports = ({ sharedState }) => {
  // Other setup stuff ..

  // Load hooks
  const hooks = [
    ...await perf({
      // Output directory to store k6 scripts
      dir: '.k6/',

      // Shared memory (required)
      sharedState,
    }),
  ];

  // Along with the other worker-init attribute, return the "hooks" attribute
  // containing the list of hooks that will be used
  return {
    hooks,
  };
};

Run your Spiderplan tests as normal. Be mindful that the host environment against which your personas are run muct be similarly running when you run finally execute the k6 scripts later. For example, if your app depends on any running external services, then those same services will need to be running when executing the k6 scripts.

Scripts are written to the output directory (default .k6/).

Executing k6 scripts

Once the scripts have been generated, you are free to pass them through k6 however you see fit. Here's an example, use docker:

# Start your target service locally - starts on http://localhost:3000/, for example
npm start

# Execute one of the generated k6 scripts against that target
docker run -i --rm --name k6 \
  -e hostname=http://host.docker.internal:3000 \
  loadimpact/k6 run - <$PWD/.k6/your-persona.js

Process overview

The following Spiderplan hooks are used:

  • post-submit-form
    Logs an entry for the final k6 script that GETs and POSTs to the appropriate waypoint
  • post-process-persona
    Generates the k6 script for the persona and stores in the output directory (default .k6/)

Performance

On an MDM mac (16GB RAM, 2.2GHz 6core CPU), with all content variants enabled:

  • 303 Personas
  • 6 worker threads
  • Execution time: 4m5s

References

Readme

Keywords

none

Package Sidebar

Install

npm i @dwp/casa-spiderplan-k6-plugin

Weekly Downloads

73

Version

0.1.8

License

ISC

Unpacked Size

7.21 kB

Total Files

4

Last publish

Collaborators

  • dwp-bot
  • jgdwp
  • lhokktyn