Skip to content

test: wait for the server to receive events instead of sleeping - #52

Merged
michalkucharczyk merged 1 commit into
mainfrom
mku-harness-wait-events
Nov 12, 2026
Merged

michalkucharczyk merged 1 commit into
mainfrom
mku-harness-wait-events

Conversation

@michalkucharczyk

Copy link
Copy Markdown
Contributor

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

  • Server (src/server.rs): each connection counts the events it has handed to the batch writer, in a watch channel. It is updated once per socket read and is not shared between connections. wait_for_events(node_id, count) waits on it.
  • Connection changes are announced to wait_for_connections only after they are queued for the batch writer, so a flush right after the wait includes them.
  • Test helpers: connect_test_node returns a TestNode, and send_events waits until the server has received everything sent. The sleeps in flush_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.
  • New test test_node_event_count_after_burst: sends 1000 events, flushes, and checks that /api/nodes/:id reports 1000. Without the wait it reports 760.

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.
@michalkucharczyk
michalkucharczyk merged commit d88d744 into main Nov 12, 2026
6 checks passed
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