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

fix: flaky test Vault Decryptor Page is able to decrypt the vault us.. due to empty file load #26612

Merged
merged 8 commits into from
Aug 26, 2024

Conversation

seaona
Copy link
Contributor

@seaona seaona commented Aug 22, 2024

Description

The vault decrypt test is flaky, at the point where we upload the vault file into the browser.
I added logs for checking the file size, and I saw that when the file failed to upload, the file size was really small.

The problem seemed to start appearing after this PR was merged. The changes doesn't seem related, but it updated a lot of dependencies, some of them related to cryptography/addres derivation packages (see screenshot below) - which could somehow affect somehow the timings.

Fix:

  • Added a function to get the file size
  • Added a retry logic to check the file size before uploading it, making sure it's bigger than a conservatory size

See logic in action:

image

Notes and future work:

  • there isn't an easy way to determine when Chrome has finished writing into the file, since this can depend on numerous factors ( Data Changes, Internal Buffering, Extension Activity, Browser Events..)
  • currently we are testing the log file, instead of the ldb file, as described in the Vault Decryptor instructions. I haven't find the ldb file, after waiting ~30seconds and closing/repoening the browser, however, that file might also exibit flakiness as Chrome would also need to write to it. For this reason, in this PR the test is kept as it was, and it only focuses on fixing the spec with the retry logic.
  • there is another test proposed by @davidmurdoch , for reading the vault value from the file and then using the function "Paste into the field" for testing that. I've decided to do this on a separate PR and keep this PR focused on the current issue only, to unblock ci faster

Open in GitHub Codespaces

Related issues

Fixes: #26572

Manual testing steps

  1. Check ci https://app.circleci.com/jobs/github/MetaMask/metamask-extension/3612121

Screenshots/Recordings

When the error appears, we can see how the file size is really small 19 bytes.

Screenshot from 2024-08-22 15-44-24

whereas when the test is successful, the file size is bigger 7358117 bytes.

Screenshot from 2024-08-22 16-02-18

See changes mentioned, after flakiness started appearing:

Screenshot from 2024-08-22 16-30-16

Pre-merge author checklist

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.

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.

Copy link

codecov bot commented Aug 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.09%. Comparing base (b3865bc) to head (7f9762f).
Report is 15 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #26612      +/-   ##
===========================================
+ Coverage    70.04%   70.09%   +0.05%     
===========================================
  Files         1411     1413       +2     
  Lines        49205    49254      +49     
  Branches     13754    13768      +14     
===========================================
+ Hits         34463    34524      +61     
+ Misses       14742    14730      -12     

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

@metamaskbot
Copy link
Collaborator

Builds ready [7548864]
Page Load Metrics (77 ± 11 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint601761053014
domContentLoaded40140732311
load46140772311
domInteractive97632199
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@seaona seaona self-assigned this Aug 22, 2024
@seaona seaona changed the title fix: draft fix: flaky test Vault Decryptor Page is able to decrypt the vault us.. due to empty file load Aug 22, 2024
@seaona seaona marked this pull request as ready for review August 22, 2024 14:24
@seaona seaona requested a review from a team as a code owner August 22, 2024 14:24
@seaona seaona added the area-qa Relating to QA work (Quality Assurance) label Aug 22, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [aeba870]
Page Load Metrics (82 ± 9 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint601571112512
domContentLoaded47117792010
load4811782199
domInteractive106632147
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@seaona seaona requested review from kumavis and a team as code owners August 22, 2024 17:50
Copy link

socket-security bot commented Aug 22, 2024

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

yarn.lock Outdated Show resolved Hide resolved
@seaona seaona requested a review from legobeat August 23, 2024 05:59
});

// Retry-logic if file upload fails
if (!fileLoaded) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, I have a question about the logic. The value of the fileLoaded variable will be true if the element "Can not read vault from file" appears. Is this intended? It seems like it should be reversed. But maybe I misunderstood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hey @chloeYue that's an awesome catch 😍 I've pushed a fix for that.
I'm now trying to see if there could be an alternative way of fixing this on the root cause - based on [this comment] from David (https://consensys.slack.com/archives/CTQAGKY5V/p1724395549815109?thread_ts=1724321902.861359&cid=CTQAGKY5V) If so, I'll update the PR one more time, if not, then we can leave this as a mitigation. I'll share my updates soon 🙏

test/e2e/vault-decryption-chrome.spec.js Outdated Show resolved Hide resolved
test/e2e/vault-decryption-chrome.spec.js Outdated Show resolved Hide resolved
Copy link

@metamaskbot
Copy link
Collaborator

Builds ready [5621c96]
Page Load Metrics (81 ± 8 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint74142106199
domContentLoaded5011876178
load5711881178
domInteractive116529136
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link

@metamaskbot
Copy link
Collaborator

Builds ready [7f9762f]
Page Load Metrics (74 ± 9 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint68151962010
domContentLoaded48117672110
load4811774199
domInteractive96324136
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@chloeYue chloeYue left a comment

Choose a reason for hiding this comment

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

LGTM !

@seaona seaona merged commit 80b28d6 into develop Aug 26, 2024
84 checks passed
@seaona seaona deleted the test-vault-file branch August 26, 2024 15:35
@github-actions github-actions bot locked and limited conversation to collaborators Aug 26, 2024
@metamaskbot metamaskbot added the release-12.5.0 Issue or pull request that will be included in release 12.5.0 label Aug 26, 2024
@gauthierpetetin gauthierpetetin added release-12.4.0 Issue or pull request that will be included in release 12.4.0 and removed release-12.5.0 Issue or pull request that will be included in release 12.5.0 labels Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-qa Relating to QA work (Quality Assurance) flaky tests release-12.4.0 Issue or pull request that will be included in release 12.4.0 team-extension-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Fix "Vault Decryptor Page is able to decrypt the vault us..." flaky tests
6 participants