New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/statsd: refactor test #40554
nixos/statsd: refactor test #40554
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. This makes the test much more useful.
nixos/tests/statsd.nix
Outdated
$machine->waitForOpenPort(8126); | ||
|
||
# check state of the `statsd` server | ||
$machine->succeed('[ "health: up" = "$(echo health | nc 127.0.0.1 8126 -w 1)" ];'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The short -w 1
timeout may cause non-deterministic failures on Hydra with high system load.
I would set a much longer timeout such as 120s. Same for the other TCP requests below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think this would be simpler, easier to read and more consistent with the rest:
$machine->succeed("echo health | nc -w 120 127.0.0.1 8126 -w 120 | grep -q 'health: up' ");
85fc1ac
to
1f311f5
Compare
@xeji increased the timeouts to 120 minutes ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The netcat options are not yet correct. Sorry I missed some things before (we recently switched master from openbsd-netcat
to a version bundled with libressl
, which has slightly different options and behaves differently, and I checked locally with the old version).
If everything is correct, the test should finish quickly without extra waits. At least it does on my local machine...
nixos/tests/statsd.nix
Outdated
$machine->waitForOpenPort(8126); | ||
|
||
# check state of the `statsd` server | ||
$machine->succeed('[ "health: up" = "$(echo health | nc 127.0.0.1 8126 -w 120)" ];'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add -N
for all TCP connections (but not for UDP) so the connection is closed after EOF on input. Otherwise this will wait 120s even after a successful connection, and the test takes forever.
nixos/tests/statsd.nix
Outdated
# confirm basic examples for metrics derived from docs: | ||
# https://github.com/etsy/statsd/blob/v0.8.0/README.md#usage and | ||
# https://github.com/etsy/statsd/blob/v0.8.0/docs/admin_interface.md | ||
$machine->succeed("echo 'foo:1|c' | nc -u -w 120 127.0.0.1 8125"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this one is UDP, you actually need -w 0
here. (but not -N
)
nixos/tests/statsd.nix
Outdated
# https://github.com/etsy/statsd/blob/v0.8.0/README.md#usage and | ||
# https://github.com/etsy/statsd/blob/v0.8.0/docs/admin_interface.md | ||
$machine->succeed("echo 'foo:1|c' | nc -u -w 120 127.0.0.1 8125"); | ||
$machine->succeed("echo counters | nc -w 120 127.0.0.1 8126 | grep foo"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and everything below) is TCP again. Add -N
.
`statsd` is a daemon written in `node` to gather statistics over UDP. The current test ensures that a port is open, but the basic functionality isn't sufficiently tested. This patch contains the following changes: * Simplified port scanning (`waitForOpenPort` rather than `netcat` magic). * Issue a TCP command to check the health of the `statsd` server. * Simple script to check if `statsd` receives data over UDP and confirms the basic functionality of the TCP interface on `8126` for admin purposes.
1f311f5
to
1f82a70
Compare
@xeji yeah it doesn't wait as well on my side. Thanks for your help! |
@GrahamcOfBorg test statsd |
No attempt on aarch64-linux (full log) The following builds were skipped because they don't evaluate on aarch64-linux: tests.statsd Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: tests.statsd Partial log (click to expand)
|
14 seconds - looks good 😃 - thanks for improving this test! |
Motivation for this change
statsd
is a daemon written innode
to gather statistics over UDP.The current test ensures that a port is open, but the basic
functionality isn't sufficiently tested.
This patch contains the following changes:
Simplified port scanning (
waitForOpenPort
rather thannetcat
magic).Issue a TCP command to check the health of the
statsd
server.Simple script to check if
statsd
receives data over UDP and confirmsthe basic functionality of the TCP interface on
8126
for adminpurposes.
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)