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

E2E Utils: Add retry mechanism to the REST API discovery #62331

Merged
merged 11 commits into from
Jun 5, 2024

Conversation

WunderBart
Copy link
Member

@WunderBart WunderBart commented Jun 5, 2024

Fixes #61627
Fixes #60366

Related thread: https://wordpress.slack.com/archives/C02QB2JS7/p1717143284055259

What?

Add a retry mechanism to the REST API discovery so that it doesn't fail when the env is not ready yet.

Testing Instructions

  • All tests should pass.
  • Perf tests on trunk have been failing, so I've triggered a workflow using params from the failing job with this branch as a test runner. It should pass.

@WunderBart WunderBart marked this pull request as ready for review June 5, 2024 11:29
Copy link

github-actions bot commented Jun 5, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: WunderBart <bartkalisz@git.wordpress.org>
Co-authored-by: kevin940726 <kevin940726@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: GraemeF <graemef@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@WunderBart WunderBart self-assigned this Jun 5, 2024
@WunderBart WunderBart requested a review from jsnajdr June 5, 2024 11:31
@WunderBart WunderBart added [Tool] E2E Test Utils /packages/e2e-test-utils [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. labels Jun 5, 2024
Copy link
Member

@kevin940726 kevin940726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! A few nitpicks but it's good to go IMO!

@WunderBart WunderBart force-pushed the fix/e2e-add-retry-mechanism-to-api-discovery branch from 66092fd to 5192d36 Compare June 5, 2024 14:22
@WunderBart WunderBart force-pushed the fix/e2e-add-retry-mechanism-to-api-discovery branch from 5192d36 to 60bf411 Compare June 5, 2024 15:25
},
{
message: 'Failed to setup REST API.',
timeout: 60_000, // 1 minute.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Do we have a rough number when the REST API will be available? A minute seems like a long wait if it returns nothing. Is 5 seconds or 10 seconds enough?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, and I have no idea TBH. Testing this thing takes ages, and it only fails in CI. Having said that, since this solution seems to be working across the board, I can lower the timeout value and do a couple more reruns. We can also address it in a follow-up PR since the failing perf tests keep blocking folks. What do you think?

reporter: process.env.CI
? './config/performance-reporter.ts'
: [ [ 'list' ], [ './config/performance-reporter.ts' ] ],
reporter: [ [ 'list' ], [ './config/performance-reporter.ts' ] ],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should merge it with this change as it now prints the errors correctly, which would allow us to close #60366. What do you think @Mamaduka @kevin940726?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. The performance test results are now attached to the summary so they won't be lost in the noise (#61450).

Copy link
Member Author

@WunderBart WunderBart Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, enabling the list reporter in this case actually means that only the error will be printed, not the tests themselves. It's because we're still using promisified exec and don't resolve with the stdout data. So, nothing in the output will change unless an error is thrown! 😄

An example error looks like this now:

▶ Running tests
    > Using: WordPress v6.5
    > Suite: front-end-block-theme (round 1 of 1)
        > Branch: 9aec5fe38aa66962d1b0dc3c73bc22c7af08e3c5
            > Starting environment
            > Running tests

> gutenberg@18.5.0-rc.1 test:performance
> wp-scripts test-playwright --config test/performance/playwright.config.ts front-end-block-theme

Error: expect(received).not.toThrow()

Matcher error: received value must be a function

Received has value: undefined

Call Log:
- Timeout 60000ms exceeded while waiting on the predicate

   at ../../../packages/e2e-test-utils-playwright/src/request-utils/rest.ts:46

  44 | 	let rootURL = '';
  45 |
> 46 | 	await expect
     | 	^
  [47](https://github.com/WordPress/gutenberg/actions/runs/9385403378/job/25843486775#step:8:48) | 		.poll(
  48 | 			async () => {
  49 | 				[ nonce, rootURL ] = await Promise.all( [

    at RequestUtils.setupRest (/tmp/wp-performance-tests/tests/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:46:2)
    at globalSetup (/tmp/wp-performance-tests/tests/test/performance/config/global-setup.ts:26:2)



Error: Command failed: npm run test:performance -- front-end-block-theme

    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:[51](https://github.com/WordPress/gutenberg/actions/runs/9385403378/job/25843486775#step:8:52)9:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
  code: 1,
  killed: false,
  signal: null,
  cmd: 'npm run test:performance -- front-end-block-theme'

Before it was printing just the genericNodeError part, and now all the necessary info is there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know 😅

Copy link
Member Author

@WunderBart WunderBart Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinging @jsnajdr, since it also means we don't need to refactor to spawn! 😄

Copy link

github-actions bot commented Jun 5, 2024

Flaky tests detected in 2b68944.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9387734581
📝 Reported issues:

@WunderBart WunderBart enabled auto-merge (squash) June 5, 2024 16:57
@WunderBart WunderBart disabled auto-merge June 5, 2024 16:57
@WunderBart WunderBart enabled auto-merge (squash) June 5, 2024 16:57
@WunderBart WunderBart merged commit 8d15c5f into trunk Jun 5, 2024
66 checks passed
@WunderBart WunderBart deleted the fix/e2e-add-retry-mechanism-to-api-discovery branch June 5, 2024 16:58
@github-actions github-actions bot added this to the Gutenberg 18.6 milestone Jun 5, 2024
patil-vipul pushed a commit to patil-vipul/gutenberg that referenced this pull request Jun 17, 2024
…2331)

Co-authored-by: WunderBart <bartkalisz@git.wordpress.org>
Co-authored-by: kevin940726 <kevin940726@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: GraemeF <graemef@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] E2E Test Utils /packages/e2e-test-utils [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
Projects
None yet
4 participants