Skip to content

[GOAL2-784] Fix random network unit test failures#75

Merged
zeldovich merged 4 commits intoalgorand:masterfrom
tsachiherman:tsachi/nettestfail2
Jun 21, 2019
Merged

[GOAL2-784] Fix random network unit test failures#75
zeldovich merged 4 commits intoalgorand:masterfrom
tsachiherman:tsachi/nettestfail2

Conversation

@tsachiherman
Copy link
Copy Markdown
Contributor

Summary

Our existing websocket library would fail to flush the first few messages, as long as the messages accumulated size is below 4096 bytes.

Explanation

The websocket library is creating a thread that is responsible for flushing the pending buffer content. When a write operation is complete, the flushing thread is being woken up to flush the buffer content.
The issue is that upon startup, the connection might get created, followed by several messages being sent. If that happens before the flushing thread start to execute, the flushing thread might miss the signal which indicates it needs to flush the outgoing buffer content.

In the context of our unit tests, where we send two small messages and wait until they reach the other socket, it being expressed as a flaky test.

Solution

The first for this is pretty straight forward; on the flushing thread, just flush the content of the buffer upon startup without waiting for a signal. Then, wait for the signal which would handle the subsequent iteration.

@tsachiherman tsachiherman changed the title Tsachi/nettestfail2 [GOAL2-784] Fix random network unit test failuires Jun 21, 2019
@tsachiherman tsachiherman changed the title [GOAL2-784] Fix random network unit test failuires [GOAL2-784] Fix random network unit test failures Jun 21, 2019
@Vervious
Copy link
Copy Markdown
Contributor

Fixes #74

derbear pushed a commit to derbear/go-algorand that referenced this pull request May 12, 2020
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.

4 participants