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

Integration Tests: fix flaky test failure due to leftover transaction #3167

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

NachoSoto
Copy link
Contributor

Fixes https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/14917/workflows/4f22199c-2229-45da-8758-9587559d02be/jobs/119481/tests

This test was failing with this error:

failed - Message 'Finishing transaction' should not have been logged

I looked through the logs, and noticed that transaction had been finished prior to the test even starting (before .serverDown() was called), likely due to a leftover transaction from an earlier test (this can still happen with SKTestSession despite our best efforts. Supposedly fully fixed in iOS 17).

This removes that possibility by clearing the log history at the beginning of the test.

Fixes https://app.circleci.com/pipelines/github/RevenueCat/purchases-ios/14917/workflows/4f22199c-2229-45da-8758-9587559d02be/jobs/119481/tests

This test was failing with this error:
> failed - Message 'Finishing transaction' should not have been logged

I looked through the logs, and noticed that transaction had been finished prior to the test even starting (before `.serverDown()` was called), likely due to a leftover transaction from an earlier test (this can still happen with `SKTestSession` despite our best efforts. Supposedly fully fixed in iOS 17).

This removes that possibility by clearing the log history at the beginning of the test.
@NachoSoto NachoSoto added the test label Sep 7, 2023
@NachoSoto NachoSoto requested a review from a team September 7, 2023 22:36
@codecov
Copy link

codecov bot commented Sep 8, 2023

Codecov Report

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

Comparison is base (341f0d3) 86.64% compared to head (7c2caad) 86.62%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3167      +/-   ##
==========================================
- Coverage   86.64%   86.62%   -0.02%     
==========================================
  Files         220      220              
  Lines       15742    15742              
==========================================
- Hits        13639    13637       -2     
- Misses       2103     2105       +2     

see 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.

📢 Have feedback on the report? Share it here.

@NachoSoto NachoSoto merged commit 9a44001 into main Sep 8, 2023
17 checks passed
@NachoSoto NachoSoto deleted the integration-test-flaky-test-100 branch September 8, 2023 14:27
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)
NachoSoto added a commit that referenced this pull request Sep 14, 2023
Same as #3167. These can fail when verifying that no transactions are finished because there might be leftover transactions before the test even begins.
In order to ignore those, we clear `TestLogHandler` at the beginning. We don't do that for every test because in some test we want to look at what was logged during SDK initialization.
NachoSoto added a commit that referenced this pull request Sep 15, 2023
Same as #3167. These can fail when verifying that no transactions are
finished because there might be leftover transactions before the test
even begins. In order to ignore those, we clear `TestLogHandler` at the
beginning. We don't do that for every test because in some test we want
to look at what was logged during SDK initialization.
NachoSoto added a commit that referenced this pull request Sep 15, 2023
Same as #3167. These can fail when verifying that no transactions are
finished because there might be leftover transactions before the test
even begins. In order to ignore those, we clear `TestLogHandler` at the
beginning. We don't do that for every test because in some test we want
to look at what was logged during SDK initialization.
NachoSoto added a commit that referenced this pull request Sep 15, 2023
Same as #3167. These can fail when verifying that no transactions are
finished because there might be leftover transactions before the test
even begins. In order to ignore those, we clear `TestLogHandler` at the
beginning. We don't do that for every test because in some test we want
to look at what was logged during SDK initialization.
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