nats
The atago project wrote these specs on its own initiative and runs them in its own CI, to exercise atago against a real program. They are not nats’s official test suite, and the nats project is not affiliated with atago.
Summary #
1 suite · 5 scenarios
Contents #
- nats (self-hosted messaging system) — 5 scenarios
nats (self-hosted messaging system) #
NATS is a message broker, which makes it the one workload here that needs two live participants to mean anything.
Request/reply is tested with a real responder: a second background process subscribes and answers, so a request is proven to have reached something and come back — not merely to have been accepted by the broker.
JetStream, the persistence layer, is followed through its whole cycle: create a stream, publish into it, read the stream’s state back and count what is stored, then purge it and confirm the count fell. The key-value store built on top is exercised the same way, and the broker’s monitoring endpoint is checked over HTTP alongside.
Source: test/e2e/thirdparty/nats/nats.atago.yaml
Scenario: the binary reports its version #
When #
nats-server --version
Then #
- exit code is
0 - stdout matches
/nats-server: v[0-9]+\.[0-9]+\.[0-9]+/
Scenario: the monitoring endpoint reports a healthy JetStream server #
Given #
- Background service
nats-serveris started:nats-server -js -sd store -a 127.0.0.1 -p 18160 -m 18161.
When #
# HTTP GET /healthz
# HTTP GET /varz
Then #
- after
HTTP GET /healthz:- HTTP status is
200 - body at
$.statusequalsok
- HTTP status is
- after
HTTP GET /varz:- HTTP status is
200 - body at
$.versionmatches/^[0-9]+\.[0-9]+\.[0-9]+/ - body at
$.portequals18160
- HTTP status is
Scenario: request/reply round-trips through the broker #
Given #
- Background service
nats-serveris started:nats-server -a 127.0.0.1 -p 18162. - Background service
responderis started:nats -s nats://127.0.0.1:18162 reply help.please "OK I CAN HELP".
When #
nats -s nats://127.0.0.1:18162 request help.please "help me"
Then #
- exit code is
0 - stdout contains
OK I CAN HELP
Scenario: a JetStream stream persists, counts, and purges messages #
Given #
- Background service
nats-serveris started:nats-server -js -sd store -a 127.0.0.1 -p 18163.
When #
nats -s nats://127.0.0.1:18163 stream add ORDERS --subjects "orders.>" --defaults
nats -s nats://127.0.0.1:18163 pub orders.new "order-1"
nats -s nats://127.0.0.1:18163 pub orders.priority "order-2"
nats -s nats://127.0.0.1:18163 stream info ORDERS --json
nats -s nats://127.0.0.1:18163 stream purge ORDERS --force
nats -s nats://127.0.0.1:18163 stream info ORDERS --json
Then #
- after
nats -s nats://127.0.0.1:18163 stream add ORDERS --subjects "orders.>" --defaults:- exit code is
0 - stdout contains
Stream ORDERS was created
- exit code is
- after
nats -s nats://127.0.0.1:18163 pub orders.new "order-1":- exit code is
0
- exit code is
- after
nats -s nats://127.0.0.1:18163 pub orders.priority "order-2":- exit code is
0
- exit code is
- after
nats -s nats://127.0.0.1:18163 stream info ORDERS --json:- exit code is
0 - stdout at
$.state.messagesequals2 - stdout at
$.config.subjects[0]equalsorders.>
- exit code is
- after
nats -s nats://127.0.0.1:18163 stream purge ORDERS --force:- exit code is
0
- exit code is
- after
nats -s nats://127.0.0.1:18163 stream info ORDERS --json:- exit code is
0 - stdout at
$.state.messagesequals0
- exit code is
Scenario: the JetStream KV bucket stores and serves configuration #
Given #
- Background service
nats-serveris started:nats-server -js -sd store -a 127.0.0.1 -p 18164.
When #
nats -s nats://127.0.0.1:18164 kv add CONFIG
nats -s nats://127.0.0.1:18164 kv put CONFIG greeting "hello from atago"
nats -s nats://127.0.0.1:18164 kv get CONFIG greeting --raw
nats -s nats://127.0.0.1:18164 kv del CONFIG greeting --force
nats -s nats://127.0.0.1:18164 kv get CONFIG greeting --raw
Then #
- after
nats -s nats://127.0.0.1:18164 kv add CONFIG:- exit code is
0 - stdout contains
Bucket Name: CONFIG
- exit code is
- after
nats -s nats://127.0.0.1:18164 kv put CONFIG greeting "hello from atago":- exit code is
0
- exit code is
- after
nats -s nats://127.0.0.1:18164 kv get CONFIG greeting --raw:- exit code is
0 - stdout equals an exact value
- exit code is
- after
nats -s nats://127.0.0.1:18164 kv del CONFIG greeting --force:- exit code is
0
- exit code is
- after
nats -s nats://127.0.0.1:18164 kv get CONFIG greeting --raw:- exit code is not
0
- exit code is not