Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jswoods committed Nov 30, 2023
1 parent 5372603 commit 2a8e93b
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions controllers/suite/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 2a8e93b

Please sign in to comment.