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

Fix more flakey tests #949

Closed
wants to merge 2 commits into from
Closed

Fix more flakey tests #949

wants to merge 2 commits into from

Conversation

AndyTWF
Copy link
Contributor

@AndyTWF AndyTWF commented May 24, 2023

RealtimeChannel: attach_when_channel_in_detaching_state

The test was failing/flakey because the channel sometimes quickly cycled through detaching into attaching, before the listener had a chance to check the state.

This change fixes the issue by making the assertion via a channel state listener instead of a point-in-time check of the channel state, which means transient states are also recorded.

Fixes #944

RealtimeChannelTest channel_resume_lost_continuity

This test was failing because of the order in which listeners were registered. The channel waiters were created (and thus registered as listeners) before the listeners that add state changes to the arrays ready for assertions. EventEmitter runs listeners that don't have a filter in order of registration.

This meant that sometimes, the test would run, the waiter would be informed of a channel state change, thus allowing it to proceed into the assertions phase on the main thread, and only then would the subjects of those assertions be updated.

So you can end up in a situation where the main thread would start asserting on things before all the listeners had run.

This change fixes the issue by ensuring the waiters are registered after the main listeners, so that the assertions will always run once all the states that are going to be received, are received.

You can test this behaviour by adding a sleep just before the line where attachingStateReached[0] is set to true. If you remove the change in this commit, the test will fail.

Fixes #945

The test was failing/flakey because the channel sometimes quickly cycled
through detaching into attaching, before the listener had a chance to check
the state.

This change fixes the issue by making the assertion via a channel state listener
instead of a point-in-time check of the channel state, which means transient states
are also recorded.

Fixes #944
@AndyTWF AndyTWF added testing Includes all kinds of automated tests, the way that we run them and the infrastructure around them. failing-test Where an automated test is failing either locally or in CI. Perhaps flakey, wrong or bug. labels May 24, 2023
@github-actions github-actions bot temporarily deployed to staging/pull/949/features May 24, 2023 10:17 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/949/javadoc May 24, 2023 10:17 Inactive
This test was failing because of the order in which listeners were registered. The channel waiters
were created (and thus registered as listeners) before the listeners that add state changes to the
arrays ready for assertions. EventEmitter runs listeners that don't have a filter in order of registration.

This meant that sometimes, the test would run, the waiter would be informed of a channel state change, thus allowing
it to proceed into the assertions phase on the main thread, and only then would the subjects of those assertions be updated.

So you can end up in a situation where the main thread would start asserting on things before all the listeners had run.

This change fixes the issue by ensuring the waiters are registered after the main listeners, so that the assertions will
always run once all the states that are going to be received, are received.

You can test this behaviour by adding a sleep just before the line where attachingStateReached[0] is set to true. If you remove
the change in this commit, the test will fail.

Fixes #945
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
failing-test Where an automated test is failing either locally or in CI. Perhaps flakey, wrong or bug. testing Includes all kinds of automated tests, the way that we run them and the infrastructure around them.
Development

Successfully merging this pull request may close these issues.

flakey test: channel_resume_lost_continuity flakey test: attach_when_channel_in_detaching_state
2 participants