From 2a8e93b5788238b970edb649724b497ff35d7c08 Mon Sep 17 00:00:00 2001 From: Jestin Woods Date: Thu, 30 Nov 2023 08:04:46 -0800 Subject: [PATCH] fix tests --- controllers/suite/common.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/controllers/suite/common.go b/controllers/suite/common.go index bbe0d0fe3..27ea6b659 100644 --- a/controllers/suite/common.go +++ b/controllers/suite/common.go @@ -293,8 +293,14 @@ func CreateAndBootstrapCluster(ctx context.Context, k8sClient client.Client, hum if os.Getenv("TEST_USE_EXISTING_CLUSTER") == "true" { UsingClusterBy(key.Name, "Wait for HumioCluster Controller to create the HumioBootstrapToken") Eventually(func() error { - var updatedHumioBootstrapToken humiov1alpha1.HumioBootstrapToken - return k8sClient.Get(ctx, bootstrapTokenKey, &updatedHumioBootstrapToken) + hbtList, err := kubernetes.ListHumioBootstrapTokens(ctx, k8sClient, key.Namespace, kubernetes.LabelsForHumioBootstrapToken(key.Name)) + if err != nil { + return err + } + if len(hbtList) > 0 { + return nil + } + return fmt.Errorf("no humiobootstraptokens for cluster %s", key.Name) }, testTimeout, TestInterval).Should(Succeed()) } else { // Simulate sidecar creating the secret which contains the admin token used to authenticate with humio @@ -340,8 +346,16 @@ func CreateAndBootstrapCluster(ctx context.Context, k8sClient client.Client, hum UsingClusterBy(key.Name, "Simulating HumioBootstrapToken Controller running and adding the secret and status") Eventually(func() error { - var updatedHumioBootstrapToken humiov1alpha1.HumioBootstrapToken - err := k8sClient.Get(ctx, bootstrapTokenKey, &updatedHumioBootstrapToken) + hbtList, err := kubernetes.ListHumioBootstrapTokens(ctx, k8sClient, key.Namespace, kubernetes.LabelsForHumioBootstrapToken(key.Name)) + if err != nil { + return err + } + if len(hbtList) == 0 { + return fmt.Errorf("no humiobootstraptokens for cluster %s", key.Name) + } + + updatedHumioBootstrapToken := hbtList[0] + err = k8sClient.Get(ctx, bootstrapTokenKey, &updatedHumioBootstrapToken) if err != nil { return err }