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