mirror of
https://github.com/Cacti/spine.git
synced 2026-10-30 16:47:26 +09:00
## Summary Consolidates the connector/build work from #613 and the broader test-infrastructure work extracted from #597 into one review: - discover MariaDB Connector/C first while retaining MySQL and Percona-compatible support - test MariaDB and MySQL Connector/C with strict GCC and Clang builds on Ubuntu 24.04 - add a real macOS 15 build and unit-test lane with portable Autotools platform detection - run unit tests under ASan/UBSan and ThreadSanitizer - enforce the measured 7% global coverage baseline and 70% changed-line coverage - add libFuzzer coverage for output parsing alongside the existing hostname parser - exercise the SNMPv3 integration suite against MariaDB and MySQL 8.4 - add cppcheck, shellcheck, DCO verification, CODEOWNERS, distcheck, and Linux-capability checks while retaining the repository-managed default CodeQL setup - expose a stable `CI / required` aggregate check for branch protection - pin runners and third-party actions and keep workflow permissions read-only by default ## Correctness fixes found by the new gates - reject truncated capability strings and poller-output SQL tuples instead of publishing partial data - make `bootstrap` fail closed and select `libtoolize`/`glibtoolize` portably - use Autoconf's canonical host for Darwin detection instead of an empty native-build alias - remove stale initialization/name-shadow findings and make read-only interfaces const-correct - make the ICMP parser test portable across Linux and BSD header names ## Verification - strict GCC and Clang builds: 4/4 unit targets passed - ASan/UBSan: 4/4 passed - ThreadSanitizer: 4/4 passed - macOS Clang/Homebrew build: 4/4 passed - MariaDB integration: passed - MySQL 8.4 integration: passed - both libFuzzer targets: passed sustained local runs - coverage: 7.2% global and 84% on changed lines - cppcheck, shellcheck, actionlint, DCO verification, and `git diff --check`: passed locally ## Post-merge repository settings After these workflows exist on `develop`, an administrator should require `CI / required`, Fuzz, Integration, Rocky Linux, and the repository-managed CodeQL/code-scanning result in the active ruleset; enable code-owner approval; and require the branch to be current (or use a merge queue). Enabling those settings before this PR merges would create required checks that the base branch cannot yet emit. Consolidates and supersedes #613. Closes #612. --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> Signed-off-by: TheWitness <thewitness@cacti.net> Signed-off-by: TheWitness <copilot@users.noreply.github.com> Co-authored-by: TheWitness <thewitness@cacti.net> Co-authored-by: TheWitness <copilot@users.noreply.github.com>
54 lines
2.3 KiB
Bash
Executable File
54 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# Asserts that the poll actually produced data, rather than that spine exited 0.
|
|
#
|
|
# Runs after the spine service completes, against the same database spine wrote
|
|
# to. Every check here is something a regression in poll_host() would break.
|
|
set -eu
|
|
|
|
DB_CLIENT=${DB_CLIENT:-mariadb}
|
|
Q="$DB_CLIENT -h db -u spine -pspine cacti -N -B -e"
|
|
|
|
fail() { echo "FAIL: $1"; exit 1; }
|
|
ok() { echo "ok: $1"; }
|
|
|
|
# 1. the poll wrote a result for the configured data source
|
|
rows=$($Q "SELECT COUNT(*) FROM poller_output WHERE local_data_id = 1;")
|
|
[ "$rows" -ge 1 ] || fail "poller_output has no row for local_data_id 1 (got $rows)"
|
|
ok "poller_output has $rows row(s) for local_data_id 1"
|
|
|
|
# 2. the value is a number, not an error string or 'U'
|
|
val=$($Q "SELECT output FROM poller_output WHERE local_data_id = 1 LIMIT 1;")
|
|
case "$val" in
|
|
''|*[!0-9]*) fail "poller_output.output is not numeric: '$val'" ;;
|
|
esac
|
|
ok "sysUpTime came back numeric: $val"
|
|
|
|
# 3. sysUpTime is a timeticks counter, so it must be moving
|
|
[ "$val" -gt 0 ] || fail "sysUpTime is $val, expected a running counter"
|
|
ok "sysUpTime is non-zero"
|
|
|
|
# 4. the device was not marked down or put into an error state
|
|
status=$($Q "SELECT status FROM host WHERE id = 1;")
|
|
[ "$status" = "3" ] || fail "host status is $status, expected 3 (up)"
|
|
ok "host 1 recorded as up"
|
|
|
|
# 5. availability accounting ran
|
|
errs=$($Q "SELECT COUNT(*) FROM host_errors WHERE host_id = 1;")
|
|
[ "$errs" = "0" ] || fail "host_errors has $errs row(s) for host 1"
|
|
ok "no host errors recorded"
|
|
|
|
# 6. the script-action data source ran and stored exactly what it printed
|
|
srows=$($Q "SELECT COUNT(*) FROM poller_output WHERE local_data_id = 2;")
|
|
[ "$srows" -ge 1 ] || fail "poller_output has no row for the script data source (got $srows)"
|
|
sval=$($Q "SELECT output FROM poller_output WHERE local_data_id = 2 LIMIT 1;")
|
|
[ "$sval" = "42" ] || fail "script data source stored '$sval', expected '42'"
|
|
ok "script action returned $sval"
|
|
|
|
# 7. the auto-reindex assertion matched, so no reindex was queued. A broken
|
|
# compare shows up here as a spurious reindex on every poll.
|
|
cmds=$($Q "SELECT COUNT(*) FROM poller_command WHERE poller_id = 1;")
|
|
[ "$cmds" = "0" ] || fail "poller_command has $cmds row(s); the reindex assertion should have matched"
|
|
ok "auto-reindex assertion matched, nothing queued"
|
|
|
|
echo "integration checks passed"
|