Skip to content

Commit cf9faa5

Browse files
committed
fix: add eventually for bastion ready
Adds an eventually check around the bastion status check. Signed-off-by: Richard Case <[email protected]>
1 parent 8a0adec commit cf9faa5

File tree

3 files changed

+75
-9
lines changed

3 files changed

+75
-9
lines changed

test/e2e/suites/unmanaged/helpers_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,33 @@ func expectAWSClusterConditions(m *infrav1.AWSCluster, expected []conditionAsser
426426
}
427427
}
428428

429+
func hasAWSClusterConditions(m *infrav1.AWSCluster, expected []conditionAssertion) bool {
430+
if len(m.Status.Conditions) < len(expected) {
431+
return false
432+
}
433+
for _, c := range expected {
434+
actual := conditions.Get(m, c.conditionType)
435+
if actual == nil {
436+
return false
437+
}
438+
439+
if actual.Type != c.conditionType {
440+
return false
441+
}
442+
if actual.Status != c.status {
443+
return false
444+
}
445+
if actual.Severity != c.severity {
446+
return false
447+
}
448+
if actual.Reason != c.reason {
449+
return false
450+
}
451+
}
452+
453+
return true
454+
}
455+
429456
func createEFS() *efs.FileSystemDescription {
430457
efs, err := shared.CreateEFS(e2eCtx, string(uuid.NewUUID()))
431458
Expect(err).NotTo(HaveOccurred())

test/e2e/suites/unmanaged/unmanaged_functional_clusterclass_test.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"context"
2424
"fmt"
2525
"path/filepath"
26+
"time"
2627

2728
"github.com/gofrs/flock"
2829
"github.com/onsi/ginkgo/v2"
@@ -81,11 +82,30 @@ var _ = ginkgo.Context("[unmanaged] [functional] [ClusterClass]", func() {
8182
WaitForControlPlaneIntervals: e2eCtx.E2EConfig.GetIntervals(specName, "wait-control-plane"),
8283
}, result)
8384

84-
ginkgo.By("Checking if bastion host is running")
85-
awsCluster, err := GetAWSClusterByName(ctx, e2eCtx.Environment.BootstrapClusterProxy, namespace.Name, clusterName)
86-
Expect(err).To(BeNil())
87-
Expect(awsCluster.Status.Bastion.State).To(Equal(infrav1.InstanceStateRunning))
88-
expectAWSClusterConditions(awsCluster, []conditionAssertion{{infrav1.BastionHostReadyCondition, corev1.ConditionTrue, "", ""}})
85+
Eventually(func(gomega Gomega) (bool, error) {
86+
ginkgo.By("Checking if the bastion is ready")
87+
awsCluster, err := GetAWSClusterByName(ctx, e2eCtx.Environment.BootstrapClusterProxy, namespace.Name, clusterName)
88+
if err != nil {
89+
return false, err
90+
}
91+
if awsCluster.Status.Bastion.State != infrav1.InstanceStateRunning {
92+
shared.Byf("Bastion is not running, state is %s", awsCluster.Status.Bastion.State)
93+
return false, nil
94+
}
95+
96+
if !hasAWSClusterConditions(awsCluster, []conditionAssertion{{infrav1.BastionHostReadyCondition, corev1.ConditionTrue, "", ""}}) {
97+
ginkgo.By("AWSCluster missing bastion host ready condition")
98+
return false, nil
99+
}
100+
101+
return true, nil
102+
}, 15*time.Minute, 30*time.Second).Should(BeTrue(), "Should've eventually succeeded creating bastion host")
103+
104+
// ginkgo.By("Checking if bastion host is running")
105+
// awsCluster, err := GetAWSClusterByName(ctx, e2eCtx.Environment.BootstrapClusterProxy, namespace.Name, clusterName)
106+
// Expect(err).To(BeNil())
107+
// Expect(awsCluster.Status.Bastion.State).To(Equal(infrav1.InstanceStateRunning))
108+
// expectAWSClusterConditions(awsCluster, []conditionAssertion{{infrav1.BastionHostReadyCondition, corev1.ConditionTrue, "", ""}})
89109

90110
ginkgo.By("PASSED!")
91111
})

test/e2e/suites/unmanaged/unmanaged_functional_test.go

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,29 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
204204
}, result)
205205

206206
// Check if bastion host is up and running
207-
awsCluster, err := GetAWSClusterByName(ctx, e2eCtx.Environment.BootstrapClusterProxy, namespace.Name, clusterName)
208-
Expect(err).To(BeNil())
209-
Expect(awsCluster.Status.Bastion.State).To(Equal(infrav1.InstanceStateRunning))
210-
expectAWSClusterConditions(awsCluster, []conditionAssertion{{infrav1.BastionHostReadyCondition, corev1.ConditionTrue, "", ""}})
207+
Eventually(func(gomega Gomega) (bool, error) {
208+
ginkgo.By("Checking if the bastion is ready")
209+
awsCluster, err := GetAWSClusterByName(ctx, e2eCtx.Environment.BootstrapClusterProxy, namespace.Name, clusterName)
210+
if err != nil {
211+
return false, err
212+
}
213+
if awsCluster.Status.Bastion.State != infrav1.InstanceStateRunning {
214+
shared.Byf("Bastion is not running, state is %s", awsCluster.Status.Bastion.State)
215+
return false, nil
216+
}
217+
218+
if !hasAWSClusterConditions(awsCluster, []conditionAssertion{{infrav1.BastionHostReadyCondition, corev1.ConditionTrue, "", ""}}) {
219+
ginkgo.By("AWSCluster missing bastion host ready condition")
220+
return false, nil
221+
}
222+
223+
return true, nil
224+
}, 15*time.Minute, 30*time.Second).Should(BeTrue(), "Should've eventually succeeded creating bastion host")
225+
226+
// awsCluster, err := GetAWSClusterByName(ctx, e2eCtx.Environment.BootstrapClusterProxy, namespace.Name, clusterName)
227+
// Expect(err).To(BeNil())
228+
// Expect(awsCluster.Status.Bastion.State).To(Equal(infrav1.InstanceStateRunning))
229+
// expectAWSClusterConditions(awsCluster, []conditionAssertion{{infrav1.BastionHostReadyCondition, corev1.ConditionTrue, "", ""}})
211230

212231
mdName := clusterName + "-md01"
213232
machineTempalte := makeAWSMachineTemplate(namespace.Name, mdName, e2eCtx.E2EConfig.GetVariable(shared.AwsNodeMachineType), nil)

0 commit comments

Comments
 (0)