Skip to content

Commit 2837b29

Browse files
committed
Add a No Bastion e2e test
1 parent 4cf3c1b commit 2837b29

File tree

6 files changed

+101
-45
lines changed

6 files changed

+101
-45
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ e2e-templates: $(addprefix $(E2E_NO_ARTIFACT_TEMPLATES_DIR)/, \
161161
cluster-template.yaml \
162162
cluster-template-flatcar.yaml \
163163
cluster-template-k8s-upgrade.yaml \
164-
cluster-template-flatcar-sysext.yaml)
164+
cluster-template-flatcar-sysext.yaml \
165+
cluster-template-no-bastion.yaml)
165166
# Currently no templates that require CI artifacts
166167
# $(addprefix $(E2E_TEMPLATES_DIR)/, add-templates-here.yaml) \
167168
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- ../default
6+
7+
patches:
8+
- path: patch-no-bastion.yaml
9+
target:
10+
kind: OpenStackCluster
11+
name: \${CLUSTER_NAME}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
- op: remove
3+
path: /spec/bastion

test/e2e/shared/common.go

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -214,51 +214,55 @@ func (o OpenStackLogCollector) CollectMachineLog(ctx context.Context, management
214214
return fmt.Errorf("error writing server JSON %s: %s", serverJSON, err)
215215
}
216216

217-
srvUser := o.E2EContext.E2EConfig.GetVariable(SSHUserMachine)
218-
executeCommands(
219-
ctx,
220-
o.E2EContext.Settings.ArtifactFolder,
221-
o.E2EContext.Settings.Debug,
222-
outputPath,
223-
ip,
224-
openStackCluster.Status.Bastion.FloatingIP,
225-
srvUser,
226-
[]command{
227-
// don't do this for now, it just takes to long
228-
// {
229-
// title: "systemd",
230-
// cmd: "journalctl --no-pager --output=short-precise | grep -v 'audit:\\|audit\\['",
231-
// },
232-
{
233-
title: "kern",
234-
cmd: "journalctl --no-pager --output=short-precise -k",
217+
if openStackCluster.Status.Bastion == nil {
218+
Logf("Skipping log collection for machine %q since no bastion is available", m.Name)
219+
} else {
220+
srvUser := o.E2EContext.E2EConfig.GetVariable(SSHUserMachine)
221+
executeCommands(
222+
ctx,
223+
o.E2EContext.Settings.ArtifactFolder,
224+
o.E2EContext.Settings.Debug,
225+
outputPath,
226+
ip,
227+
openStackCluster.Status.Bastion.FloatingIP,
228+
srvUser,
229+
[]command{
230+
// don't do this for now, it just takes to long
231+
// {
232+
// title: "systemd",
233+
// cmd: "journalctl --no-pager --output=short-precise | grep -v 'audit:\\|audit\\['",
234+
// },
235+
{
236+
title: "kern",
237+
cmd: "journalctl --no-pager --output=short-precise -k",
238+
},
239+
{
240+
title: "containerd-info",
241+
cmd: "crictl --runtime-endpoint unix:///run/containerd/containerd.sock info",
242+
},
243+
{
244+
title: "containerd-containers",
245+
cmd: "crictl --runtime-endpoint unix:///run/containerd/containerd.sock ps",
246+
},
247+
{
248+
title: "containerd-pods",
249+
cmd: "crictl --runtime-endpoint unix:///run/containerd/containerd.sock pods",
250+
},
251+
{
252+
title: "cloud-final",
253+
cmd: "journalctl --no-pager -u cloud-final",
254+
},
255+
{
256+
title: "kubelet",
257+
cmd: "journalctl --no-pager -u kubelet.service",
258+
},
259+
{
260+
title: "containerd",
261+
cmd: "journalctl --no-pager -u containerd.service",
262+
},
235263
},
236-
{
237-
title: "containerd-info",
238-
cmd: "crictl --runtime-endpoint unix:///run/containerd/containerd.sock info",
239-
},
240-
{
241-
title: "containerd-containers",
242-
cmd: "crictl --runtime-endpoint unix:///run/containerd/containerd.sock ps",
243-
},
244-
{
245-
title: "containerd-pods",
246-
cmd: "crictl --runtime-endpoint unix:///run/containerd/containerd.sock pods",
247-
},
248-
{
249-
title: "cloud-final",
250-
cmd: "journalctl --no-pager -u cloud-final",
251-
},
252-
{
253-
title: "kubelet",
254-
cmd: "journalctl --no-pager -u kubelet.service",
255-
},
256-
{
257-
title: "containerd",
258-
cmd: "journalctl --no-pager -u containerd.service",
259-
},
260-
},
261-
)
264+
)
265+
}
262266
return nil
263267
}
264268

test/e2e/shared/defaults.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const (
4646
OpenStackNodeMachineFlavor = "OPENSTACK_NODE_MACHINE_FLAVOR"
4747
SSHUserMachine = "SSH_USER_MACHINE"
4848
FlavorDefault = ""
49+
FlavorNoBastion = "no-bastion"
4950
FlavorWithoutLB = "without-lb"
5051
FlavorMultiNetwork = "multi-network"
5152
FlavorMultiAZ = "multi-az"

test/e2e/suites/e2e/e2e_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,42 @@ var _ = Describe("e2e tests [PR-Blocking]", func() {
245245
})
246246
})
247247

248+
Describe("Workload cluster (no bastion)", func() {
249+
It("should be creatable and deletable", func() {
250+
shared.Logf("Creating a cluster")
251+
clusterName := fmt.Sprintf("cluster-%s", namespace.Name)
252+
configCluster := defaultConfigCluster(clusterName, namespace.Name)
253+
configCluster.ControlPlaneMachineCount = ptr.To(int64(1))
254+
configCluster.WorkerMachineCount = ptr.To(int64(1))
255+
configCluster.Flavor = shared.FlavorNoBastion
256+
createCluster(ctx, configCluster, clusterResources)
257+
md := clusterResources.MachineDeployments
258+
259+
workerMachines := framework.GetMachinesByMachineDeployments(ctx, framework.GetMachinesByMachineDeploymentsInput{
260+
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
261+
ClusterName: clusterName,
262+
Namespace: namespace.Name,
263+
MachineDeployment: *md[0],
264+
})
265+
controlPlaneMachines := framework.GetControlPlaneMachinesByCluster(ctx, framework.GetControlPlaneMachinesByClusterInput{
266+
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
267+
ClusterName: clusterName,
268+
Namespace: namespace.Name,
269+
})
270+
Expect(workerMachines).To(HaveLen(1))
271+
Expect(controlPlaneMachines).To(HaveLen(1))
272+
273+
shared.Logf("Waiting for worker nodes to be in Running phase")
274+
statusChecks := []framework.MachineStatusCheck{framework.MachinePhaseCheck(string(clusterv1.MachinePhaseRunning))}
275+
machineStatusInput := framework.WaitForMachineStatusCheckInput{
276+
Getter: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
277+
Machine: &workerMachines[0],
278+
StatusChecks: statusChecks,
279+
}
280+
framework.WaitForMachineStatusCheck(ctx, machineStatusInput, e2eCtx.E2EConfig.GetIntervals(specName, "wait-machine-status")...)
281+
})
282+
})
283+
248284
Describe("Workload cluster (flatcar)", func() {
249285
It("should be creatable and deletable", func() {
250286
// Flatcar default user is "core"

0 commit comments

Comments
 (0)