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

[PM-17710] Fix NotificationCenterServiceTests race condition failure #1313

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

fedemkr
Copy link
Member

@fedemkr fedemkr commented Jan 30, 2025

🎟️ Tracking

PM-17710

📔 Objective

Fix NotificationCenterServiceTests race condition failure that caused tests to execute until timeout or fail randomly with the new maximum-test-execution-time-allowance setting.

This was caused when notificationCenter.post(...) was executed before the iterator.next() started. Therefore the notification value was missed from the publisher and the test never ended.

In order to fix this without adding an explicit Task.sleep(...) I've moved the for await in publisher to the setup where a flag is set when the value is received and then I call the notificationCenter.post(...) inside the try await waitForAsync { ... } so if the first time the post is missed then it will loop again in it waitForAsync and post again until the publisher is ready, receives the notification value and updates the flag.

I've run each test 100 times locally and with the fix all passed whereas before in around 30-40 times runs it was failing.
Plus all runs of each test are under 0,5 seconds so we're inside the maximum-test-execution-time-allowance of 1 second.
So hopefully we won't encounter these tests failing in CI anymore.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Contributor

Logo
Checkmarx One – Scan Summary & Detailsda7d3208-2b52-46e8-beb4-59a03efe1586

Great job, no security vulnerabilities found in this Pull Request

Copy link
Contributor

@KatherineInCode KatherineInCode left a comment

Choose a reason for hiding this comment

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

👍🏻 Good catch, and I like this solution!

@fedemkr fedemkr enabled auto-merge (squash) January 30, 2025 16:19
@fedemkr fedemkr merged commit 9f6b685 into main Jan 30, 2025
7 checks passed
@fedemkr fedemkr deleted the PM-17710/fix-notification-center-test-hanging branch January 30, 2025 16:26
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.43%. Comparing base (c746146) to head (ad29f30).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1313      +/-   ##
==========================================
- Coverage   89.44%   89.43%   -0.01%     
==========================================
  Files         743      745       +2     
  Lines       46590    46621      +31     
==========================================
+ Hits        41671    41695      +24     
- Misses       4919     4926       +7     

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

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