Forráskód Böngészése

Wait for Accept in TestBootstrapClientServerRotation

The TestBootstrapClientServerRotation often fails because the reload
returns once the Server loop gets the new listener, but the server
hasn't really started yet. This commit makes the test pass, adding a
small sleep after the reload.

A proper fix might require a wrapper over the listener and an ACK
callback on a sync.Once on a custom Accept.
Mariano Cano 3 éve
szülő
commit
0c3a1aea38
1 módosított fájl, 7 hozzáadás és 1 törlés
  1. 7 1
      ca/bootstrap_test.go

+ 7 - 1
ca/bootstrap_test.go

@@ -606,7 +606,13 @@ func doReload(ca *CA) error {
 	}
 	// Use same address in new server
 	newCA.srv.Addr = ca.srv.Addr
-	return ca.srv.Reload(newCA.srv)
+	if err := ca.srv.Reload(newCA.srv); err != nil {
+		return err
+	}
+
+	// Wait a few ms until the http server calls listener.Accept()
+	time.Sleep(100 * time.Millisecond)
+	return nil
 }
 
 func TestBootstrapListener(t *testing.T) {