Skip to content

Commit 1e5ba15

Browse files
committed
test(kubernetes): update tests for the control-plane-only chart
Drop pool-render tests; assert no pool objects render; add ingress-nginx guard tests. Signed-off-by: Ivan Okhotnikov <[email protected]>
1 parent 4bd7994 commit 1e5ba15

9 files changed

Lines changed: 175 additions & 1973 deletions

‎packages/apps/kubernetes/tests/cluster_test.yaml‎

Lines changed: 0 additions & 574 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
suite: control-plane-only cluster.yaml render (worker pools moved to kubernetes-nodes)
2+
3+
# Phase 2 moved the worker node pools (KubevirtMachineTemplate, MachineDeployment,
4+
# MachineHealthCheck, worker WorkloadMonitor) and the per-pool talos-reconcile Job
5+
# into the separate kubernetes-nodes chart. cluster.yaml now renders the control
6+
# plane only, in source order: Cluster (0), KamajiControlPlane (1), the
7+
# control-plane WorkloadMonitor (2), KubevirtCluster (3). This suite pins that
8+
# surface so a regression that re-introduces pool objects into the parent chart
9+
# (double-render / name collision) is caught.
10+
11+
templates:
12+
- templates/cluster.yaml
13+
14+
values:
15+
- values/common.yaml
16+
17+
release:
18+
name: test-k8s
19+
namespace: tenant-test
20+
21+
tests:
22+
- it: renders exactly the four control-plane objects in order
23+
asserts:
24+
- hasDocuments:
25+
count: 4
26+
- isKind:
27+
of: Cluster
28+
documentIndex: 0
29+
- equal:
30+
path: metadata.name
31+
value: test-k8s
32+
documentIndex: 0
33+
- isKind:
34+
of: KamajiControlPlane
35+
documentIndex: 1
36+
- isKind:
37+
of: WorkloadMonitor
38+
documentIndex: 2
39+
- equal:
40+
path: spec.type
41+
value: control-plane
42+
documentIndex: 2
43+
- isKind:
44+
of: KubevirtCluster
45+
documentIndex: 3
46+
47+
- it: emits no worker-pool objects
48+
asserts:
49+
- containsDocument:
50+
apiVersion: cluster.x-k8s.io/v1beta1
51+
kind: MachineDeployment
52+
not: true
53+
documentIndex: -1
54+
- containsDocument:
55+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
56+
kind: KubevirtMachineTemplate
57+
not: true
58+
documentIndex: -1
59+
- containsDocument:
60+
apiVersion: cluster.x-k8s.io/v1beta1
61+
kind: MachineHealthCheck
62+
not: true
63+
documentIndex: -1
64+
- containsDocument:
65+
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3
66+
kind: TalosConfigTemplate
67+
not: true
68+
documentIndex: -1

‎packages/apps/kubernetes/tests/gpu_node_labels_test.yaml‎

Lines changed: 0 additions & 82 deletions
This file was deleted.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
suite: ingress-nginx requires an ingress-nginx worker pool (Phase 2 guard)
2+
3+
# The ingress-nginx controller DaemonSet pins itself (nodeSelector) to nodes
4+
# labelled node-role.kubernetes.io/ingress-nginx. Since Phase 2 moved worker
5+
# pools into the kubernetes-nodes chart, that label comes only from a
6+
# KubernetesNodes pool with roles: [ingress-nginx]. The chart fails render when
7+
# this cluster already has pools but none carries the ingress role, so the
8+
# operator gets an actionable error instead of a DaemonSet that schedules
9+
# nothing. The lookup is empty during plain render (helm template / lint /
10+
# unittest without a mocked provider), so the guard never fires there.
11+
12+
templates:
13+
- templates/helmreleases/ingress-nginx.yaml
14+
15+
values:
16+
- values/common.yaml
17+
18+
release:
19+
name: test-k8s
20+
namespace: tenant-test
21+
22+
tests:
23+
- it: renders the ingress-nginx HelmRelease when enabled and no pools are visible (empty lookup, no fail)
24+
set:
25+
addons.ingressNginx.enabled: true
26+
asserts:
27+
- hasDocuments:
28+
count: 1
29+
- isKind:
30+
of: HelmRelease
31+
- equal:
32+
path: metadata.name
33+
value: test-k8s-ingress-nginx
34+
35+
- it: does not render when the addon is disabled
36+
set:
37+
addons.ingressNginx.enabled: false
38+
asserts:
39+
- hasDocuments:
40+
count: 0
41+
42+
- it: fails when a worker pool exists for this cluster but none has the ingress-nginx role
43+
set:
44+
addons.ingressNginx.enabled: true
45+
kubernetesProvider:
46+
scheme:
47+
"cluster.x-k8s.io/v1beta1/MachineDeployment":
48+
gvr:
49+
group: cluster.x-k8s.io
50+
version: v1beta1
51+
resource: machinedeployments
52+
namespaced: true
53+
objects:
54+
- apiVersion: cluster.x-k8s.io/v1beta1
55+
kind: MachineDeployment
56+
metadata:
57+
name: test-k8s-md0
58+
namespace: tenant-test
59+
spec:
60+
clusterName: test-k8s
61+
template:
62+
metadata:
63+
labels:
64+
node-role.kubernetes.io/worker: ""
65+
asserts:
66+
- failedTemplate:
67+
errorPattern: "no KubernetesNodes pool for this cluster has roles"
68+
69+
- it: renders when a worker pool with the ingress-nginx role exists
70+
set:
71+
addons.ingressNginx.enabled: true
72+
kubernetesProvider:
73+
scheme:
74+
"cluster.x-k8s.io/v1beta1/MachineDeployment":
75+
gvr:
76+
group: cluster.x-k8s.io
77+
version: v1beta1
78+
resource: machinedeployments
79+
namespaced: true
80+
objects:
81+
- apiVersion: cluster.x-k8s.io/v1beta1
82+
kind: MachineDeployment
83+
metadata:
84+
name: test-k8s-ingress
85+
namespace: tenant-test
86+
spec:
87+
clusterName: test-k8s
88+
template:
89+
metadata:
90+
labels:
91+
node-role.kubernetes.io/ingress-nginx: ""
92+
asserts:
93+
- hasDocuments:
94+
count: 1
95+
- isKind:
96+
of: HelmRelease

0 commit comments

Comments
 (0)