Skip to content

Commit

Permalink
e2e: deploy a bastion in its own test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
EmilienM committed Jan 11, 2024
1 parent 5440246 commit 1c6082c
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 8 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ e2e-templates: $(addprefix $(E2E_NO_ARTIFACT_TEMPLATES_DIR)/, \
cluster-template-multi-az.yaml \
cluster-template-multi-network.yaml \
cluster-template-without-lb.yaml \
cluster-template-bastion-no-worker.yaml \
cluster-template.yaml \
cluster-template-flatcar.yaml \
cluster-template-k8s-upgrade.yaml \
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/data/kustomize/bastion-no-worker/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../default

patches:
- path: patch-bastion.yaml
target:
kind: OpenStackCluster
name: \${CLUSTER_NAME}
9 changes: 9 additions & 0 deletions test/e2e/data/kustomize/bastion-no-worker/patch-bastion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- op: add
path: /spec/bastion
value:
enabled: true
instance:
flavor: ${OPENSTACK_BASTION_MACHINE_FLAVOR}
image: ${OPENSTACK_BASTION_IMAGE_NAME}
sshKeyName: ${OPENSTACK_SSH_KEY_NAME}
8 changes: 0 additions & 8 deletions test/e2e/data/kustomize/common-patches/cni/patch-cluster.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
---
- op: add
path: /spec/bastion
value:
enabled: true
instance:
flavor: ${OPENSTACK_BASTION_MACHINE_FLAVOR}
image: ${OPENSTACK_BASTION_IMAGE_NAME}
sshKeyName: ${OPENSTACK_SSH_KEY_NAME}
- op: add
path: /spec/controlPlaneAvailabilityZones
value:
Expand Down
1 change: 1 addition & 0 deletions test/e2e/shared/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const (
FlavorFlatcar = "flatcar"
FlavorKubernetesUpgrade = "k8s-upgrade"
FlavorFlatcarSysext = "flatcar-sysext"
FlavorBastionNoWorker = "bastion-no-worker"
)

// DefaultScheme returns the default scheme to use for testing.
Expand Down
55 changes: 55 additions & 0 deletions test/e2e/suites/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,61 @@ var _ = Describe("e2e tests [PR-Blocking]", func() {
})
})

Describe("Workload cluster (with bastion and no workers)", func() {
It("should be creatable and deletable", func() {
shared.Logf("Creating a cluster")
clusterName := fmt.Sprintf("cluster-%s", namespace.Name)
configCluster := defaultConfigCluster(clusterName, namespace.Name)
configCluster.ControlPlaneMachineCount = pointer.Int64(1)
configCluster.WorkerMachineCount = pointer.Int64(0)
configCluster.Flavor = shared.FlavorBastionNoWorker
createCluster(ctx, configCluster, clusterResources)

controlPlaneMachines := framework.GetControlPlaneMachinesByCluster(ctx, framework.GetControlPlaneMachinesByClusterInput{
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
ClusterName: clusterName,
Namespace: namespace.Name,
})
Expect(controlPlaneMachines).To(HaveLen(1))

workloadCluster := e2eCtx.Environment.BootstrapClusterProxy.GetWorkloadCluster(ctx, namespace.Name, clusterName)

waitForDaemonSetRunning(ctx, workloadCluster.GetClient(), "kube-system", "openstack-cloud-controller-manager")

waitForNodesReadyWithoutCCMTaint(ctx, workloadCluster.GetClient(), 1)

// We expect a control plane machine and a bastion host
allServers, err := shared.DumpOpenStackServers(e2eCtx, servers.ListOpts{})
Expect(err).NotTo(HaveOccurred())
Expect(allServers).To(HaveLen(2))

// When listing servers with multiple tags, nova api requires a single, comma-separated string
// with all the tags
controlPlaneTags := fmt.Sprintf("%s,%s", clusterName, "control-plane")
controlPlaneServers, err := shared.DumpOpenStackServers(e2eCtx, servers.ListOpts{Tags: controlPlaneTags})
Expect(err).NotTo(HaveOccurred())
Expect(controlPlaneServers).To(HaveLen(1))

networksList, err := shared.DumpOpenStackNetworks(e2eCtx, networks.ListOpts{Tags: clusterName})
Expect(err).NotTo(HaveOccurred())
Expect(networksList).To(HaveLen(1))

subnetsList, err := shared.DumpOpenStackSubnets(e2eCtx, subnets.ListOpts{Tags: clusterName})
Expect(err).NotTo(HaveOccurred())
Expect(subnetsList).To(HaveLen(1))

routersList, err := shared.DumpOpenStackRouters(e2eCtx, routers.ListOpts{Tags: clusterName})
Expect(err).NotTo(HaveOccurred())
Expect(routersList).To(HaveLen(1))

securityGroupsList, err := shared.DumpOpenStackSecurityGroups(e2eCtx, groups.ListOpts{Tags: clusterName})
Expect(err).NotTo(HaveOccurred())
Expect(securityGroupsList).To(HaveLen(3))

// Here we want to test the part where we change the bastion spec and want to check
// that the new bastion is created with the new spec and the old one is deleted.
})
})
Describe("MachineDeployment misconfigurations", func() {
It("should fail to create MachineDeployment with invalid subnet or invalid availability zone", func() {
shared.Logf("Creating a cluster")
Expand Down

0 comments on commit 1c6082c

Please sign in to comment.