mirror of
https://github.com/kubereboot/kured.git
synced 2026-05-24 01:03:03 +00:00
Without this, we can't know if the exposed prometheus metrics behave properly. This is a problem, as the only way we can evaluate the success (right now), is a compilation success or failure from kured. While this is a good start, it doesn't translate to what we claim to offer: A boolean showing if a reboot is required. This fixes it by creating a new github action workflow testing if the float64 gauge is properly showing 0 for no reboot, 1 for reboot. This is done by exposing the metrics endpoint through a node port. A helm chart change was required to have the ability to expose the service on a node port. We connect to the kind node through docker in the `tests/test-metrics.sh`, where we curl the nodeport, extract the only relevant metric, and compare it to the expected result.
19 lines
520 B
Bash
Executable File
19 lines
520 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
expected="$1"
|
|
if [[ "$expected" != "0" && "$expected" != "1" ]]; then
|
|
echo "You should give an argument to this script, the gauge value (0 or 1)"
|
|
exit 1
|
|
fi
|
|
|
|
HOST="${HOST:-localhost}"
|
|
PORT="${PORT:-30000}"
|
|
NODENAME="${NODENAME-chart-testing-control-plane}"
|
|
|
|
reboot_required=$(docker exec "$NODENAME" curl "http://$HOST:$PORT/metrics" | awk '/^kured_reboot_required/{print $2}')
|
|
if [[ "$reboot_required" == "$expected" ]]; then
|
|
echo "Test success"
|
|
else
|
|
echo "Test failed"
|
|
exit 1
|
|
fi |