@@ -11,6 +11,7 @@ import (
1111 . "github.com/onsi/ginkgo/v2"
1212 . "github.com/onsi/gomega"
1313 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14+ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1415 "sigs.k8s.io/cluster-api/cmd/clusterctl/client/config"
1516 capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
1617 framework "sigs.k8s.io/cluster-api/test/framework"
@@ -205,6 +206,41 @@ func preInitFunc(clusterProxy framework.ClusterProxy, bmoRelease string, ironicR
205206 Deployment : deployment ,
206207 }, e2eConfig .GetIntervals (specName , "wait-deployment" )... )
207208 }
209+ // Create an issuer and certificate to ensure that cert-manager is ready.
210+ certManagerTest , err := os .ReadFile ("data/cert-manager-test.yaml" )
211+ Expect (err ).ToNot (HaveOccurred (), "Unable to read cert-manager test YAML file" )
212+ Eventually (func () error {
213+ return clusterProxy .CreateOrUpdate (ctx , certManagerTest )
214+ }, e2eConfig .GetIntervals (specName , "wait-deployment" )... ).Should (Succeed ())
215+ // Wait for and check that the certificate becomes ready.
216+ certKey := client.ObjectKey {
217+ Name : "my-selfsigned-cert" ,
218+ Namespace : "test" ,
219+ }
220+ testCert := new (unstructured.Unstructured )
221+ testCert .SetAPIVersion ("cert-manager.io/v1" )
222+ testCert .SetKind ("Certificate" )
223+ Eventually (func () error {
224+ if err := clusterProxy .GetClient ().Get (ctx , certKey , testCert ); err != nil {
225+ return err
226+ }
227+ conditions , found , err := unstructured .NestedSlice (testCert .Object , "status" , "conditions" )
228+ if err != nil {
229+ return err
230+ }
231+ if ! found {
232+ return fmt .Errorf ("certificate doesn't have status.conditions (yet)" )
233+ }
234+ // There is only one condition (Ready) on certificates.
235+ condType := conditions [0 ].(map [string ]any )["type" ]
236+ condStatus := conditions [0 ].(map [string ]any )["status" ]
237+ if condType == "Ready" && condStatus == "True" {
238+ return nil
239+ }
240+ return fmt .Errorf ("certificate is not ready, type: %s, status: %s, message: %s" , condType , condStatus , conditions [0 ].(map [string ]any )["message" ])
241+ }, e2eConfig .GetIntervals (specName , "wait-deployment" )... ).Should (Succeed ())
242+ // Delete test namespace
243+ Expect (clusterProxy .GetClientSet ().CoreV1 ().Namespaces ().Delete (ctx , "test" , metav1.DeleteOptions {})).To (Succeed ())
208244 }
209245
210246 By ("Fetch manifest for bootstrap cluster" )
0 commit comments