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
7.94k stars 507 forks source link

'capture' keyword doesn't seem working with 'before' keyword #3282

Closed artofz closed 2 months ago

artofz commented 2 months ago

Version info: 2.0.18 Node.js: 22.2.0

Running this command:

artillery run test.yml

I expected to see this happen:

I expected to get token from the request to /auth.

Instead, this happened:

/Users/user/.nvm/versions/node/v22.2.0/lib/node_modules/artillery/node_modules/@artilleryio/int-core/lib/engine_http.js:673
                    return done(new Error('Failed capture or match'), context);
                                ^

Error: Failed capture or match
    at /Users/user/.nvm/versions/node/v22.2.0/lib/node_modules/artillery/node_modules/@artilleryio/int-core/lib/engine_http.js:673:33
    at /Users/user/.nvm/versions/node/v22.2.0/lib/node_modules/artillery/node_modules/async/dist/async.js:473:16
    at replenish (/Users/user/.nvm/versions/node/v22.2.0/lib/node_modules/artillery/node_modules/async/dist/async.js:1009:25)
    at /Users/user/.nvm/versions/node/v22.2.0/lib/node_modules/artillery/node_modules/async/dist/async.js:1019:9
    at eachLimit$1 (/Users/user/.nvm/versions/node/v22.2.0/lib/node_modules/artillery/node_modules/async/dist/async.js:3199:24)
    at Object.<anonymous> (/Users/user/.nvm/versions/node/v22.2.0/lib/node_modules/artillery/node_modules/async/dist/async.js:1049:16)
    at captured (/Users/user/.nvm/versions/node/v22.2.0/lib/node_modules/artillery/node_modules/@artilleryio/int-core/lib/engine_http.js:628:21)
    at /Users/user/.nvm/versions/node/v22.2.0/lib/node_modules/artillery/node_modules/@artilleryio/int-commons/engine_util.js:499:16
    at /Users/user/.nvm/versions/node/v22.2.0/lib/node_modules/artillery/node_modules/async/dist/async.js:473:16
    at replenish (/Users/user/.nvm/versions/node/v22.2.0/lib/node_modules/artillery/node_modules/async/dist/async.js:1009:25)

Files being used:

config:
  target: 'http://localhost:9099' # 테스트 진행할 URL
  phases:
    - duration: 50
      arrivalRate: 3
  payload:
    - path: './data/article.csv'
      fields:
        - 'title'
        - 'content'
        - 'author'
        - 'domesticStockArticleType'

before:
  flow:
    - log: 'Get auth token'
    - post:
        url: '/auth'
        json:
          username: 'arto'
          password: 'localpassword'
        capture:
          - json: $.data.token
            as: token

scenarios:
  - flow:
      - post:
          url: '/admin/articles/recommendations'
          headers:
            authorization: 'Bearer {{ token }}'
          json:
            article:
              - {{ title }}
              - {{ content }}
              - {{ author }}
              - {{ domesticStockArticleType }}

[ For more information ]