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

test: Add dynamic allocation port for ganache, fixtures and test dapp #7356

Merged
merged 15 commits into from
Oct 3, 2023

Conversation

vinistevam
Copy link
Contributor

@vinistevam vinistevam commented Sep 29, 2023

Description

This PR addresses an issue encountered when increasing the number of workers to 3 in the CI pipeline. The problem arose because, when increasing the number of jest workers, Detox creates new emulators in the same VM. However, existing fixtures, Ganache, and the test Dapp were not equipped to dynamically manage port allocation, causing test failures due to port conflicts between workers. These failures were particularly noticeable in confirmation tests, as they utilised Ganache, the test Dapp, and different fixtures for each test.

To resolve this issue, this PR introduces a dynamic port allocation mechanism that is deterministic and relies on process.pid instead of JEST_WORKER_ID because the worker id is different in the emulator but always 1 outside where servers are spun up. This approach ensures that the number of ports is different between the workers, eliminating port clashes and enabling smooth test execution in multi-worker environments.

Included all the confirmation tests in the smoke pattern (removed).

Manual testing steps

No functional change in the code.

E2E Pipeline

The build average time is 17m.

Before
https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/53f3a798-1302-4f91-89f0-c1ca724bee6e
image

After
without confirmations tests
https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/6994eecb-bb23-4161-bdac-9a8605334b49
image

with confirmations tests
https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/cd363c8a-8f09-4dd0-b822-132488d68852
image

Related issues

_Fixes https://github.com/MetaMask/MetaMask-planning/issues/1393

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained:
    • What problem this PR is solving.
    • How this problem was solved.
    • How reviewers can test my changes.
  • I’ve indicated what issue this PR is linked to: Fixes #???
  • I’ve included tests if applicable.
  • I’ve documented any added code.
  • I’ve applied the right labels on the PR (see labeling guidelines).
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@vinistevam vinistevam changed the title Test: Add dynamic port for ganache, fixtures and test dapp Test: Add dynamic allocation port for ganache, fixtures and test dapp Sep 29, 2023
@vinistevam vinistevam changed the title Test: Add dynamic allocation port for ganache, fixtures and test dapp test: Add dynamic allocation port for ganache, fixtures and test dapp Sep 29, 2023
@socket-security
Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
react-native-launch-arguments 4.0.1 None +0 26.7 kB iamolegga

@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (46b493b) 34.59% compared to head (072a313) 34.59%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7356   +/-   ##
=======================================
  Coverage   34.59%   34.59%           
=======================================
  Files        1017     1017           
  Lines       27150    27150           
  Branches     2211     2211           
=======================================
  Hits         9393     9393           
  Misses      17268    17268           
  Partials      489      489           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vinistevam vinistevam added the team-confirmations-system DEPRECATED: please use "team-confirmations" label instead label Sep 29, 2023
@vinistevam vinistevam marked this pull request as ready for review October 2, 2023 07:54
@vinistevam vinistevam requested a review from a team as a code owner October 2, 2023 07:54
seaona
seaona previously approved these changes Oct 2, 2023
Copy link
Contributor

@seaona seaona left a comment

Choose a reason for hiding this comment

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

LGTM! A couple of comments:

shim.js Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Oct 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@vinistevam vinistevam merged commit ed3f0e5 into main Oct 3, 2023
24 checks passed
@vinistevam vinistevam deleted the test-reorg-dynamic-ports branch October 3, 2023 18:13
@github-actions github-actions bot locked and limited conversation to collaborators Oct 3, 2023
@vinistevam vinistevam added the No QA Needed/E2E Only Apply this label when your PR does not need any QA effort. label Oct 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
No QA Needed/E2E Only Apply this label when your PR does not need any QA effort. release-7.10.0 team-confirmations-system DEPRECATED: please use "team-confirmations" label instead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants