Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix main CI fallout from the 50-node demo estate

rcourtman814f7008833c
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 83324e3035..810029e32e 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -199,9 +199,11 @@ jobs:
- name: Go unit tests (shard ${{ matrix.shard }})
env:
PULSE_DATA_DIR: /tmp/pulse-test-data
- # internal/api alone takes ~10m under -race on a fast machine; CI
- # runners need the larger per-binary budget. Remaining packages are
- # split deterministically by list position.
+ # internal/api alone takes ~22m under -race on a fast machine since
+ # the demo estate scaled to 50 nodes, and CI runners have needed
+ # roughly double the fast-machine time, hence the large per-binary
+ # budget. Remaining packages are split deterministically by list
+ # position.
run: |
set -euo pipefail
case "${{ matrix.shard }}" in
@@ -215,7 +217,7 @@ jobs:
exit 1
fi
printf 'Packages in this shard:\n%s\n' "$pkgs"
- go test -race -timeout 25m $pkgs
+ go test -race -timeout 50m $pkgs
scripts-and-build:
name: Script smoke tests & backend build
diff --git a/internal/alerts/history_concurrency_test.go b/internal/alerts/history_concurrency_test.go
index 4af4e39c33..a45474f3ce 100644
--- a/internal/alerts/history_concurrency_test.go
+++ b/internal/alerts/history_concurrency_test.go
@@ -74,13 +74,9 @@ func TestHistoryManagerConcurrentAccess(t *testing.T) {
wg.Wait()
- close(hm.stopChan)
- if hm.saveTicker != nil {
- hm.saveTicker.Stop()
- }
-
- // give final save a chance
- time.Sleep(20 * time.Millisecond)
+ // Stop waits for the save worker and performs the final save, so nothing
+ // races the TempDir cleanup.
+ hm.Stop()
_ = os.RemoveAll(tempDir)
}
diff --git a/internal/alerts/history_lifecycle_test.go b/internal/alerts/history_lifecycle_test.go
index f6666501b1..2303a0d80c 100644
--- a/internal/alerts/history_lifecycle_test.go
+++ b/internal/alerts/history_lifecycle_test.go
@@ -86,12 +86,9 @@ func TestStartPeriodicSave_PersistsHistoryOnTicker(t *testing.T) {
}
hm.startPeriodicSave()
- defer func() {
- close(hm.stopChan)
- if hm.saveTicker != nil {
- hm.saveTicker.Stop()
- }
- }()
+ // Stop waits for the save worker, so an in-flight save cannot race the
+ // TempDir cleanup.
+ defer hm.Stop()
deadline := time.Now().Add(750 * time.Millisecond)
for time.Now().Before(deadline) {
diff --git a/internal/api/router_integration_test.go b/internal/api/router_integration_test.go
index 8fdf39a790..d6690535c8 100644
--- a/internal/api/router_integration_test.go
+++ b/internal/api/router_integration_test.go
@@ -5,6 +5,7 @@ import (
"context"
"database/sql"
"encoding/json"
+ "fmt"
"io"
"net/http"
"net/http/cookiejar"
@@ -876,36 +877,50 @@ func TestStateEndpointReturnsMockData(t *testing.T) {
func TestRecoveryRollupsEndpointReturnsMockData(t *testing.T) {
srv := newIntegrationServer(t)
- res, err := http.Get(srv.server.URL + "/api/recovery/rollups?limit=500")
- if err != nil {
- t.Fatalf("rollups request failed: %v", err)
- }
- defer res.Body.Close()
+ // The endpoint caps limit at 500 per page and the default mock estate
+ // produces more rollups than one page holds, so walk every page.
+ var allItems []map[string]any
+ for page := 1; ; page++ {
+ res, err := http.Get(fmt.Sprintf("%s/api/recovery/rollups?limit=500&page=%d", srv.server.URL, page))
+ if err != nil {
+ t.Fatalf("rollups request failed (page %d): %v", page, err)
+ }
- if res.StatusCode != http.StatusOK {
- body, _ := io.ReadAll(res.Body)
- t.Fatalf("unexpected status: got %d want %d, body=%s", res.StatusCode, http.StatusOK, string(body))
- }
+ if res.StatusCode != http.StatusOK {
+ body, _ := io.ReadAll(res.Body)
+ res.Body.Close()
+ t.Fatalf("unexpected status on page %d: got %d want %d, body=%s", page, res.StatusCode, http.StatusOK, string(body))
+ }
- var payload struct {
- Data []map[string]any `json:"data"`
- Meta map[string]any `json:"meta"`
- }
- body, err := io.ReadAll(res.Body)
- if err != nil {
- t.Fatalf("read rollups response: %v", err)
- }
- if err := json.Unmarshal(body, &payload); err != nil {
- t.Fatalf("unmarshal rollups response: %v", err)
+ var payload struct {
+ Data []map[string]any `json:"data"`
+ Meta map[string]any `json:"meta"`
+ }
+ body, err := io.ReadAll(res.Body)
+ res.Body.Close()
+ if err != nil {
+ t.Fatalf("read rollups response (page %d): %v", page, err)
+ }
+ if err := json.Unmarshal(body, &payload); err != nil {
+ t.Fatalf("unmarshal rollups response (page %d): %v", page, err)
+ }
+
+ allItems = append(allItems, payload.Data...)
+ if len(payload.Data) < 500 {
+ break
+ }
+ if page > 100 {
+ t.Fatalf("rollups pagination did not terminate after %d pages", page)
+ }
}
- if len(payload.Data) == 0 {
- t.Fatalf("expected rollups data, got none: %s", string(body))
+ if len(allItems) == 0 {
+ t.Fatal("expected rollups data, got none")
}
hasK8s := false
hasTrueNAS := false
- for _, item := range payload.Data {
+ for _, item := range allItems {
raw, ok := item["platforms"]
if !ok {
continue