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

Refactoring getToken() #101

Merged
merged 7 commits into from
Apr 4, 2024
Merged

Refactoring getToken() #101

merged 7 commits into from
Apr 4, 2024

Conversation

paolomanca-pagopa
Copy link
Contributor

@paolomanca-pagopa paolomanca-pagopa commented Apr 3, 2024

getToken() has been restructured in this way:

  1. role parameter has a default value. (default is: "admin")
    All invocation, except one in common-step.ts, call this function with role = "admin"; so this value gets default value in parameter's function.

  2. token generation has moved from BeforeAll() features/common-steps.ts to utils/commons.ts; token generation is inside local function getToken() and not in global cucumber context. Token generation is called only the first time getToken() is called.

Now the getToken() invocation is simplified:
const token = await getToken(tenantType); // default role = "admin"
const token await getToken(tenantType, role);

I run all test after modification:

p bun:test:ready.  

802 scenarios (7 failed, 795 passed)
3723 steps (7 failed, 17 skipped, 3699 passed)
37m03.175s (executing steps: 183m38.099s)
error: "cucumber-js" exited with code 1

Only 7 has failed, for this reason:

Error: Something went wrong: "The server was not able to produce a timely response to your request.\r\nPlease try again in a short while!"
           at assertValidResponse (/Users/lap-mbp16-n01-0355/Projects/interop-qa/interop-qa-tests/utils/commons.ts:156:4)
           at <anonymous> (/Users/lap-mbp16-n01-0355/Projects/interop-qa/interop-qa-tests/services/data-preparation.service.ts:121:24)
           at processTicksAndRejections (:12:39)

Remarks:

getToken() is executed many times as N workers in parallel execution, same behavior then BeforeAll()

Some references about parallelization:

@AsterITA AsterITA marked this pull request as ready for review April 3, 2024 09:52
Base automatically changed from given_refactor to main April 4, 2024 08:14
@AsterITA AsterITA merged commit c7a7e73 into main Apr 4, 2024
5 checks passed
@AsterITA AsterITA deleted the token_refactor branch April 4, 2024 09:24
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

Successfully merging this pull request may close these issues.

2 participants