From b88a3cb7b2cf2c5c33cf05c1f5407a41fb15c387 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Mon, 15 Jun 2026 09:52:08 +0000 Subject: [PATCH] servertest, hi, integration: remove dead test helpers --- cmd/hi/docker.go | 20 ----- hscontrol/servertest/assertions.go | 119 ----------------------------- hscontrol/servertest/harness.go | 7 -- integration/scenario.go | 2 - 4 files changed, 148 deletions(-) diff --git a/cmd/hi/docker.go b/cmd/hi/docker.go index 1ed8709c..cdfa775c 100644 --- a/cmd/hi/docker.go +++ b/cmd/hi/docker.go @@ -769,17 +769,6 @@ func extractContainerArtifacts(ctx context.Context, cli *client.Client, containe return fmt.Errorf("extracting logs: %w", err) } - // Extract tar files for headscale containers only - if strings.HasPrefix(containerName, "hs-") { - err := extractContainerFiles(ctx, cli, containerID, containerName, logsDir, verbose) - if err != nil { - if verbose { - log.Printf("Warning: failed to extract files from %s: %v", containerName, err) - } - // Don't fail the whole extraction if files are missing - } - } - return nil } @@ -827,12 +816,3 @@ func extractContainerLogs(ctx context.Context, cli *client.Client, containerID, return nil } - -// extractContainerFiles extracts database file and directories from headscale containers. -// Note: The actual file extraction is now handled by the integration tests themselves -// via [SaveProfile], [SaveMapResponses], and [SaveDatabase] functions in hsic.go. -func extractContainerFiles(ctx context.Context, cli *client.Client, containerID, containerName, logsDir string, verbose bool) error { - // Files are now extracted directly by the integration tests - // This function is kept for potential future use or other file types - return nil -} diff --git a/hscontrol/servertest/assertions.go b/hscontrol/servertest/assertions.go index 351659cb..54da6473 100644 --- a/hscontrol/servertest/assertions.go +++ b/hscontrol/servertest/assertions.go @@ -1,9 +1,7 @@ package servertest import ( - "net/netip" "testing" - "time" ) // AssertMeshComplete verifies that every client in the slice sees @@ -67,72 +65,6 @@ func AssertPeerOnline(tb testing.TB, observer *TestClient, peerName string) { } } -// AssertPeerOffline checks that the observer sees peerName as offline. -func AssertPeerOffline(tb testing.TB, observer *TestClient, peerName string) { - tb.Helper() - - peer, ok := observer.PeerByName(peerName) - if !ok { - // Peer gone entirely counts as "offline" for this assertion. - return - } - - isOnline, known := peer.Online().GetOk() - if known && isOnline { - tb.Errorf("AssertPeerOffline: %s sees peer %s as online, want offline", - observer.Name, peerName) - } -} - -// AssertPeerGone checks that the observer does NOT have peerName in -// its peer list at all. -func AssertPeerGone(tb testing.TB, observer *TestClient, peerName string) { - tb.Helper() - - _, ok := observer.PeerByName(peerName) - if ok { - tb.Errorf("AssertPeerGone: %s still sees peer %s", observer.Name, peerName) - } -} - -// AssertPeerHasAllowedIPs checks that a peer has the expected -// [tailcfg.Node.AllowedIPs] prefixes. -func AssertPeerHasAllowedIPs(tb testing.TB, observer *TestClient, peerName string, want []netip.Prefix) { - tb.Helper() - - peer, ok := observer.PeerByName(peerName) - if !ok { - tb.Errorf("AssertPeerHasAllowedIPs: %s does not see peer %s", observer.Name, peerName) - - return - } - - got := make([]netip.Prefix, 0, peer.AllowedIPs().Len()) - for i := range peer.AllowedIPs().Len() { - got = append(got, peer.AllowedIPs().At(i)) - } - - if len(got) != len(want) { - tb.Errorf("AssertPeerHasAllowedIPs: %s sees %s with AllowedIPs %v, want %v", - observer.Name, peerName, got, want) - - return - } - - // Build a set for comparison. - wantSet := make(map[netip.Prefix]bool, len(want)) - for _, p := range want { - wantSet[p] = true - } - - for _, p := range got { - if !wantSet[p] { - tb.Errorf("AssertPeerHasAllowedIPs: %s sees %s with unexpected AllowedIP %v (want %v)", - observer.Name, peerName, p, want) - } - } -} - // AssertConsistentState checks that all clients agree on peer // properties: every connected client should see the same set of // peer hostnames. @@ -210,54 +142,3 @@ func AssertSelfHasAddresses(tb testing.TB, client *TestClient) { tb.Errorf("AssertSelfHasAddresses: %s self node has no addresses", client.Name) } } - -// EventuallyAssertMeshComplete retries [AssertMeshComplete] up to -// timeout, useful when waiting for state to propagate. -func EventuallyAssertMeshComplete(tb testing.TB, clients []*TestClient, timeout time.Duration) { - tb.Helper() - - expected := len(clients) - 1 - deadline := time.After(timeout) - - for { - allGood := true - - for _, c := range clients { - nm := c.Netmap() - if nm == nil || len(nm.Peers) < expected { - allGood = false - - break - } - } - - if allGood { - // Final strict check. - AssertMeshComplete(tb, clients) - - return - } - - select { - case <-deadline: - // Report the failure with details. - for _, c := range clients { - nm := c.Netmap() - - got := 0 - if nm != nil { - got = len(nm.Peers) - } - - if got != expected { - tb.Errorf("EventuallyAssertMeshComplete: %s has %d peers, want %d (timeout %v)", - c.Name, got, expected, timeout) - } - } - - return - case <-time.After(100 * time.Millisecond): - // Poll again. - } - } -} diff --git a/hscontrol/servertest/harness.go b/hscontrol/servertest/harness.go index 212c5412..a88aa118 100644 --- a/hscontrol/servertest/harness.go +++ b/hscontrol/servertest/harness.go @@ -145,13 +145,6 @@ func (h *TestHarness) WaitForMeshComplete(tb testing.TB, timeout time.Duration) } } -// WaitForConvergence waits until all connected clients have a -// non-nil [netmap.NetworkMap] and their peer counts have stabilised. -func (h *TestHarness) WaitForConvergence(tb testing.TB, timeout time.Duration) { - tb.Helper() - h.WaitForMeshComplete(tb, timeout) -} - // ChangePolicy sets an ACL policy on the server and propagates changes // to all connected nodes. The policy should be a valid HuJSON policy document. func (h *TestHarness) ChangePolicy(tb testing.TB, policy []byte) { diff --git a/integration/scenario.go b/integration/scenario.go index 2233cbdf..52470fb0 100644 --- a/integration/scenario.go +++ b/integration/scenario.go @@ -406,8 +406,6 @@ func (s *Scenario) ShutdownAssertNoPanics(t *testing.T) { } if s.mockOIDC.r != nil { - s.mockOIDC.r.Close() - err := s.mockOIDC.r.Close() if err != nil { log.Printf("tearing down oidc server: %s", err)