Validator agent: retry outbound HTTPS up to 3 times, traceroute on failure
A failed HTTPS check is retried (3 attempts, 2 s apart). If all attempts fail, the agent runs traceroute -4 -n to the target's IPv4 address in a separate process, polls it every 5 s (90 s limit) and posts the full output as a traceroute_result event for the address. The agent waits for traces before reporting completion, while the floating IP is attached. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1536723196
commit
5c75ece8b1
15 files changed
+480
-25
No files matched your search
@@ -0,0 +1,45 @@
|
||||
package checkrunner
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestHTTPSRetrySucceedsOnSecondAttempt(t *testing.T) {
|
||||
var n atomic.Int32
|
||||
srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if n.Add(1) == 1 {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
res := httpsWithRetry(srv.Client(), srv.URL, 2*time.Second, 3, 10*time.Millisecond)(context.Background())
|
||||
if !res.Success || res.Detail != "ok (attempt 2/3)" {
|
||||
t.Fatalf("got success=%v detail=%q", res.Success, res.Detail)
|
||||
}
|
||||
if n.Load() != 2 {
|
||||
t.Fatalf("expected 2 requests, got %d", n.Load())
|
||||
}
|
||||
}
|
||||
|
||||
func TestHostFromTarget(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"https://github.com": "github.com",
|
||||
"https://github.com:8443/x": "github.com",
|
||||
"http://1.2.3.4/path?q=1": "1.2.3.4",
|
||||
"example.org": "example.org",
|
||||
"example.org:443": "example.org",
|
||||
}
|
||||
for in, want := range cases {
|
||||
if got := HostFromTarget(in); got != want {
|
||||
t.Errorf("HostFromTarget(%q)=%q want %q", in, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user