mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-04-11 21:53:45 +00:00
PubSub Example
This example runs a small replicated pub/sub service with a WebSocket client API.
The scenarios open WebSocket sessions, subscribe to a topic, publish messages, and check that every subscriber sees the same events. There is also a reconnect scenario and a k8s manual-cluster variant that restarts a node mid-run.
How TF runs this
Each example follows the same pattern:
- TF starts a small deployment of pubsub nodes
- a workload opens WebSocket sessions and drives publish/subscribe behavior
- an expectation checks that the nodes end up with the same topic state
Scenarios
basic_ws_roundtripruns a local roundtrip checkbasic_ws_reconnectruns a local reconnect scenariocompose_ws_roundtripandcompose_ws_reconnectrun the same checks in Docker Composek8s_ws_roundtripruns the roundtrip scenario on Kubernetesk8s_manual_ws_roundtripstarts the nodes through the k8s manual cluster API, restarts one node, and checks that the topic state converges again
Run locally
cargo run -p pubsub-examples --bin basic_ws_roundtrip
cargo run -p pubsub-examples --bin basic_ws_reconnect
Run with Docker Compose
cargo run -p pubsub-examples --bin compose_ws_roundtrip
cargo run -p pubsub-examples --bin compose_ws_reconnect
Set PUBSUB_IMAGE to override the default compose image tag.
Run with Kubernetes
docker build -t pubsub-node:local -f examples/pubsub/Dockerfile .
cargo run -p pubsub-examples --bin k8s_ws_roundtrip
Prerequisites:
kubectlconfigured with a reachable clusterhelminstalled
Optional image override:
PUBSUB_K8S_IMAGE(falls back toPUBSUB_IMAGE, thenpubsub-node:local)
Run with Kubernetes manual cluster
docker build -t pubsub-node:local -f examples/pubsub/Dockerfile .
cargo run -p pubsub-examples --bin k8s_manual_ws_roundtrip