Skip to content

Commit 0a9bd04

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 0a9bd04

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
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_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)