Prechádzať zdrojové kódy

cmd/tailscaled: add TS_DEBUG_BACKEND_DELAY_SEC for testing async startup

This adds an envknob to make testing async startup more reproducible.
We want the Windows GUI to behave well when wintun is not (or it's
doing its initial slow driver installation), but during testing it's often
too fast to see that it's working. This lets it be slowed down.

Updates #6522

Change-Id: I6ae19f46e270ea679cbaea32a53888efcf2943a7
Signed-off-by: Brad Fitzpatrick <[email protected]>
Brad Fitzpatrick 3 rokov pred
rodič
commit
0a10a5632b
1 zmenil súbory, kde vykonal 10 pridanie a 0 odobranie
  1. 10 0
      cmd/tailscaled/tailscaled.go

+ 10 - 0
cmd/tailscaled/tailscaled.go

@@ -416,6 +416,16 @@ func startIPNServer(ctx context.Context, logf logger.Logf, logid string) error {
 
 	go func() {
 		t0 := time.Now()
+		if s, ok := envknob.LookupInt("TS_DEBUG_BACKEND_DELAY_SEC"); ok {
+			d := time.Duration(s) * time.Second
+			logf("sleeping %v before starting backend...", d)
+			select {
+			case <-time.After(d):
+				logf("slept %v; starting backend...", d)
+			case <-ctx.Done():
+				return
+			}
+		}
 		lb, err := getLocalBackend(ctx, logf, logid)
 		if err == nil {
 			logf("got LocalBackend in %v", time.Since(t0).Round(time.Millisecond))