Skip to content

Conversation

@jaclync
Copy link
Contributor

@jaclync jaclync commented Oct 9, 2025

For WOOMOB-1441
Just one review is required.

Description

Fixes flaky test failures and slow test execution in POS catalog sync tests caused by concurrent access to shared state and retry delay logic. I was able to reproduce the flakiness and crash locally by running the test suite repeatedly.

Issues Fixed

  1. Flaky test crashes from concurrent counter updates: Tests were randomly failing or crashing when running in parallel due to concurrent updates to integer counters in local variables and MockPOSCatalogSyncRemote
  2. Slow test execution (14s delay): The startFullSync_propagates_network_errors and startIncrementalSync_throws_error_when_product_loading_fails tests were taking 14 seconds to complete due to exponential backoff retry delays
Screenshot 2025-10-09 at 10 18 53 AM

Changes

  • Introduced thread-safe Counter actor for tracking call counts in test mocks and assertions
  • Updated MockPOSCatalogSyncRemote to use Counter instead of plain integers for all call count properties
  • Updated BatchedRequestLoaderTests to use Counter for thread-safe attempt tracking
  • Added retryDelay parameter to sync service initializers to allow configuring retry delays (defaults to 2.0s for production)
  • Modified error propagation tests to use retryDelay: 0 to eliminate unnecessary delays in test execution

Steps to reproduce

Run the following test suites repeatedly locally to verify that each test suite completes almost right away without crashing:

  • BatchedRequestLoaderTests
  • POSCatalogFullSyncServiceTests
  • POSCatalogIncrementalSyncServiceTests

Testing information

I tested the above in Xcode 26 with iPad A16 iOS 18.4 simulator.


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@jaclync jaclync changed the title Fix flaky and slow POS catalog sync tests [Local Catalog] Fix flaky and slow POS catalog sync tests Oct 9, 2025
@jaclync jaclync added the category: unit tests Related to unit testing. label Oct 9, 2025
@jaclync jaclync added this to the 23.5 milestone Oct 9, 2025
@wpmobilebot
Copy link
Collaborator

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16227-ef47178
Version23.4
Bundle IDcom.automattic.alpha.woocommerce
Commitef47178
Installation URL7l8pub1j0vojg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

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

👍 Appreciate the optimization. Looks good to me, good use of the actor in the counter.

@jaclync jaclync merged commit 98d4ad1 into trunk Oct 13, 2025
22 of 23 checks passed
@jaclync jaclync deleted the feat/WOOMOB-1441-fix-flaky-concurrency-tests branch October 13, 2025 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: unit tests Related to unit testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants