Address publication review feedback
Add the AGPL LICENSE file and a deployment-security note in the README to clarify that the unauthenticated /collect endpoint must run on a trusted network. Fix the IPv6 reachability rule so it consults the IP actually probed: PingTargetResult now carries ResolvedIP populated from pinger.IPAddr(), which lets the rule classify hostname targets correctly instead of always reporting "No IPv6 target pinged". Tighten error handling: ipsFromService now propagates JSON errors, ExtractMetrics wraps decode failures, the count option returns an explicit error when out of range instead of silently clamping, and the "all pings failed" message no longer concatenates every per-target error. Threshold validation is factored into validateThresholdPair and shared between the RTT and packet-loss rules. Add unit tests covering address resolution, threshold validation, and each rule's evaluation paths.
This commit is contained in:
parent
706fc2a4c1
commit
086492b03c
16 changed files with 1183 additions and 33 deletions
65
checker/rules_ipv6_test.go
Normal file
65
checker/rules_ipv6_test.go
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
// This file is part of the happyDomain (R) project.
|
||||
// Copyright (c) 2020-2026 happyDomain
|
||||
// Authors: Pierre-Olivier Mercier, et al.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
package checker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
sdk "git.happydns.org/checker-sdk-go/checker"
|
||||
)
|
||||
|
||||
func TestIPv6ReachabilityEvaluate(t *testing.T) {
|
||||
r := &ipv6ReachabilityRule{}
|
||||
ctx := context.Background()
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
targets []PingTargetResult
|
||||
wantStat sdk.Status
|
||||
wantCode string
|
||||
}{
|
||||
{
|
||||
name: "no v6 targets",
|
||||
targets: []PingTargetResult{{Address: "1.1.1.1", Sent: 5, Received: 5}},
|
||||
wantStat: sdk.StatusUnknown,
|
||||
wantCode: "ping.ipv6_reachable.skipped",
|
||||
},
|
||||
{
|
||||
name: "v6 reachable",
|
||||
targets: []PingTargetResult{
|
||||
{Address: "1.1.1.1", Sent: 5, Received: 5},
|
||||
{Address: "2001:db8::1", Sent: 5, Received: 5},
|
||||
},
|
||||
wantStat: sdk.StatusOK,
|
||||
wantCode: "ping.ipv6_reachable.ok",
|
||||
},
|
||||
{
|
||||
name: "all v6 unreachable",
|
||||
targets: []PingTargetResult{
|
||||
{Address: "2001:db8::1", Sent: 5, Received: 0},
|
||||
{Address: "2001:db8::2", Sent: 5, Received: 0},
|
||||
},
|
||||
wantStat: sdk.StatusWarn,
|
||||
wantCode: "ping.ipv6_reachable.unreachable",
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
states := r.Evaluate(ctx, obsWith(c.targets...), sdk.CheckerOptions{})
|
||||
if len(states) != 1 {
|
||||
t.Fatalf("got %d states, want 1", len(states))
|
||||
}
|
||||
if states[0].Status != c.wantStat {
|
||||
t.Errorf("status = %v, want %v", states[0].Status, c.wantStat)
|
||||
}
|
||||
if states[0].Code != c.wantCode {
|
||||
t.Errorf("code = %q, want %q", states[0].Code, c.wantCode)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue