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.04k stars 511 forks source link

One time login for multiple scenarios. #653

Open sureshkrishnaselvam opened 5 years ago

sureshkrishnaselvam commented 5 years ago

@hassy We need to execute login call only once for multiple scenarios in which there will be multiple f lows as well. Could you please suggest best way to call a login function only once based on the response it has execute multiple scenarios which follows after login response.

SandroGrzicic commented 5 years ago

Similarly, it would be great if we could run a single "login" HTTP call scenario, which runs before all other scenarios, and then run 1 or more websocket scenarios (which can then make use of captured e.g. sessionIds from the login call) . Currently it seems that we can either run HTTP or websocket scenarios within a single test. Thanks!

NivLipetz commented 5 years ago

This PR https://github.com/artilleryio/artillery/pull/625 solves this issue. You can login using the 'before' feature, capture the sessionId if needed and use it in the rest of the test. The before scenario is run only once before the test begins

SandroGrzicic commented 5 years ago

This PR #625 solves this issue. You can login using the 'before' feature, capture the sessionId if needed and use it in the rest of the test. The before scenario is run only once before the test begins

Thanks, will this enable the possibility of combining a single engine: "http" "before" scenario with multiple engine: "ws" scenarios, e.g. be able to login using the HTTP call and then use the captured credentials in the websocket calls? Thanks.

gregormci commented 5 years ago

If your willing to create a local redis server then i've found that i store my login response in a redis key, on each scenario that runs a quick check for this value. if exists then uses it. if not exists then js script to set a variable that i use (hit login url ifTrue). i'm going to use redis to store GLOBAL variables for the other scenarios to read from. downside is perhaps adding slight time to read from redis and that may impact your times. but for me it's suitable solution.

riechst1 commented 5 years ago

I'm running into the same scenario where I need to have a call made to an API to obtain a jwt token. I know it has been mentioned about the 'before' feature, but it seems to not work in the latest community release. Is that feature only for paid customers?

Forgot to mention that I've tried the before feature in yml and not in json schema. Any pointers will help. Thanks.


Update: The before option works fine, I just had a syntax error in my yaml. I would suggest to have documentation updated as its difficult to troubleshoot when going to commits.

before: flow:

The above is a ymal example to get the one time login working for future users

Lillypot commented 4 years ago

This PR #625 solves this issue. You can login using the 'before' feature, capture the sessionId if needed and use it in the rest of the test. The before scenario is run only once before the test begins

One of the thing this feature doesn't take into account is refreshing the token every hour as it expires. Is this going to included in this?