|
|
@@ -84,6 +84,48 @@ func TestOneNodeUp_NoAuth(t *testing.T) {
|
|
|
t.Logf("number of HTTP logcatcher requests: %v", env.LogCatcher.numRequests())
|
|
|
}
|
|
|
|
|
|
+func TestOneNodeExpiredKey(t *testing.T) {
|
|
|
+ t.Skip("Test to exercise a problem which is not fixed yet.")
|
|
|
+ t.Parallel()
|
|
|
+ bins := BuildTestBinaries(t)
|
|
|
+
|
|
|
+ env := newTestEnv(t, bins)
|
|
|
+ defer env.Close()
|
|
|
+
|
|
|
+ n1 := newTestNode(t, env)
|
|
|
+
|
|
|
+ d1 := n1.StartDaemon(t)
|
|
|
+ defer d1.Kill()
|
|
|
+ n1.AwaitResponding(t)
|
|
|
+ n1.MustUp()
|
|
|
+ n1.AwaitRunning(t)
|
|
|
+
|
|
|
+ nodes := env.Control.AllNodes()
|
|
|
+ if len(nodes) != 1 {
|
|
|
+ t.Fatalf("expected 1 node, got %d nodes", len(nodes))
|
|
|
+ }
|
|
|
+
|
|
|
+ nodeKey := nodes[0].Key
|
|
|
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
+ if err := env.Control.AwaitNodeInMapRequest(ctx, nodeKey); err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+ cancel()
|
|
|
+
|
|
|
+ env.Control.SetExpireAllNodes(true)
|
|
|
+ n1.AwaitNeedsLogin(t)
|
|
|
+ ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
+ if err := env.Control.AwaitNodeInMapRequest(ctx, nodeKey); err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+ cancel()
|
|
|
+
|
|
|
+ env.Control.SetExpireAllNodes(false)
|
|
|
+ n1.AwaitRunning(t)
|
|
|
+
|
|
|
+ d1.MustCleanShutdown(t)
|
|
|
+}
|
|
|
+
|
|
|
func TestCollectPanic(t *testing.T) {
|
|
|
t.Parallel()
|
|
|
bins := BuildTestBinaries(t)
|
|
|
@@ -780,6 +822,23 @@ func (n *testNode) AwaitRunning(t testing.TB) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// AwaitNeedsLogin waits for n to reach the IPN state "NeedsLogin".
|
|
|
+func (n *testNode) AwaitNeedsLogin(t testing.TB) {
|
|
|
+ t.Helper()
|
|
|
+ if err := tstest.WaitFor(20*time.Second, func() error {
|
|
|
+ st, err := n.Status()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if st.BackendState != "NeedsLogin" {
|
|
|
+ return fmt.Errorf("in state %q", st.BackendState)
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+ }); err != nil {
|
|
|
+ t.Fatalf("failure/timeout waiting for transition to NeedsLogin status: %v", err)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// Tailscale returns a command that runs the tailscale CLI with the provided arguments.
|
|
|
// It does not start the process.
|
|
|
func (n *testNode) Tailscale(arg ...string) *exec.Cmd {
|