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 fixed #1705

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Flaky test fixed #1705

wants to merge 1 commit into from

Conversation

Derrick2000
Copy link

Dear Maintainer,

I noticed that one of the WebSocket tests in the repository is exhibiting flaky behavior due to Non-Order-Determinism (NOD) issues. Below is a detailed explanation of the problem and a proposed fix to ensure the test behaves reliably.

Occasionally, the test fails at the line:

with the error:
expected:<[MESSAGE-ECHO-hi]> but was:<[CLOSE]>

The issue stems from Non-Order-Determinism (NOD) in the asynchronous WebSocket communication. Specifically:

  1. Race Condition During Reconnection: After sending the "close" message, the test immediately proceeds to send "hi" without ensuring that the WebSocket connection has been fully reopened.
    The "CLOSE" message from the previous interaction might still be processed or pending when "hi" is sent, causing the test to retrieve "CLOSE" instead of "MESSAGE-ECHO-hi".

  2. Session State Assumption: The test assumes that the Session is immediately ready to send and receive messages after receiving an "OPEN" message, which may not be the case in all scenarios.

  3. Unreliable Message Processing Order: WebSocket communication is asynchronous, and the test does not synchronize properly with the server's message processing, leading to unexpected order of messages.

Proposed Fix
To resolve the issue, I propose the following change: Verify session state before sending messages by adding a check to ensure the Session is open and ready for communication. This change ensure the test behaves reliably by addressing the Non-Order-Determinism issue caused by race conditions in the asynchronous WebSocket communication.

Please let me know if you’d like further clarification or assistance with implementing these changes.

Best regards,

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