New external site management. New external prober heartbeat feature.
This commit is contained in:
1 parent
42f584dd3c
commit
ef24cc9858
38 files changed
+1058
-158
No files matched your search
@@ -316,11 +316,11 @@ func TestSitesPutAndConflict(t *testing.T) {
|
||||
t.Fatalf("expected site-1 assigned to slot 1, got:\n%s", body)
|
||||
}
|
||||
|
||||
// Slot page always renders exactly 3 rows, including empty ones — count
|
||||
// the per-slot PUT forms rather than raw <tr> (the thead row has one too).
|
||||
// The table renders exactly as many rows as configured slots — no
|
||||
// fixed cap, no padding to a fixed count.
|
||||
page := get(t, ts, "/sites")
|
||||
if strings.Count(page, `hx-put="/sites/`) != 3 {
|
||||
t.Fatalf("expected exactly 3 site slot rows, got:\n%s", page)
|
||||
if strings.Count(page, `hx-put="/sites/`) != 1 {
|
||||
t.Fatalf("expected exactly 1 site slot row, got:\n%s", page)
|
||||
}
|
||||
|
||||
body = postForm(t, ts, "PUT", "/sites/2", map[string][]string{"site_id": {"site-1"}})
|
||||
@@ -329,6 +329,53 @@ func TestSitesPutAndConflict(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestSiteCreateAddsSlotBeyondThree proves there's no hardcoded cap on the
|
||||
// number of prober slots — the "add site" form can create slot 4 and
|
||||
// beyond.
|
||||
func TestSiteCreateAddsSlotBeyondThree(t *testing.T) {
|
||||
_, caURL := newFakeControlAPI(t)
|
||||
ts := newTestServer(t, caURL)
|
||||
|
||||
postForm(t, ts, "PUT", "/sites/1", map[string][]string{"site_id": {"site-1"}})
|
||||
postForm(t, ts, "PUT", "/sites/2", map[string][]string{"site_id": {"site-2"}})
|
||||
postForm(t, ts, "PUT", "/sites/3", map[string][]string{"site_id": {"site-3"}})
|
||||
|
||||
body := postForm(t, ts, "POST", "/sites", map[string][]string{"index": {"4"}, "site_id": {"site-4"}})
|
||||
if !strings.Contains(body, "site-4") {
|
||||
t.Fatalf("expected slot 4 created, got:\n%s", body)
|
||||
}
|
||||
if strings.Count(body, `hx-put="/sites/`) != 4 {
|
||||
t.Fatalf("expected exactly 4 site slot rows, got:\n%s", body)
|
||||
}
|
||||
|
||||
// A malformed index is caught by the dashboard itself.
|
||||
body = postForm(t, ts, "POST", "/sites", map[string][]string{"index": {"not-a-number"}, "site_id": {"site-5"}})
|
||||
if !strings.Contains(body, "alert-warning") {
|
||||
t.Fatalf("expected client error banner for non-numeric index, got:\n%s", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSitesPageShowsProberBadge(t *testing.T) {
|
||||
fake, caURL := newFakeControlAPI(t)
|
||||
fake.sites[1] = "site-1"
|
||||
fake.siteState[1] = "idle"
|
||||
fake.siteHostname[1] = "probe-host-1"
|
||||
fake.sites[2] = "site-2"
|
||||
fake.siteState[2] = "unreachable"
|
||||
ts := newTestServer(t, caURL)
|
||||
|
||||
page := get(t, ts, "/sites")
|
||||
if !strings.Contains(page, "probe-host-1") {
|
||||
t.Fatalf("expected hostname shown, got:\n%s", page)
|
||||
}
|
||||
if !strings.Contains(page, "pill-success") || !strings.Contains(page, ">idle<") {
|
||||
t.Fatalf("expected idle badge for site-1, got:\n%s", page)
|
||||
}
|
||||
if !strings.Contains(page, "pill-danger") || !strings.Contains(page, ">unreachable<") {
|
||||
t.Fatalf("expected unreachable badge for site-2, got:\n%s", page)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTargetsAndCheckTypesRoundTrip(t *testing.T) {
|
||||
_, caURL := newFakeControlAPI(t)
|
||||
ts := newTestServer(t, caURL)
|
||||
|
||||
Reference in new issue
Block a user