-
Notifications
You must be signed in to change notification settings - Fork 754
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
Conversation
for reviewers, enabling |
955ac8d
to
ad8786d
Compare
@@ -34,6 +35,7 @@ import java.util.UUID | |||
|
|||
@RunWith(AndroidJUnit4::class) | |||
@LargeTest | |||
@Ignore // Temporary ignore whilst confirming other tests |
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.
I'm currently investigating re-enabling this and the VoiceRecorderLTests
tests
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.
ad8786d
to
1db0ef4
Compare
9c42b87
to
97b3b23
Compare
1db0ef4
to
3f83afb
Compare
- replaces some more runBlocking/periodic lateches
… there's only 1 variant
- fixes double trigger on the resume which error
3f83afb
to
c595475
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@@ -43,9 +43,7 @@ class ChangePasswordTest : InstrumentedTest { | |||
val session = commonTestHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(withInitialSync = false)) | |||
|
|||
// Change password | |||
commonTestHelper.runBlockingTest { |
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.
the runCryptoTest
& runSessionTest
are now suspending which means runBlockingTest
is the equivalent of running in the original scope
testHelper.cleanUpOpenedSessions() | ||
return runTest(dispatchTimeoutMs = TestConstants.timeOutMillis) { | ||
try { | ||
withContext(Dispatchers.Default) { |
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.
we use the Default
context to allow Timeouts
to work correctly, the original runTest
dispatcher uses a test scheduler which requires the scheduler timings to be manually incremented, otherwise timing based suspensions like delay/timeout complete instantly (which we don't want!)
* limitations under the License. | ||
*/ | ||
|
||
package org.matrix.android.sdk.common |
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.
reusable test functions, more functions could lifted from the testHelper
now that the helpers are mostly stateless~
@@ -173,25 +141,18 @@ class UnwedgingTest : InstrumentedTest { | |||
bobSession.cryptoService().getMyDevice().identityKey()!! | |||
) | |||
olmDevice.clearOlmSessionCache() | |||
Thread.sleep(6_000) |
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.
we should avoid any thread sleeps and instead rely on dynamic updates from retryPeriodic
, waitFor
, suspendCancellableCoroutine
|
||
messagesReceivedByBob.size shouldBe 1 | ||
messagesReceivedByBob.size shouldBeEqualTo 1 |
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.
shouldBe
uses reference equality ===
whereas shouldBeEqualTo
uses value equality ==
@@ -135,7 +126,7 @@ class E2EShareKeysConfigTest : InstrumentedTest { | |||
} | |||
|
|||
@Test | |||
fun ifSharingDisabledOnAliceSideBobShouldNotShareAliceHistoty() = runCryptoTest(context()) { cryptoTestHelper, commonTestHelper -> | |||
fun ifSharingDisabledOnAliceSideBobShouldNotShareAliceHistory() = runCryptoTest(context()) { cryptoTestHelper, commonTestHelper -> |
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.
🙃
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.
thought I'd fix it whilst I was in the area 😄
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.
Awesome work, LGTM. Some documentation above fun in https://github.com/vector-im/element-android/blob/3e46263bef7d480b441477ecf98589d79610e873/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/TestExtensions.kt could help, but I can add it later, to not block this PR from being merged.
@bmarty agreed! we could also lift some of the |
Type of change
Content
CountdownLatch
usagesMotivation and context
To help improve test stability and time taken to execute
Before: 23m 43s
After: 6m 34s
72% reduction in runtime, saving around 17 minutes~
Screenshots / GIFs
|
Tests
Run the
./gradlew matrix-sdk-android:connectedAndroidTest
, or all thematrix-sdk-android androidTest
tests from within Android StudioTested devices