Repository navigation
test: wait for the server to receive events instead of sleeping - #52
Merged
Merged
Conversation
Each connection counts the events it hands to the batch writer; send_events waits for that count, so a following flush covers every event sent. Connection changes are announced only after they are queued. Drops the sleeps from the flush helpers and the grafana tests, and the grafana copies of connect_test_node/send_events.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tests sent events over TCP, slept 100 ms, then flushed. If the server had not read everything from the socket by then, the flush missed it. A test sending 1000 events sometimes found none of them stored.
Changes
src/server.rs): each connection counts the events it has handed to the batch writer, in awatchchannel. It is updated once per socket read and is not shared between connections.wait_for_events(node_id, count)waits on it.wait_for_connectionsonly after they are queued for the batch writer, so a flush right after the wait includes them.connect_test_nodereturns aTestNode, andsend_eventswaits until the server has received everything sent. The sleeps inflush_all,flush_and_wait, the node-disconnect test and 11 places in the Grafana tests are gone. The Grafana tests use the shared helpers instead of their own copies.test_node_event_count_after_burst: sends 1000 events, flushes, and checks that/api/nodes/:idreports 1000. Without the wait it reports 760.