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

Flaky test: CardBrowserViewModelTest - suspend - notes - some notes suspended #16541

Closed
david-allison opened this issue Jun 3, 2024 · 4 comments · Fixed by #16553
Closed

Comments

@david-allison
Copy link
Member

david-allison commented Jun 3, 2024

macOS runner: https://github.com/ankidroid/Anki-Android/actions/runs/9357727049/job/25758121561?pr=16244

CardBrowserViewModelTest > suspend - notes - some notes suspended FAILED
    java.lang.AssertionError: ChangeManager: expected 1 calls
    Expected: <1>
         but: was <0>
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at com.ichi2.testutils.TestChangeSubscriberKt.ensureOpsExecuted(TestChangeSubscriber.kt:50)
        at com.ichi2.anki.browser.CardBrowserViewModelTest$suspend - notes - some notes suspended$1.invokeSuspend(CardBrowserViewModelTest.kt:441)
        at com.ichi2.anki.browser.CardBrowserViewModelTest$suspend - notes - some notes suspended$1.invoke(CardBrowserViewModelTest.kt)
        at com.ichi2.anki.browser.CardBrowserViewModelTest$suspend - notes - some notes suspended$1.invoke(CardBrowserViewModelTest.kt)
        at com.ichi2.anki.browser.CardBrowserViewModelTest$runViewModelNotesTest$1.invokeSuspend(CardBrowserViewModelTest.kt:489)
        at com.ichi2.anki.browser.CardBrowserViewModelTest$runViewModelNotesTest$1.invoke(CardBrowserViewModelTest.kt)
        at com.ichi2.anki.browser.CardBrowserViewModelTest$runViewModelNotesTest$1.invoke(CardBrowserViewModelTest.kt)
        at com.ichi2.testutils.TestClass$runTest$1$1.invokeSuspend(TestClass.kt:240)
        at com.ichi2.testutils.TestClass$runTest$1$1.invoke(TestClass.kt)
        at com.ichi2.testutils.TestClass$runTest$1$1.invoke(TestClass.kt)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$1.invokeSuspend(TestBuilders.kt:316)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
        at kotlinx.coroutines.test.TestDispatcher.processEvent$kotlinx_coroutines_test(TestDispatcher.kt:24)
        at kotlinx.coroutines.test.TestCoroutineScheduler.tryRunNextTaskUnless$kotlinx_coroutines_test(TestCoroutineScheduler.kt:99)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt$runTest$2$1$workRunner$1.invokeSuspend(TestBuilders.kt:322)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:277)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:48)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at kotlinx.coroutines.test.TestBuildersJvmKt.createTestResult(TestBuildersJvm.kt:10)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt.runTest-8Mi8wO0(TestBuilders.kt:310)
        at kotlinx.coroutines.test.TestBuildersKt.runTest-8Mi8wO0(Unknown Source)
        at kotlinx.coroutines.test.TestBuildersKt__TestBuildersKt.runTest-8Mi8wO0(TestBuilders.kt:168)
        at kotlinx.coroutines.test.TestBuildersKt.runTest-8Mi8wO0(Unknown Source)
        at com.ichi2.testutils.TestClass.runTest(TestClass.kt:238)
        at com.ichi2.testutils.TestClass.runTest$default(TestClass.kt:227)
        at com.ichi2.anki.browser.CardBrowserViewModelTest.runViewModelNotesTest(CardBrowserViewModelTest.kt:472)
        at com.ichi2.anki.browser.CardBrowserViewModelTest.runViewModelNotesTest$default(CardBrowserViewModelTest.kt:467)
        at com.ichi2.anki.browser.CardBrowserViewModelTest.suspend - notes - some notes suspended(CardBrowserViewModelTest.kt:438)
@david-allison
Copy link
Member Author

-- executing test "suspend - notes - some notes suspended"
D/Backend: Opening rust backend with lang=[en-US]
Backend: Opening rust backend with lang=[en-US]
Media: dir /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T/robolectric-CardBrowserViewModelTest_suspend_-_notes_-_some_notes_suspended13282912277527198913/external-files/Android/data/com.ichi2.anki.debug/AnkiDroid/collection.media
I/Collection: (Re)opening Database: /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T/robolectric-CardBrowserViewModelTest_suspend_-_notes_-_some_notes_suspended13282912277527198913/external-files/Android/data/com.ichi2.anki.debug/AnkiDroid/collection.anki2
Collection: (Re)opening Database: /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T/robolectric-CardBrowserViewModelTest_suspend_-_notes_-_some_notes_suspended13282912277527198913/external-files/Android/data/com.ichi2.anki.debug/AnkiDroid/collection.anki2
D/CardBrowserViewModel: CardBrowserViewModel::init
CardBrowserViewModel: CardBrowserViewModel::init
I/CardBrowserViewModel: setting deck: 1
CardBrowserViewModel: setting deck: 1
I/CardBrowserViewModel: initCompleted
CardBrowserViewModel: initCompleted
D/CardBrowserViewModel$launchSearchForCards: performing search: 'deck:"Default" '
CardBrowserViewModel$launchSearchForCards: performing search: 'deck:"Default" '
D/CardBrowserViewModel$launchSearchForCards: Search returned 2 card(s)
CardBrowserViewModel$launchSearchForCards: Search returned 2 card(s)
I/Collection: Collection closed
Collection: Collection closed
D/Backend: Closing rust backend
Backend: Closing rust backend

@david-allison
Copy link
Member Author

more logs (Windows)

https://github.com/ankidroid/Anki-Android/actions/runs/9372967072/job/25805626489

