MCPcopy
hub / github.com/tailscale/tailscale / TestContainerBoot

Function TestContainerBoot

cmd/containerboot/main_test.go:49–1389  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47const configFileAuthKey = "some-auth-key"
48
49func TestContainerBoot(t *testing.T) {
50 flakytest.Mark(t, "https://github.com/tailscale/tailscale/issues/19380")
51 boot := filepath.Join(t.TempDir(), "containerboot")
52 if err := exec.Command("go", "build", "-ldflags", "-X main.testSleepDuration=1ms", "-o", boot, "tailscale.com/cmd/containerboot").Run(); err != nil {
53 t.Fatalf("Building containerboot: %v", err)
54 }
55 egressStatus := egressSvcStatus("foo", "foo.tailnetxyz.ts.net", "100.64.0.2")
56 egressStatusUpdated := egressSvcStatus("foo", "foo.tailnetxyz.ts.net", "100.64.0.3")
57
58 metricsURL := func(port int) string {
59 return fmt.Sprintf("http://127.0.0.1:%d/metrics", port)
60 }
61 healthURL := func(port int) string {
62 return fmt.Sprintf("http://127.0.0.1:%d/healthz", port)
63 }
64 egressSvcTerminateURL := func(port int) string {
65 return fmt.Sprintf("http://127.0.0.1:%d%s", port, kubetypes.EgessServicesPreshutdownEP)
66 }
67
68 capver := fmt.Sprintf("%d", tailcfg.CurrentCapabilityVersion)
69
70 type phase struct {
71 // If non-nil, send this IPN bus notification (and remember it as the
72 // initial update for any future new watchers, then wait for all the
73 // Waits below to be true before proceeding to the next phase.
74 Notify *ipn.Notify
75
76 // WantCmds is the commands that containerboot should run in this phase.
77 WantCmds []string
78
79 // WantKubeSecret is the secret keys/values that should exist in the
80 // kube secret.
81 WantKubeSecret map[string]string
82
83 // Update the kube secret with these keys/values at the beginning of the
84 // phase (simulates our fake tailscaled doing it).
85 UpdateKubeSecret map[string]string
86
87 // Update files with these paths/contents at the beginning of the phase
88 // (simulates the operator updating mounted config files).
89 UpdateFiles map[string]string
90
91 // WantFiles files that should exist in the container and their
92 // contents.
93 WantFiles map[string]string
94
95 // WantLog is a log message we expect from containerboot.
96 WantLog string
97
98 // If set for a phase, the test will expect containerboot to exit with
99 // this error code, and the test will finish on that phase without
100 // waiting for the successful startup log message.
101 WantExitCode *int
102
103 // The signal to send to containerboot at the start of the phase.
104 Signal *syscall.Signal
105
106 EndpointStatuses map[string]int

Callers

nothing calls this directly

Calls 15

StringMethod · 0.95
MarkFunction · 0.92
StableNodeIDTypeAlias · 0.92
WaitForFunction · 0.92
egressSvcStatusFunction · 0.85
mustJSONFunction · 0.85
newTestEnvFunction · 0.85
statusFromNotifyFunction · 0.85
waitLogLineFunction · 0.85
waitArgsFunction · 0.85
SetSecretMethod · 0.80
SetPatchingMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…