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 2a8e93b commit a887b11
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions controllers/suite/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,19 +290,7 @@ func CreateAndBootstrapCluster(ctx context.Context, k8sClient client.Client, hum
Name: bootstrapToken.Name,
}

if os.Getenv("TEST_USE_EXISTING_CLUSTER") == "true" {
UsingClusterBy(key.Name, "Wait for HumioCluster Controller to create the HumioBootstrapToken")
Eventually(func() error {
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 {
if os.Getenv("TEST_USE_EXISTING_CLUSTER") != "true" {
// Simulate sidecar creating the secret which contains the admin token used to authenticate with humio
secretData := map[string][]byte{"token": []byte("")}
adminTokenSecretName := fmt.Sprintf("%s-%s", key.Name, kubernetes.ServiceTokenSecretNameSuffix)
Expand Down Expand Up @@ -353,12 +341,11 @@ func CreateAndBootstrapCluster(ctx context.Context, k8sClient client.Client, hum
if len(hbtList) == 0 {
return fmt.Errorf("no humiobootstraptokens for cluster %s", key.Name)
}
if len(hbtList) > 0 {
return fmt.Errorf("too many humiobootstraptokens for cluster %s. found list : %+v", key.Name, hbtList)
}

updatedHumioBootstrapToken := hbtList[0]
err = k8sClient.Get(ctx, bootstrapTokenKey, &updatedHumioBootstrapToken)
if err != nil {
return err
}
updatedHumioBootstrapToken.Status.State = humiov1alpha1.HumioBootstrapTokenStateReady
updatedHumioBootstrapToken.Status.TokenSecretKeyRef = humiov1alpha1.HumioTokenSecretStatus{
SecretKeyRef: &corev1.SecretKeySelector{
Expand Down

0 comments on commit a887b11

Please sign in to comment.