-- executing test "suspend - cards - some suspended"
D/Backend: Opening rust backend with lang=[en-US]
Backend: Opening rust backend with lang=[en-US]
Media: dir C:\Users\RUNNER~1\AppData\Local\Temp\robolectric-CardBrowserViewModelTest_suspend_-_cards_-_some_suspended1688466108410830537\external-files\Android\data\com.ichi2.anki.debug\AnkiDroid\collection.media
I/Collection: (Re)opening Database: C:\Users\RUNNER~1\AppData\Local\Temp\robolectric-CardBrowserViewModelTest_suspend_-_cards_-_some_suspended1688466108410830537\external-files\Android\data\com.ichi2.anki.debug\AnkiDroid\collection.anki2
Collection: (Re)opening Database: C:\Users\RUNNER~1\AppData\Local\Temp\robolectric-CardBrowserViewModelTest_suspend_-_cards_-_some_suspended1688466108410830537\external-files\Android\data\com.ichi2.anki.debug\AnkiDroid\collection.anki2
D/CardBrowserViewModel: CardBrowserViewModel::init
CardBrowserViewModel: CardBrowserViewModel::init
I/CardBrowserViewModel: setting deck: 1
CardBrowserViewModel: setting deck: 1
I/CardBrowserViewModel: initCompleted
CardBrowserViewModel: initCompleted
D/CardBrowserViewModel$launchSearchForCards: performing search: 'deck:"Default" '
CardBrowserViewModel$launchSearchForCards: performing search: 'deck:"Default" '
D/CardBrowserViewModel$launchSearchForCards: Search returned 2 card(s)
CardBrowserViewModel$launchSearchForCards: Search returned 2 card(s)
I/Scheduler: suspending 1 card(s)
Scheduler: suspending 1 card(s)
V/TestChangeSubscriberKt: Listening for ChangeManager ops
TestChangeSubscriberKt: Listening for ChangeManager ops
D/CardBrowserViewModel: selecting all: 2 item(s)
CardBrowserViewModel: selecting all: 2 item(s)
I/Scheduler: suspending 2 card(s)
Scheduler: suspending 2 card(s)
D/CardBrowserViewModel$toggleSuspendCards: finished 'toggleSuspendCards'
CardBrowserViewModel$toggleSuspendCards: finished 'toggleSuspendCards'
I/Collection: Collection closed
Collection: Collection closed
D/Backend: Closing rust backend
Backend: Closing rust backend
-- completed test "suspend - cards - some suspended"

@david-allison
Copy link
Member Author

-- executing test "suspend - notes - all suspended"
D/ChangeManager: clearing 0 subscribers
ChangeManager: clearing 0 subscribers
D/Backend: Opening rust backend with lang=[en-US]
Backend: Opening rust backend with lang=[en-US]
Media: dir /tmp/robolectric-CardBrowserViewModelTest_suspend_-_notes_-_all_suspended16939841479539386933/external-files/Android/data/com.ichi2.anki.debug/AnkiDroid/collection.media
I/Collection: (Re)opening Database: /tmp/robolectric-CardBrowserViewModelTest_suspend_-_notes_-_all_suspended16939841479539386933/external-files/Android/data/com.ichi2.anki.debug/AnkiDroid/collection.anki2
Collection: (Re)opening Database: /tmp/robolectric-CardBrowserViewModelTest_suspend_-_notes_-_all_suspended16939841479539386933/external-files/Android/data/com.ichi2.anki.debug/AnkiDroid/collection.anki2
D/CardBrowserViewModel: CardBrowserViewModel::init
CardBrowserViewModel: CardBrowserViewModel::init
I/CardBrowserViewModel: setting deck: 1
CardBrowserViewModel: setting deck: 1
I/CardBrowserViewModel: initCompleted
CardBrowserViewModel: initCompleted
D/CardBrowserViewModel$launchSearchForCards: performing search: 'deck:"Default" '
CardBrowserViewModel$launchSearchForCards: performing search: 'deck:"Default" '
D/CardBrowserViewModel$launchSearchForCards: Search returned 2 card(s)
CardBrowserViewModel$launchSearchForCards: Search returned 2 card(s)
D/CardBrowserViewModel: manualInit
CardBrowserViewModel: manualInit
I/Scheduler: suspending 4 card(s)
Scheduler: suspending 4 card(s)
D/CardBrowserViewModelTestKt: suspended 4 cards
CardBrowserViewModelTestKt: suspended 4 cards
V/TestChangeSubscriberKt: Listening for ChangeManager ops
TestChangeSubscriberKt: Listening for ChangeManager ops
D/CardBrowserViewModel: selecting all: 2 item(s)
CardBrowserViewModel: selecting all: 2 item(s)
D/CardBrowserViewModel$toggleSuspendCards: toggling selected cards suspend status
CardBrowserViewModel$toggleSuspendCards: toggling selected cards suspend status
I/Scheduler: unsuspending 4 card(s)
Scheduler: unsuspending 4 card(s)
V/ChangeManager: removing 1 expired subscribers
ChangeManager: removing 1 expired subscribers
D/CardBrowserViewModel$toggleSuspendCards: finished 'toggleSuspendCards'
CardBrowserViewModel$toggleSuspendCards: finished 'toggleSuspendCards'
I/Collection: Collection closed
Collection: Collection closed
D/Backend: Closing rust backend
Backend: Closing rust backend
-- completed test "suspend - notes - all suspended"

@david-allison
Copy link
Member Author

david-allison commented Jun 5, 2024

I suspect this is the lambda going out of scope BEFORE the method containing it has completed

Testing: https://github.com/david-allison/Anki-Android/actions/runs/9382123592

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant