(t *testing.T)
| 2459 | } |
| 2460 | |
| 2461 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…