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

test(UserAuthenticationObserverServiceTest): attempt to fix test flakiness #42

Conversation

iusmac
Copy link
Owner

@iusmac iusmac commented Dec 6, 2024

When running this particular test inside a GitHub workflow, for some reason, sending the interrupt signal can take some time to be received by the Worker thread, so the LinkedBlockingQueue poll is not stopped and new tasks can still be "infiltrated", or, maybe the latter itself takes time to acquire a new ReentrantLock and enter the waiting state. Luckily, we have the mReleased flag, which we can use to further prevent new tasks from being added to the queue when Worker has been explicitly stopped.

java.lang.AssertionError:
Expected: is <3>
     but: was <4>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
	at com.github.iusmac.sevensim.UserAuthenticationObserverServiceTest$TaskRunningLifecycle.test_onStartCommand_NoNewTasksShouldBeAcceptedAfterDestroyed(UserAuthenticationObserverServiceTest.java:365)

…iness

When running this particular test inside a GitHub workflow, for some
reason, sending the interrupt signal can take some time to be received
by the Worker thread, so the LinkedBlockingQueue poll is not stopped and
new tasks can still be "infiltrated", or, maybe the latter itself takes
time to acquire a new ReentrantLock and enter the waiting state.
Luckily, we have the mReleased flag, which we can use to further prevent
new tasks from being added to the queue when Worker has been explicitly
stopped.

java.lang.AssertionError:
Expected: is <3>
     but: was <4>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
	at com.github.iusmac.sevensim.UserAuthenticationObserverServiceTest$TaskRunningLifecycle.test_onStartCommand_NoNewTasksShouldBeAcceptedAfterDestroyed(UserAuthenticationObserverServiceTest.java:365)

Signed-off-by: iusmac <[email protected]>
@iusmac iusmac merged commit c590bd0 into 14.0-dev Dec 6, 2024
1 check passed
@iusmac iusmac deleted the hotfix/UserAuthenticationObserverServiceTest-attempt-to-address-test-flakiness branch December 6, 2024 20:56
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.

1 participant