Skip to content

Commit

Permalink
Fix unit test flaky for IPsec controller (antrea-io#4016)
Browse files Browse the repository at this point in the history
Wait one second as the fake clientset doesn't support watching with specific resourceVersion.
Otherwise the update event would be missed by the watcher used in csrutil.WaitForCertificate()
if it happens to be generated in-between the List and Watch calls.

Fixes: antrea-io#3851

Signed-off-by: Xu Liu <[email protected]>
  • Loading branch information
xliuxu authored and hjiajing committed Jul 28, 2022
1 parent 50db08f commit 87ff3b9
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ func signCSR(t *testing.T, controller *fakeController,
assert.Empty(t, remain)
req, err := x509.ParseCertificateRequest(block.Bytes)
assert.NoError(t, err)

// Wait one second as the fake clientset doesn't support watching with specific resourceVersion.
// Otherwise the update event would be missed by the watcher used in csrutil.WaitForCertificate()
// if it happens to be generated in-between the List and Watch calls.
time.Sleep(1 * time.Second)

newCert := createCertificate(t, req.Subject.CommonName, controller.caCert,
controller.caKey, req.PublicKey, csr.CreationTimestamp.Time, expirationDuration)
toUpdate := csr.DeepCopy()
Expand All @@ -369,6 +375,7 @@ func signCSR(t *testing.T, controller *fakeController,
_, err = controller.kubeClient.CertificatesV1().CertificateSigningRequests().
UpdateStatus(context.TODO(), toUpdate, metav1.UpdateOptions{})
assert.NoError(t, err)
t.Logf("Sign CSR %q successfully", csr.Name)
}

func Test_jitteryDuration(t *testing.T) {
Expand Down

0 comments on commit 87ff3b9

Please sign in to comment.