Skip to content

Commit 0c3a1ae

Browse files
committed
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.
1 parent cbc46d1 commit 0c3a1ae

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ca/bootstrap_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,13 @@ func doReload(ca *CA) error {
606606
}
607607
// Use same address in new server
608608
newCA.srv.Addr = ca.srv.Addr
609-
return ca.srv.Reload(newCA.srv)
609+
if err := ca.srv.Reload(newCA.srv); err != nil {
610+
return err
611+
}
612+
613+
// Wait a few ms until the http server calls listener.Accept()
614+
time.Sleep(100 * time.Millisecond)
615+
return nil
610616
}
611617

612618
func TestBootstrapListener(t *testing.T) {

0 commit comments

Comments
 (0)