-
Notifications
You must be signed in to change notification settings - Fork 385
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
test(SSR e2e): Validate http port 4000 is not used by other process, before running tests #19337
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…0 if HTTP error occurred when calling other than cms/pages API URL"
…in logs. And provide more context about the problem with parsing
… proxy backend before running tests. Previously we were checking the app's behavior in the runtime of tests, checking its symptoms of running in dev mode.
… the port 4000. If yes, avoid running errors and give advice on how to kill that process
Platonn
changed the title
test(SSR e2e) Validate http port 4000 is not used by other process, before running tests
test(SSR e2e): Validate http port 4000 is not used by other process, before running tests
Oct 4, 2024
Full pipeline run with SSR tests: https://github.com/SAP/spartacus/actions/runs/11182025201 |
pawelfras
previously approved these changes
Oct 4, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. QA done
pawelfras
approved these changes
Oct 4, 2024
spartacus Run #45149
Run Properties:
|
Project |
spartacus
|
Branch Review |
feature/CXSPA-8587
|
Run status |
Passed #45149
|
Run duration | 00m 45s |
Commit |
a865c49d8c: test(SSR e2e): before running tests, check if some process listens on the port 4...
|
Committer | Krzysztof Platis |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
1
|
Pending |
22
|
Skipped |
0
|
Passing |
805
|
Upgrade your plan to view test results. | |
View all changes introduced in this branch ↗︎ |
spartacus Run #45153
Run Properties:
|
Project |
spartacus
|
Branch Review |
feature/CXSPA-8587
|
Run status |
Passed #45153
|
Run duration | 13m 22s |
Commit |
3a78c81992 ℹ️: Merge c5a41e3d2c2d30f843665436f0c3b7cae341c05c into 81c7302ba0da80a2e5feb3423281...
|
Committer | Krzysztof Platis |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
4
|
Pending |
2
|
Skipped |
0
|
Passing |
125
|
Upgrade your plan to view test results. | |
View all changes introduced in this branch ↗︎ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
Each SSR test starts and kills an SSR process in the background, listening on port 4000.
If you interrupt the tests that you run on local (e.g. by pressing Cmd+C), then the Jest tests process is stopped but the SSR process might be still dangling in the background.
So the next time you try to re-run SSR Tests, they'll fail with because the new SSR process cannot be started on the already occupied port 4000.
Previosuly, the we had to wait for all tests fail (30secons), until we were presented with an vague error message about port being in use. Moreover it didn't get any hint how to solve the problem.
Now, the problem is detected before running any test. The error message is descriptive and provides a hint how to kill a process that is listening on the conflicting port.
Note: Instead of detecting the problem and showing an useful message, my first strategy was to avoid the problem in general. I mean that whenever the parent Jest process is interupted, I wanted the child SSR process to be killed as well. I've tried hooks like
process.on('SIGTERM')
etc. , I've tried tampering the config of spawning thechild
process (removedetach: true
, addkillSignal
) or callingchild.unref()
, but I had various problems - the child process was still not killed when parent was interupted or the child process couldn't be killed withprocess.kill()
in the tests bodyQA steps
Build SSR
npm build:libs && npm build && npm build:local-http-backend
In one terminal run
npm run serve:ssr
In second terminal run
npm run test:ssr
Verify the following error message is presented in the second terminal:
BEFORE:
AFTER:
Kill the SSR process in the first terminal (e.g. using the commands from the advice from the console)
Re-run ssr tests in the second terminal and verity they pass
Fixes https://jira.tools.sap/browse/CXSPA-8587