Skip to content

Commit

Permalink
deflake kube-root-ca.crt e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
zshihang committed Nov 5, 2020
1 parent eca5350 commit 3de3a75
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/e2e/auth/service_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,12 @@ var _ = SIGDescribe("ServiceAccounts", func() {
})

ginkgo.It("should guarantee kube-root-ca.crt exist in any namespace", func() {
const rootCAConfigMapName = "kube-root-ca.crt"
const (
rootCAConfigMapName = "kube-root-ca.crt"
timeout = time.Minute
)

framework.ExpectNoError(wait.PollImmediate(500*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) {
framework.ExpectNoError(wait.PollImmediate(500*time.Millisecond, timeout, func() (bool, error) {
_, err := f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Get(context.TODO(), rootCAConfigMapName, metav1.GetOptions{})
if err == nil {
return true, nil
Expand All @@ -876,8 +879,7 @@ var _ = SIGDescribe("ServiceAccounts", func() {
framework.ExpectNoError(f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Delete(context.TODO(), rootCAConfigMapName, metav1.DeleteOptions{GracePeriodSeconds: utilptr.Int64Ptr(0)}))
framework.Logf("Deleted root ca configmap in namespace %q", f.Namespace.Name)

framework.ExpectNoError(wait.Poll(500*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) {
ginkgo.By("waiting for a new root ca configmap created")
framework.ExpectNoError(wait.Poll(500*time.Millisecond, timeout, func() (bool, error) {
_, err := f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Get(context.TODO(), rootCAConfigMapName, metav1.GetOptions{})
if err == nil {
return true, nil
Expand All @@ -901,7 +903,7 @@ var _ = SIGDescribe("ServiceAccounts", func() {
framework.ExpectNoError(err)
framework.Logf("Updated root ca configmap in namespace %q", f.Namespace.Name)

framework.ExpectNoError(wait.Poll(500*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) {
framework.ExpectNoError(wait.Poll(500*time.Millisecond, timeout, func() (bool, error) {
ginkgo.By("waiting for the root ca configmap reconciled")
cm, err := f.ClientSet.CoreV1().ConfigMaps(f.Namespace.Name).Get(context.TODO(), rootCAConfigMapName, metav1.GetOptions{})
if err != nil {
Expand Down

0 comments on commit 3de3a75

Please sign in to comment.