MCPcopy Create free account
hub / github.com/tailscale/tailscale / TestNodeWithBadStateFile

Function TestNodeWithBadStateFile

tstest/integration/integration_test.go:2461–2493  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2459}
2460
2461func TestNodeWithBadStateFile(t *testing.T) {
2462 tstest.Parallel(t)
2463 env := NewTestEnv(t)
2464 n1 := NewTestNode(t, env)
2465 if err := os.WriteFile(n1.stateFile, []byte("bad json"), 0644); err != nil {
2466 t.Fatal(err)
2467 }
2468
2469 d1 := n1.StartDaemon()
2470 n1.AwaitResponding()
2471
2472 // Make sure the health message shows up in status output.
2473 n1.AwaitBackendState("NoState")
2474 st := n1.MustStatus()
2475 wantHealth := ipn.StateStoreHealth.Text(health.Args{health.ArgError: ""})
2476 if !slices.ContainsFunc(st.Health, func(m string) bool { return strings.HasPrefix(m, wantHealth) }) {
2477 t.Errorf("Status does not contain expected health message %q\ngot health messages: %q", wantHealth, st.Health)
2478 }
2479
2480 // Make sure login attempts are rejected.
2481 cmd := n1.Tailscale("up", "--login-server="+n1.env.ControlURL())
2482 t.Logf("Running %v ...", cmd)
2483 out, err := cmd.CombinedOutput()
2484 if err == nil {
2485 t.Fatalf("up succeeded with output %q", out)
2486 }
2487 wantOut := "cannot start backend when state store is unhealthy"
2488 if !strings.Contains(string(out), wantOut) {
2489 t.Fatalf("got up output:\n%s\nwant:\n%s", string(out), wantOut)
2490 }
2491
2492 d1.MustCleanShutdown(t)
2493}

Callers

nothing calls this directly

Calls 15

StartDaemonMethod · 0.95
AwaitRespondingMethod · 0.95
AwaitBackendStateMethod · 0.95
MustStatusMethod · 0.95
TailscaleMethod · 0.95
ParallelFunction · 0.92
NewTestEnvFunction · 0.85
NewTestNodeFunction · 0.85
TextMethod · 0.80
ContainsFuncMethod · 0.80
CombinedOutputMethod · 0.80
MustCleanShutdownMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…