artilleryio / artillery

The complete load testing platform. Everything you need for production-grade load tests. Serverless & distributed. Load test with Playwright. Load test HTTP APIs, GraphQL, WebSocket, and more. Use any Node.js module.
https://www.artillery.io
Mozilla Public License 2.0
8.06k stars 511 forks source link

showAllPageMetrics doesn't work when Target is changed in runtime #3269

Open robin-miro opened 4 months ago

robin-miro commented 4 months ago

showAllPageMetrics by default is false, it enables webvitals metrics if the URL start with target

but it doesn't work if target is changed within runtime (within js file)

  engines:
    playwright:
      contextOptions: {}
      defaultNavigationTimeout: 60 # in seconds
      aggregateByName: false
      useSeparateBrowserPerVU: false
      launchOptions:
        headless: false
target: replace_me.example.com

in JS

    vuContext.vars.target = vuContext.vars.target.replace("replace_me","new")

Version info:

2.0.17

I expected to see this happen:

hassy commented 4 months ago

The relevant code is here, it's definitely possible to make it take other values into account. https://github.com/artilleryio/artillery/blob/main/packages/artillery-engine-playwright/index.js#L290

I'm curious to learn more about how/why you're overriding the target. It looks like your test may be injecting a different target into different VUs, which I presume the VU then uses for page.goto() calls?

Is there a reason that overriding config.target at runtime doesn't work? E.g. with something like artillery run --target https://mytargetoverride.com?

robin-miro commented 4 months ago

Hey @hassy

The target url will be like [something].mydomain.com, each customer may have their own sub-domain.

During the test, we are reading the data from a CSV file, within this CSV file, it will tell what is this "[something]"

so ideally, I would prefer to read variables from the CSV file and then directly use them within config.yaml, such as

target: "{{ $something }}.mydomain.com"

since it is not supported, then we use a workaround

target: "replace_me.mydomain.com"

and inside JS file, we did

    vuContext.vars.target = vuContext.vars.target.replace("replace_me", vuContext.vars.something)

unctionally it works perfectly, but metrics don't if we don't turn on "showAllPage".

Would like to hear your opinion?

My suggestion: