Skip to content

Commit

Permalink
Merge pull request #3318 from Ankitasw/bastion-e2e-test
Browse files Browse the repository at this point in the history
[E2E] Test to check if bastion host is running when enabled
  • Loading branch information
k8s-ci-robot committed Mar 17, 2022
2 parents 14ff8fc + 0dfa65b commit 14af7f6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ resources:
- role.yaml
patchesStrategicMerge:
- patches/role-identity.yaml
- patches/bastion-enabled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AWSCluster
metadata:
name: "${CLUSTER_NAME}"
spec:
bastion:
enabled: true
20 changes: 20 additions & 0 deletions test/e2e/suites/unmanaged/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1"
"sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
"sigs.k8s.io/cluster-api/util/conditions"
)

type statefulSetInfo struct {
Expand Down Expand Up @@ -674,3 +675,22 @@ func LatestCIReleaseForVersion(searchVersion string) (string, error) {

return strings.TrimSpace(string(b)), nil
}

type conditionAssertion struct {
conditionType clusterv1.ConditionType
status corev1.ConditionStatus
severity clusterv1.ConditionSeverity
reason string
}

func expectAWSClusterConditions(m *infrav1.AWSCluster, expected []conditionAssertion) {
Expect(len(m.Status.Conditions)).To(BeNumerically(">=", len(expected)), "number of conditions")
for _, c := range expected {
actual := conditions.Get(m, c.conditionType)
Expect(actual).To(Not(BeNil()))
Expect(actual.Type).To(Equal(c.conditionType))
Expect(actual.Status).To(Equal(c.status))
Expect(actual.Severity).To(Equal(c.severity))
Expect(actual.Reason).To(Equal(c.reason))
}
}
5 changes: 5 additions & 0 deletions test/e2e/suites/unmanaged/unmanaged_functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ var _ = ginkgo.Context("[unmanaged] [functional]", func() {
WaitForControlPlaneIntervals: e2eCtx.E2EConfig.GetIntervals(specName, "wait-control-plane"),
}, result)

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

0 comments on commit 14af7f6

Please sign in to comment.