-
Notifications
You must be signed in to change notification settings - Fork 121
Address flaky Alamofire network test on Alamofire.AFError.sessionDeinitialized error from concurrent requests
#16137
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
Address flaky Alamofire network test on Alamofire.AFError.sessionDeinitialized error from concurrent requests
#16137
Conversation
… condition `Alamofire.AFError.sessionDeinitialized` and network error could be thrown at the same time.
…l_with_sessionDeinitialized_error_when_ensuresSessionManagerIsInitialized_is_true`.
Alamofire.AFError.sessionDeinitialized error from concurrent requests
Alamofire.AFError.sessionDeinitialized error from concurrent requestsAlamofire.AFError.sessionDeinitialized error from concurrent requests
|
|
|
Version |
…mofireNetworkTests # Conflicts: # Modules/Tests/NetworkingTests/Network/AlamofireNetworkTests.swift
|
Regarding this part:
This line is no longer in trunk after the changes from last week. Do you think it's worth trying your approach again to update the |
Nice, thanks for sharing the update. I replaced the lazy var |
itsmeichigo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update! The tests pass locally for me too. I also did some regression tests and confirmed that network switching still works correctly after the change to alamofireSession. ![]()
|
Thanks for the review & additional testing @itsmeichigo, I also tested again for concurrent requests in POS catalog sync for stores with big & small catalog size. Merging it now. |

For WOOMOB-1326
Just one review is required.
Description
This PR addresses a flaky test in the Alamofire networking layer that were causing intermittent test failures due to race conditions. It also updates a similar test case to not make an external network request. The changes address two main issues:
AlamofireNetworkTests.test_concurrent_requests_fail_with_sessionDeinitialized_error_when_ensuresSessionManagerIsInitialized_is_falsewas removed because it relied on a race condition betweenAlamofire.AFError.sessionDeinitializedand network errors that could be thrown simultaneously, making the test unreliable.Alamofire.Sessionis unpredictable andAlamofire.AFError.sessionDeinitializedisn't consistently thrown right away.alamofireSession: Alamofire.Sessionfrom a lazy var to alet, but it results in a crash when runningtest_authenticationMode_changes_to_appPasswordsWithJetpack_when_app_password_switching_enabledon this line that updates the fixedRequestProcessor:But I ran out of time to look further, and didn't have enough context of the recent authentication changes from Kiwi to determine the cause. It felt a bit concerning that the test case is relying on the session being a lazy variable, even though that test case actually DI'ed a mock session. It might just be the test setup, though.
AlamofireNetworkTests.test_concurrent_requests_do_not_fail_with_sessionDeinitialized_error_when_ensuresSessionManagerIsInitialized_is_truenow uses a direct URLRequest to localhost with a very short timeout instead of a JetpackRequest, making it more predictable and eliminating the race condition.Steps to reproduce
CI passing is sufficient, but feel free to run
AlamofireNetworkTestsrepeatedly locally.Testing information
I ran
AlamofireNetworkTestsrepeatedly (100 times) multiple times locally and esnured that they passed. I was able to reproduce the flakiness by runningAlamofireNetworkTestsrepeatedly (100 times) once before the PR changes.RELEASE-NOTES.txtif necessary.