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

Instrumentation test coroutines #7207

Merged
merged 56 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
bb381ca
adding test helpers when using coroutines with live data
ouchadam Sep 16, 2022
b4dde44
replacing latched live data waiting with coroutines
ouchadam Sep 16, 2022
4552f43
adding suspending test account creation
ouchadam Sep 16, 2022
6b9e5a2
removing unused helpers
ouchadam Sep 20, 2022
743667b
converting test helper to use coroutine based waits
ouchadam Sep 20, 2022
79fd5bf
adding suspending message sending and top level suspending runTest he…
ouchadam Sep 20, 2022
f90667a
creating wrapper function for testing coroutine timeouts
ouchadam Sep 20, 2022
e3fb362
using suspending periodic retries for the E2E share history tests
ouchadam Sep 20, 2022
e59cadc
replacing direct usages of withTimeout with the deferred result readi…
ouchadam Sep 20, 2022
7f0955b
allowing the live data suspending wrapper to clean up on cancellation
ouchadam Sep 20, 2022
6ebda6b
replacing send message test periodic retries with suspending versions
ouchadam Sep 20, 2022
71d18bb
forcing periodic retries to block the test thread
ouchadam Sep 20, 2022
24a7ea9
using suspending message sending and removing duplicated retry rule
ouchadam Sep 20, 2022
4004263
using default context when running tests to allow delays to execute
ouchadam Sep 20, 2022
e39faa8
replacing latches with suspending versions
ouchadam Sep 20, 2022
ad5ec06
adding suspending account login helpers
ouchadam Sep 20, 2022
2470796
replace latches with suspending funcs
ouchadam Sep 20, 2022
c42d6f1
converting auto verification test to coroutine suspends
ouchadam Sep 20, 2022
62338ed
removing unused non suspending wait for invite
ouchadam Sep 20, 2022
942e3bd
increasing the default runTest timeout
ouchadam Sep 20, 2022
46434c8
replacing latches with suspending versions
ouchadam Sep 20, 2022
26db94d
updating encryption test to use suspending functions
ouchadam Sep 21, 2022
1f6dbbd
using suspending versions of doSync
ouchadam Sep 21, 2022
8e226bc
updating preshare tests to use suspending methods
ouchadam Sep 21, 2022
1006e9e
updating search message tests to use suspending functions
ouchadam Sep 21, 2022
969e98d
marking doE2ETestWithAliceInARoom as suspending
ouchadam Sep 21, 2022
800746b
replacing some keysbackup latch usages
ouchadam Sep 21, 2022
fff364f
replacing withheld test latch usages with suspends
ouchadam Sep 21, 2022
85eb46f
replacing create dm latch with suspends
ouchadam Sep 21, 2022
cff63e6
making ensureCan/CannotDecrypt test functions suspending
ouchadam Sep 21, 2022
080e5bb
replacing latches with suspending version
ouchadam Sep 21, 2022
fec4bf1
making the test session clean up suspending
ouchadam Sep 21, 2022
fa97699
making test login and create account usages suspending
ouchadam Sep 21, 2022
801afdd
using shouldbeequalto as we're checking values rather than instances
ouchadam Sep 22, 2022
e3a9e4e
removing test sleeps, the test is passing without
ouchadam Sep 22, 2022
f4da2d8
converting unwedging test to use coroutines/suspends instead of latches
ouchadam Sep 22, 2022
0b844ea
converting space creation tests to suspends
ouchadam Sep 22, 2022
aff82a6
converting space hierarchy tests to suspends
ouchadam Sep 22, 2022
75becaf
making all test createAccount usages suspending
ouchadam Sep 22, 2022
9d3fdda
making all runCryptoTest suspending
ouchadam Sep 22, 2022
20f7fc0
renaming all suspending test runners back to their original names now…
ouchadam Sep 22, 2022
087be63
using suspending text message sending for all instrumentation tests
ouchadam Sep 22, 2022
a9361c7
making all test doSync calls suspending instead of latch
ouchadam Sep 22, 2022
ae51bfe
removing no longer needed test runBlocking or launch
ouchadam Sep 22, 2022
5ed9e75
replacing remaining period wait with latch with suspending version
ouchadam Sep 22, 2022
707f3bf
replacing remaining latched wait usages with suspends
ouchadam Sep 22, 2022
53e8e25
removing no longer need runBlocking
ouchadam Sep 22, 2022
2c338bd
renaming function for better context
ouchadam Sep 22, 2022
99d01b2
removing unused scope
ouchadam Sep 22, 2022
e09f9bc
disabling test retries to help identify flaky tests
ouchadam Sep 22, 2022
2c446ce
including waiting for the room topic to be updated
ouchadam Sep 22, 2022
ff012bd
replacing latches in keysbackup tests
ouchadam Sep 22, 2022
aef44a3
ensuring the verification listener is removed before resuming
ouchadam Sep 22, 2022
bf153e2
removing unused imports and re-enabling retry test rule
ouchadam Sep 22, 2022
3e46263
using correct license for matrix sdk class
ouchadam Sep 22, 2022
c595475
adding changelog entry
ouchadam Sep 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/7207.sdk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ports SDK instrumentation tests to use suspending functions instead of countdown latches
2 changes: 2 additions & 0 deletions matrix-sdk-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ dependencies {
androidTestImplementation libs.mockk.mockkAndroid
androidTestImplementation libs.androidx.coreTesting
androidTestImplementation libs.jetbrains.coroutinesAndroid
androidTestImplementation libs.jetbrains.coroutinesTest

// Plant Timber tree for test
androidTestImplementation libs.tests.timberJunitRule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ class ChangePasswordTest : InstrumentedTest {
val session = commonTestHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(withInitialSync = false))

// Change password
commonTestHelper.runBlockingTest {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the runCryptoTest & runSessionTest are now suspending which means runBlockingTest is the equivalent of running in the original scope

session.accountService().changePassword(TestConstants.PASSWORD, NEW_PASSWORD)
}
session.accountService().changePassword(TestConstants.PASSWORD, NEW_PASSWORD)

// Try to login with the previous password, it will fail
val throwable = commonTestHelper.logAccountWithError(session.myUserId, TestConstants.PASSWORD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,20 @@ class DeactivateAccountTest : InstrumentedTest {
val session = commonTestHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(withInitialSync = true))

// Deactivate the account
commonTestHelper.runBlockingTest {
session.accountService().deactivateAccount(
eraseAllData = false,
userInteractiveAuthInterceptor = object : UserInteractiveAuthInterceptor {
override fun performStage(flowResponse: RegistrationFlowResponse, errCode: String?, promise: Continuation<UIABaseAuth>) {
promise.resume(
UserPasswordAuth(
user = session.myUserId,
password = TestConstants.PASSWORD,
session = flowResponse.session
)
)
}
session.accountService().deactivateAccount(
eraseAllData = false,
userInteractiveAuthInterceptor = object : UserInteractiveAuthInterceptor {
override fun performStage(flowResponse: RegistrationFlowResponse, errCode: String?, promise: Continuation<UIABaseAuth>) {
promise.resume(
UserPasswordAuth(
user = session.myUserId,
password = TestConstants.PASSWORD,
session = flowResponse.session
)
)
}
)
}
}
)

// Try to login on the previous account, it will fail (M_USER_DEACTIVATED)
val throwable = commonTestHelper.logAccountWithError(session.myUserId, TestConstants.PASSWORD)
Expand All @@ -74,23 +72,19 @@ class DeactivateAccountTest : InstrumentedTest {
// Try to create an account with the deactivate account user id, it will fail (M_USER_IN_USE)
val hs = commonTestHelper.createHomeServerConfig()

commonTestHelper.runBlockingTest {
commonTestHelper.matrix.authenticationService.getLoginFlow(hs)
}
commonTestHelper.matrix.authenticationService.getLoginFlow(hs)

var accountCreationError: Throwable? = null
commonTestHelper.runBlockingTest {
try {
commonTestHelper.matrix.authenticationService
.getRegistrationWizard()
.createAccount(
session.myUserId.substringAfter("@").substringBefore(":"),
TestConstants.PASSWORD,
null
)
} catch (failure: Throwable) {
accountCreationError = failure
}
try {
commonTestHelper.matrix.authenticationService
.getRegistrationWizard()
.createAccount(
session.myUserId.substringAfter("@").substringBefore(":"),
TestConstants.PASSWORD,
null
)
} catch (failure: Throwable) {
accountCreationError = failure
}

// Test the error
Expand Down
Loading