servertest, hi, integration: remove dead test helpers

This commit is contained in:
Kristoffer Dalby
2026-06-15 09:52:08 +00:00
parent ed6596f9d7
commit b88a3cb7b2
4 changed files with 0 additions and 148 deletions
-20
View File
@@ -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
}
-119
View File
@@ -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.
}
}
}
-7
View File
@@ -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) {
-2
View File
@@ -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)