Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel use error with exported variables #766

Open
auriou opened this issue Aug 9, 2024 · 0 comments
Open

Parallel use error with exported variables #766

auriou opened this issue Aug 9, 2024 · 0 comments

Comments

@auriou
Copy link

auriou commented Aug 9, 2024

I want to run load tests using httpyac's parallel mode, but it doesn't work when I use javascript blocks with exported variables.
Here is an example of code that works without parallel mode, but gives errors with this mode.

{{
    const { faker } = require('@faker-js/faker');
    exports.sexType = faker.person.sexType()
    exports.password = faker.internet.password({ length: 10})
    exports.firstName = faker.person.firstName(exports.sexType)
    exports.lastName = faker.person.lastName(exports.sexType)
    exports.email = faker.internet.email({ firstName: exports.firstName, lastName: exports.lastName });
    exports.phone = faker.helpers.fromRegExp(/0[67][0-9]{8}/)
    exports.auth = "Basic " + Buffer.from(exports.firstName + ":" + exports.password).toString("base64")
}}

GET https://httpbin.org/basic-auth/{{firstName}}/{{password}}
Authorization: {{auth}}

{{
    exports.user = response.parsedBody.user;
    console.log('user', exports.user)
}}

GET https://httpbin.org/uuid
Token: {{user}}
{{
    exports.uuid = response.parsedBody.uuid;
}}

POST https://httpbin.org/anything/{{user}}
Token: {{uuid}}

It's ok without parallel

httpyac.js send senario-httpbin.http  --all  -o short 

GET https://httpbin.org/basic-auth/Carrie/KjnXrfgHzK
=> 200 (657 ms, 231 B)
user Carrie
---------------------
GET https://httpbin.org/uuid
=> 200 (543 ms, 235 B)
---------------------
POST https://httpbin.org/anything/Carrie
=> 200 (871 ms, 752 B)
3 requests processed (3 succeeded))

but Error with parallel mode

httpyac.js send senario-httpbin.http  --all  -o short --repeat 10  --repeat-mode  parallel  --parallel 2

GET https://httpbin.org/basic-auth/Marsha/A6ZL0Eqs25
=> 200 (2760.8 ms, ?)
user undefined

---------------------

GET https://httpbin.org/uuid
Token: {{user}}
[-] user is not defined (ReferenceError: user is not defined - Object.userJS (C:/Users/p.auriou/Documents/GIT/httpyac/examples/faker/senario-httpbin.http:23:20)
expression user throws error

---------------------

POST https://httpbin.org/anything/{{user}}
Token: {{uuid}}
[-] user is not defined (ReferenceError: user is not defined - Object.userJS (C:/Users/p.auriou/Documents/GIT/httpyac/examples/faker/senario-httpbin.http:28:20)
expression user throws error

3 requests processed (1 succeeded, 2 errored))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant