Skip to content

Commit 14af7f6

Browse files
authored
Merge pull request #3318 from Ankitasw/bastion-e2e-test
[E2E] Test to check if bastion host is running when enabled
2 parents 14ff8fc + 0dfa65b commit 14af7f6

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

test/e2e/data/infrastructure-aws/kustomize_sources/nested-multitenancy/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ resources:
33
- role.yaml
44
patchesStrategicMerge:
55
- patches/role-identity.yaml
6+
- patches/bastion-enabled.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
3+
kind: AWSCluster
4+
metadata:
5+
name: "${CLUSTER_NAME}"
6+
spec:
7+
bastion:
8+
enabled: true

test/e2e/suites/unmanaged/helpers_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import (
5353
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1"
5454
"sigs.k8s.io/cluster-api/test/framework"
5555
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
56+
"sigs.k8s.io/cluster-api/util/conditions"
5657
)
5758

5859
type statefulSetInfo struct {
@@ -674,3 +675,22 @@ func LatestCIReleaseForVersion(searchVersion string) (string, error) {
674675

675676
return strings.TrimSpace(string(b)), nil
676677
}
678+
679+
type conditionAssertion struct {
680+
conditionType clusterv1.ConditionType
681+
status corev1.ConditionStatus
682+
severity clusterv1.ConditionSeverity
683+
reason string
684+
}
685+
686+
func expectAWSClusterConditions(m *infrav1.AWSCluster, expected []conditionAssertion) {
687+
Expect(len(m.Status.Conditions)).To(BeNumerically(">=", len(expected)), "number of conditions")
688+
for _, c := range expected {
689+
actual := conditions.Get(m, c.conditionType)
690+
Expect(actual).To(Not(BeNil()))
691+
Expect(actual.Type).To(Equal(c.conditionType))
692+
Expect(actual.Status).To(Equal(c.status))
693+
Expect(actual.Severity).To(Equal(c.severity))
694+
Expect(actual.Reason).To(Equal(c.reason))
695+
}
696+
}

test/e2e/suites/unmanaged/unmanaged_functional_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
136136
WaitForControlPlaneIntervals: e2eCtx.E2EConfig.GetIntervals(specName, "wait-control-plane"),
137137
}, result)
138138

139+
// Check if bastion host is up and running
140+
awsCluster, err := GetAWSClusterByName(ctx, namespace.Name, clusterName)
141+
Expect(err).To(BeNil())
142+
Expect(awsCluster.Status.Bastion.State).To(Equal(infrav1.InstanceStateRunning))
143+
expectAWSClusterConditions(awsCluster, []conditionAssertion{{infrav1.BastionHostReadyCondition, corev1.ConditionTrue, "", ""}})
139144
ginkgo.By("PASSED!")
140145
})
141146
})

0 commit comments

Comments
 (0)