Skip to content

Commit ddd51dd

Browse files
committed
fix: added test cases for ansibleVarsFrom changes
1 parent aed228c commit ddd51dd

4 files changed

Lines changed: 110 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Test ansibleVarsFrom ConfigMap/Secret change detection
2+
# Create ConfigMap and Secret for ansibleVarsFrom
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: ansiblevars-test-cm
7+
data:
8+
test_var: original-value
9+
---
10+
apiVersion: v1
11+
kind: Secret
12+
metadata:
13+
name: ansiblevars-test-secret
14+
stringData:
15+
secret_var: original-secret-value
16+
---
17+
# Patch existing NodeSet to add ansibleVarsFrom
18+
apiVersion: dataplane.openstack.org/v1beta1
19+
kind: OpenStackDataPlaneNodeSet
20+
metadata:
21+
name: edpm-compute-no-nodes
22+
spec:
23+
nodeTemplate:
24+
ansible:
25+
ansibleVarsFrom:
26+
- configMapRef:
27+
name: ansiblevars-test-cm
28+
- secretRef:
29+
name: ansiblevars-test-secret
30+
---
31+
# Create deployment to capture the hashes
32+
apiVersion: dataplane.openstack.org/v1beta1
33+
kind: OpenStackDataPlaneDeployment
34+
metadata:
35+
name: edpm-ansiblevars-deploy
36+
spec:
37+
nodeSets:
38+
- edpm-compute-no-nodes
39+
servicesOverride:
40+
- configure-os
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestAssert
3+
timeout: 600
4+
collectors:
5+
- type: command
6+
command: oc logs -n openstack-operators -l openstack.org/operator-name=openstack
7+
name: operator-logs
8+
---
9+
# Assert NodeSet is Ready with configMapHashes populated
10+
apiVersion: dataplane.openstack.org/v1beta1
11+
kind: OpenStackDataPlaneNodeSet
12+
metadata:
13+
name: edpm-compute-no-nodes
14+
namespace: openstack-kuttl-tests
15+
status:
16+
conditions:
17+
- message: NodeSet Ready
18+
reason: Ready
19+
status: "True"
20+
type: Ready
21+
configMapHashes:
22+
ansiblevars-test-cm: {}
23+
secretHashes:
24+
ansiblevars-test-secret: {}
25+
---
26+
# Assert deployment completed with hashes
27+
apiVersion: dataplane.openstack.org/v1beta1
28+
kind: OpenStackDataPlaneDeployment
29+
metadata:
30+
name: edpm-ansiblevars-deploy
31+
namespace: openstack-kuttl-tests
32+
status:
33+
deployed: true
34+
configMapHashes:
35+
ansiblevars-test-cm: {}
36+
secretHashes:
37+
ansiblevars-test-secret: {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Update ConfigMap and Secret content to trigger change detection
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: ansiblevars-test-cm
6+
data:
7+
test_var: updated-value
8+
---
9+
apiVersion: v1
10+
kind: Secret
11+
metadata:
12+
name: ansiblevars-test-secret
13+
stringData:
14+
secret_var: updated-secret-value
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestAssert
3+
timeout: 600
4+
collectors:
5+
- type: command
6+
command: oc logs -n openstack-operators -l openstack.org/operator-name=openstack
7+
name: operator-logs
8+
---
9+
# Assert NodeSet is NOT Ready after ConfigMap/Secret content changed
10+
apiVersion: dataplane.openstack.org/v1beta1
11+
kind: OpenStackDataPlaneNodeSet
12+
metadata:
13+
name: edpm-compute-no-nodes
14+
namespace: openstack-kuttl-tests
15+
status:
16+
conditions:
17+
- reason: Requested
18+
status: "False"
19+
type: Ready

0 commit comments

Comments
 (0)