Fix cache modification + cert flake in e2e tests

Signed-off-by: Jake Sanders <i@am.so-aweso.me>
This commit is contained in:
Jake Sanders 2021-07-27 09:48:07 +01:00
parent fc428d763e
commit 85cb26e3c5
No known key found for this signature in database
GPG Key ID: 7E708D7933B84690
2 changed files with 27 additions and 15 deletions

View File

@ -32,6 +32,7 @@ go_library(
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
"@io_k8s_apimachinery//pkg/util/intstr:go_default_library",
"@io_k8s_apimachinery//pkg/util/wait:go_default_library",
"@io_k8s_client_go//util/retry:go_default_library",
"@io_k8s_utils//pointer:go_default_library",
],
)

View File

@ -21,12 +21,20 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
networkingv1beta1 "k8s.io/api/networking/v1beta1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
"strings"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
networkingv1beta1 "k8s.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/util/retry"
"k8s.io/utils/pointer"
cmacme "github.com/jetstack/cert-manager/pkg/apis/acme/v1"
v1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1"
@ -38,12 +46,6 @@ import (
"github.com/jetstack/cert-manager/test/e2e/util"
e2eutil "github.com/jetstack/cert-manager/test/e2e/util"
"github.com/jetstack/cert-manager/test/unit/gen"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
)
const foreverTestTimeout = time.Second * 60
@ -175,13 +177,22 @@ var _ = framework.CertManagerDescribe("ACME Certificate (HTTP01)", func() {
_, err = f.Helper().WaitForCertificateNotReadyUpdate(cert, 30*time.Second)
Expect(err).NotTo(HaveOccurred())
By("Getting the latest version of the Certificate")
cert, err = certClient.Get(context.TODO(), certificateName, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
By("Getting the latest version of the Certificate")
cert, err = certClient.Get(context.TODO(), certificateName, metav1.GetOptions{})
if err != nil {
return err
}
By("Replacing dnsNames with a valid dns name")
cert.Spec.DNSNames = []string{e2eutil.RandomSubdomain(acmeIngressDomain)}
_, err = certClient.Update(context.TODO(), cert, metav1.UpdateOptions{})
By("Replacing dnsNames with a valid dns name")
cert = cert.DeepCopy()
cert.Spec.DNSNames = []string{e2eutil.RandomSubdomain(acmeIngressDomain)}
_, err = certClient.Update(context.TODO(), cert, metav1.UpdateOptions{})
if err != nil {
return err
}
return nil
})
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to have the Ready=True condition")