In Multiple, each of the Test Stages is represented as a JavaScript function:

  1. Global Init
  2. VU Init
  3. VU Loop
  4. VU Cleanup
  5. Global Cleanup
Load Test Setup

Global Init

The globalInit() function runs once at the beginning of the load test. Typically you would set up the environment or prepare for the test here. To pass data from globalInit() to the other test stages, return the data from this function, and access it via ctx.globalInitData.

You can only return JSON serializable data from globalInit().

VU Init

The vuInit() function is run once per VU, before the VU Loop. To pass data from vuInit() to vuLoop() and vuCleanup() stages, return the data from this function, and access it via ctx.vuInitData.

You can return any data type from vuInit() (ie JSON, objects, auth tokens, database connections, ws connections, etc.)

VU Loop

vuLoop() is run repeatedly for the duration of the test. The next loop iteration does not start until the current loop’s code finishes executing, even if the Minimum VU Loop Duration has elapsed.

VU Cleanup

vuCleanup() runs once per VU after the VU Loop. Typically this stage would perform cleanup such as logging out, or closing a db or websocket connection.

Global Cleanup

globalCleanup() runs once at the very end of the test.