artillery icon indicating copy to clipboard operation
artillery copied to clipboard

Functional testing with artillery-plugin-expect does not guarantee completeness

Open LesterTheTester opened this issue 5 years ago • 5 comments

I am trying to use artillery-plugin-expect to also run my artillery tests as functional tests. However, the environment configuration shown to do this on the npm module page doesn't take into account the possiblity that one config file has multiple named scenarios:

config:
  environments:
    local:
      target: 'http://localhost:3000/'
      phases:
        - duration: 1
          arrivalRate: 1
      plugins:
        expect: {}
    staging:
      target: 'https://staging.myserver.com/'
      phases:
        - duration: 120
          arrivalRate: 10
  ensure:
    maxErrorRate: 1
scenarios:
  - name: Endpoint 1
    flow:
      - get:
          url: "/endpoint1"
          expect:
            - statusCode: 200
  - name: Endpoint 2
    flow:
      - get:
          url: "/endpoint2"
          expect:
            - statusCode: 200

It seems providing duration: 1 and arrivalRate: 1 means artillery will only ever execute 1 of my scenarios. Furthermore, due to the random selection, even if I change to arrivalRate: 2, I may just get two of the same scenario.

For proper functional testing, we need to validate ALL our scenarios in each run. Am I missing something here?

LesterTheTester avatar Sep 06 '19 22:09 LesterTheTester

The way to go right now is to keep your scenarios in separate files, extract config to its own file too, and use the --config option to run your tests with common configuration. Your folder structure would look like this:

tests/
  - scenarios/
      - product-search.yaml
      - get-offers.yaml
      - checkout.yaml
  - config/
      - common.yaml

And you'd run your test with:

artillery run --config config/common.yaml scenarios/checkout.yaml

We're working on a way to run a number of given scenarios exactly once for this use-case for a future release of Artillery.

hassy avatar Sep 07 '19 12:09 hassy

So it seems for now that I have to specify each one of my scenarios individually, artillery run --config src/e2e/config/common.yaml -e local src/e2e/scenarios/* results in just the first scenario being run. Is that correct?

LesterTheTester avatar Sep 09 '19 18:09 LesterTheTester

Yes, that's correct. Artillery's run command does not guarantee that all scenarios given to it will be executed exactly once right now.

hassy avatar Sep 26 '19 10:09 hassy

@hassy how about now?

vegerot avatar May 06 '20 12:05 vegerot

Hi @hassy Is there news about this? thanks!

jmrivas86 avatar Jun 13 '22 23:06 jmrivas86