Skip to content

Commit 90aca96

Browse files
committed
e2e: deploy a bastion in its own test
Deploying a bastion consumes resources so we now do it in a single test: `bastion-no-worker`. From now, the rest of the tests won't have a bastion node.
1 parent 88dcecf commit 90aca96

File tree

6 files changed

+76
-9
lines changed

6 files changed

+76
-9
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ e2e-templates: $(addprefix $(E2E_NO_ARTIFACT_TEMPLATES_DIR)/, \
156156
cluster-template-multi-az.yaml \
157157
cluster-template-multi-network.yaml \
158158
cluster-template-without-lb.yaml \
159+
cluster-template-bastion-no-worker.yaml \
159160
cluster-template.yaml \
160161
cluster-template-flatcar.yaml \
161162
cluster-template-k8s-upgrade.yaml \
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- ../default
5+
6+
patches:
7+
- path: patch-bastion.yaml
8+
target:
9+
kind: OpenStackCluster
10+
name: \${CLUSTER_NAME}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- op: add
3+
path: /spec/bastion
4+
value:
5+
enabled: true
6+
instance:
7+
flavor: ${OPENSTACK_BASTION_MACHINE_FLAVOR}
8+
image: ${OPENSTACK_BASTION_IMAGE_NAME}
9+
sshKeyName: ${OPENSTACK_SSH_KEY_NAME}

test/e2e/data/kustomize/common-patches/cni/patch-cluster.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
---
2-
- op: add
3-
path: /spec/bastion
4-
value:
5-
enabled: true
6-
instance:
7-
flavor: ${OPENSTACK_BASTION_MACHINE_FLAVOR}
8-
image:
9-
name: ${OPENSTACK_BASTION_IMAGE_NAME}
10-
sshKeyName: ${OPENSTACK_SSH_KEY_NAME}
112
- op: add
123
path: /spec/controlPlaneAvailabilityZones
134
value:

test/e2e/shared/defaults.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const (
5656
FlavorFlatcar = "flatcar"
5757
FlavorKubernetesUpgrade = "k8s-upgrade"
5858
FlavorFlatcarSysext = "flatcar-sysext"
59+
FlavorBastionNoWorker = "bastion-no-worker"
5960
)
6061

6162
// DefaultScheme returns the default scheme to use for testing.

test/e2e/suites/e2e/e2e_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,61 @@ var _ = Describe("e2e tests [PR-Blocking]", func() {
465465
})
466466
})
467467

468+
Describe("Workload cluster (with bastion and no workers)", func() {
469+
It("should be creatable and deletable", func() {
470+
shared.Logf("Creating a cluster")
471+
clusterName := fmt.Sprintf("cluster-%s", namespace.Name)
472+
configCluster := defaultConfigCluster(clusterName, namespace.Name)
473+
configCluster.ControlPlaneMachineCount = pointer.Int64(1)
474+
configCluster.WorkerMachineCount = pointer.Int64(0)
475+
configCluster.Flavor = shared.FlavorBastionNoWorker
476+
createCluster(ctx, configCluster, clusterResources)
477+
478+
controlPlaneMachines := framework.GetControlPlaneMachinesByCluster(ctx, framework.GetControlPlaneMachinesByClusterInput{
479+
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
480+
ClusterName: clusterName,
481+
Namespace: namespace.Name,
482+
})
483+
Expect(controlPlaneMachines).To(HaveLen(1))
484+
485+
workloadCluster := e2eCtx.Environment.BootstrapClusterProxy.GetWorkloadCluster(ctx, namespace.Name, clusterName)
486+
487+
// waitForDaemonSetRunning(ctx, workloadCluster.GetClient(), "kube-system", "openstack-cloud-controller-manager")
488+
489+
waitForNodesReadyWithoutCCMTaint(ctx, workloadCluster.GetClient(), 1)
490+
491+
// We expect a control plane machine and a bastion host
492+
allServers, err := shared.DumpOpenStackServers(e2eCtx, servers.ListOpts{})
493+
Expect(err).NotTo(HaveOccurred())
494+
Expect(allServers).To(HaveLen(2))
495+
496+
// When listing servers with multiple tags, nova api requires a single, comma-separated string
497+
// with all the tags
498+
controlPlaneTags := fmt.Sprintf("%s,%s", clusterName, "control-plane")
499+
controlPlaneServers, err := shared.DumpOpenStackServers(e2eCtx, servers.ListOpts{Tags: controlPlaneTags})
500+
Expect(err).NotTo(HaveOccurred())
501+
Expect(controlPlaneServers).To(HaveLen(1))
502+
503+
networksList, err := shared.DumpOpenStackNetworks(e2eCtx, networks.ListOpts{Tags: clusterName})
504+
Expect(err).NotTo(HaveOccurred())
505+
Expect(networksList).To(HaveLen(1))
506+
507+
subnetsList, err := shared.DumpOpenStackSubnets(e2eCtx, subnets.ListOpts{Tags: clusterName})
508+
Expect(err).NotTo(HaveOccurred())
509+
Expect(subnetsList).To(HaveLen(1))
510+
511+
routersList, err := shared.DumpOpenStackRouters(e2eCtx, routers.ListOpts{Tags: clusterName})
512+
Expect(err).NotTo(HaveOccurred())
513+
Expect(routersList).To(HaveLen(1))
514+
515+
securityGroupsList, err := shared.DumpOpenStackSecurityGroups(e2eCtx, groups.ListOpts{Tags: clusterName})
516+
Expect(err).NotTo(HaveOccurred())
517+
Expect(securityGroupsList).To(HaveLen(3))
518+
519+
// Here we want to test the part where we change the bastion spec and want to check
520+
// that the new bastion is created with the new spec and the old one is deleted.
521+
})
522+
})
468523
Describe("MachineDeployment misconfigurations", func() {
469524
It("should fail to create MachineDeployment with invalid subnet or invalid availability zone", func() {
470525
shared.Logf("Creating a cluster")

0 commit comments

Comments
 (0)