Sequentially run scenarios

I have three tests which I want to run sequentially, after the one is completely done. I am using scenarios and I got it working, but as of now my tests are being run simultaneously.

I have been looking for quite a while now, without success. I get the feeling that I am completely overlooking the answer for this.

My code:

import runLoginTest from './loginTest.js'
import runGetCustomizationTest from './get-customizationTest.js'
import runGetCustomizationsTest from './get-customizationsTest.js'

export const options = {
  scenarios: {
    login_test: {
      executor: 'constant-vus',
      vus: 5,
      duration: '10s',
      gracefulStop: '0s',
      exec: 'loginTest',
    },
    get_customization_test: {
      executor: 'constant-vus',
      vus: 5,
      duration: '10s',
      gracefulStop: '0s',
      exec: 'getCustomizationTest',
    },
    get_customizations_test: {
      executor: 'constant-vus',
      vus: 5,
      duration: '10s',
      gracefulStop: '0s',
      exec: 'getCustomizationsTest',
    },
  },
}

export function loginTest () {
  runLoginTest()
}

export function getCustomizationTest () {
  runGetCustomizationTest()
}

export function getCustomizationsTest () {
  runGetCustomizationsTest()
}

Thank you for reading and for the help in advance.

See the startTime option in https://k6.io/docs/using-k6/scenarios

In your case, it’d go somewhat like this:


export const options = {
  scenarios: {
    login_test: {
      executor: 'constant-vus',
      vus: 5,
      duration: '10s',
      gracefulStop: '0s',
      exec: 'loginTest',
    },
    get_customization_test: {
      executor: 'constant-vus',
      vus: 5,
      duration: '10s',
      gracefulStop: '0s',
      exec: 'getCustomizationTest',
      startTime: '10s',  // duration + gracefulStop of the above
    },
    get_customizations_test: {
      executor: 'constant-vus',
      vus: 5,
      duration: '10s',
      gracefulStop: '0s',
      exec: 'getCustomizationsTest',
      startTime: '20s',  // duration + gracefulStop of the above
    },
  },
}
2 Likes

That does the job, thanks! Turns out I’ve been overlooking it all along.

1 Like