Artillery: Add init hook or config file that runs before the scenarios

Created on 28 Oct 2016  路  3Comments  路  Source: artilleryio/artillery

The use case that I have is that I have a config file of login/passwords and environment settings that I want to load into the context before the scenarios are run. My current work around is to have a dummy request to an innocuous endpoint that uses a beforeRequest hook to init the context.

What I'd like to have is a parameter in the config block that either loads a config file into the context or an init hook that will call the processor to initialize the context from my config files.

docs

Most helpful comment

@hassy I think it's more about something that is run prior any scenario is picked, and only once per artillery run.

I'd even like a shutdown hook, as I'd then be able to do some automated cleanup of any temp file I'd generate during the run.

All 3 comments

@JohnieLee there's a way to run an arbitrary function using a function step, e.g.:

scenarios:
  - name: "A scenario"
    flow:
      - function: "setupContext"
      - get:
          url: "/some/endpoint/{{ someId }}"

where setupContext is something like:

function setupContext(context, ee, done) {
  context.vars.someId = 12345;
  return done();
}

Does this do what you need to do?

@hassy I think it's more about something that is run prior any scenario is picked, and only once per artillery run.

I'd even like a shutdown hook, as I'd then be able to do some automated cleanup of any temp file I'd generate during the run.

Going to close this as we have #131 already, which I'll add on to the 2.0 list.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanielMSchmidt picture DanielMSchmidt  路  4Comments

ericmacfarland picture ericmacfarland  路  6Comments

sureshkrishnaselvam picture sureshkrishnaselvam  路  6Comments

damon-kreft picture damon-kreft  路  3Comments

SamDecrock picture SamDecrock  路  5Comments