Skip to content

Integration Tests: another flaky failure#3165

Merged
NachoSoto merged 2 commits into
mainfrom
integration-test-unfinished-transactions
Sep 8, 2023
Merged

Integration Tests: another flaky failure#3165
NachoSoto merged 2 commits into
mainfrom
integration-test-unfinished-transactions

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

See https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/14903/workflows/a607f078-553a-44c0-8873-16abc12d3e3a/jobs/119243

This test (testCallToGetCustomerInfoWithPendingTransactionsPostsReceiptOnlyOnce) has a race condition. It currently does:

  • purchaseMonthlyProduct
  • forceRenewalOfSubscription

However, with a slow CPU, it's possible that StoreKit will renew automatically, leading to more unfinished transactions.

This modifies the test to be a bit more lenient, while still complying with the spirit of the test: testCallToGetCustomerInfoWithPendingTransactionsPostsReceiptOnlyOnce.

See https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/14903/workflows/a607f078-553a-44c0-8873-16abc12d3e3a/jobs/119243

This test (`testCallToGetCustomerInfoWithPendingTransactionsPostsReceiptOnlyOnce`) has a race condition. It currently does:
- `purchaseMonthlyProduct`
- `forceRenewalOfSubscription`

However, with a slow CPU, it's possible that StoreKit will renew automatically, leading to more unfinished transactions.

This modifies the test to be a bit more lenient, while still complying with the spirit of the test: `testCallToGetCustomerInfoWithPendingTransactionsPostsReceiptOnlyOnce`.
@NachoSoto NachoSoto added the test label Sep 7, 2023
@NachoSoto NachoSoto requested a review from a team September 7, 2023 20:11
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.2, *)
func asyncWait(
description: String? = nil,
func asyncWait<T>(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added this new overload that allows printing the last value in the description.
This allows us to see exactly what the failure was, instead of just:

failed - Expected 2 unfinished transactions
expected to be true, got <false>

"Expected true, got false" wasn't very helpful.

line: line,
foundCorrectValue
).to(beTrue(), description: description)
).to(beTrue(), description: description(lastValue))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now the description can be derived from the last value.

)

try await self.waitUntilUnfinishedTransactions(2)
try await self.waitUntilUnfinishedTransactions { $0 >= 2 }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the core of the change, from == 2 to >= 2.

@codecov

codecov Bot commented Sep 7, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage has no change and project coverage change: -0.07% ⚠️

Comparison is base (341f0d3) 86.64% compared to head (af04838) 86.57%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3165      +/-   ##
==========================================
- Coverage   86.64%   86.57%   -0.07%     
==========================================
  Files         220      220              
  Lines       15742    15742              
==========================================
- Hits        13639    13628      -11     
- Misses       2103     2114      +11     

see 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.

📢 Have feedback on the report? Share it here.

@NachoSoto NachoSoto merged commit 5972790 into main Sep 8, 2023
@NachoSoto NachoSoto deleted the integration-test-unfinished-transactions branch September 8, 2023 14:28
NachoSoto pushed a commit that referenced this pull request Sep 14, 2023
**This is an automatic release.**

### Bugfixes
* Fix runtime crash in SK2TransactionListener in iOS < 15 (#3206) via
Toni Rico (@tonidero)
### Performance Improvements
* `OperationDispatcher`: add support for "long" delays (#3168) via
NachoSoto (@NachoSoto)
### Other Changes
* `Integration Tests`: add tests for ghost transfer behavior (#3135) via
NachoSoto (@NachoSoto)
* `Xcode`: removed `purchases-ios` SPM reference (#3166) via NachoSoto
(@NachoSoto)
* `Integration Tests`: another flaky failure (#3165) via NachoSoto
(@NachoSoto)
* `Integration Tests`: fix flaky test failure due to leftover
transaction (#3167) via NachoSoto (@NachoSoto)
* `Xcode 13`: removed last `Swift 5.7` checks (#3161) via NachoSoto
(@NachoSoto)
* `Integration Tests`: improve flaky tests (#3163) via NachoSoto
(@NachoSoto)
* `Codable`: improved decoding errors (#3153) via NachoSoto (@NachoSoto)
* Refactor: extract `HealthOperation` (#3154) via NachoSoto (@NachoSoto)
* `Xcode 13`: remove conditional code (#3147) via NachoSoto (@NachoSoto)
* `CircleCI`: change all jobs to use `Xcode 14.x` and replace
`xcode-install` with `xcodes` (#2421) via NachoSoto (@NachoSoto)
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