Skip to content

Commit

Permalink
🌱 Better logging, to find root cause of flaky test. (#1452)
Browse files Browse the repository at this point in the history
  • Loading branch information
guettli authored Aug 19, 2024
1 parent bd6a7c4 commit 472809c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions controllers/hcloudmachine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ limitations under the License.
package controllers

import (
"fmt"
"testing"
"time"

"github.com/hetznercloud/hcloud-go/v2/hcloud"
. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -366,18 +368,23 @@ var _ = Describe("HCloudMachineReconciler", func() {
It("creates the HCloud machine in Hetzner 1 (flaky)", func() {
By("checking that no servers exist")

Eventually(func() bool {
Eventually(func(start time.Time) bool {
servers, err := hcloudClient.ListServers(ctx, hcloud.ServerListOpts{
ListOpts: hcloud.ListOpts{
LabelSelector: utils.LabelsToLabelSelector(map[string]string{hetznerCluster.ClusterTagKey(): "owned"}),
},
})
if err != nil {
fmt.Printf("flaky test. ListServers failed: %s\n", err.Error())
return false
}

return len(servers) == 0
}, 2*timeout, interval).Should(BeTrue())
if len(servers) != 0 {
fmt.Printf("flaky test. There are still servers: %+v\n", servers)
return false
}
fmt.Printf("flaky test. OK after %s\n", time.Since(start).String())
return true
}, 2*timeout, interval).WithArguments(time.Now()).Should(BeTrue())

By("checking that bootstrap condition is not ready")

Expand Down

0 comments on commit 472809c

Please sign in to comment.