Skip to content

Commit

Permalink
Add kuttl tests to validate config overrides with extraMounts
Browse files Browse the repository at this point in the history
Added config override check for both secret and configmap.

Also update debug config check pod to filter only running containers.

Resolves: OSPRH-4296
  • Loading branch information
karelyatin committed Sep 5, 2024
1 parent e0d3f1c commit 9fcb695
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

pod=$(oc get pods -n $NAMESPACE -l service=neutron -o name)
pod=$(oc get pods -n $NAMESPACE -l service=neutron --field-selector=status.phase=Running -o name|head -1)

# Check if the neutron pod logs contain DEBUG messages
oc logs -n $NAMESPACE "$pod" | grep -q "DEBUG"
Expand Down
15 changes: 15 additions & 0 deletions test/kuttl/tests/change_neutron_config/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Check for:
#
# - Secret
# - ConfigMap

apiVersion: v1
kind: Secret
metadata:
name: test-secret-vol
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-configmap-vol
19 changes: 19 additions & 0 deletions test/kuttl/tests/change_neutron_config/00-test-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# test-secret-vol Secret
# test-configmap-vol ConfiMap
#
apiVersion: v1
kind: Secret
metadata:
name: test-secret-vol
data:
testsecret.conf: W0RFRkFVTFRdCnJwY193b3JrZXJzID0gMAo=
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-configmap-vol
data:
testcm.conf: |
[DEFAULT]
api_workers = 1
7 changes: 7 additions & 0 deletions test/kuttl/tests/change_neutron_config/02-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ kind: TestAssert
commands:
- script: |
$NEUTRON_KUTTL_DIR/../common/scripts/check_debug_in_neutron_pod_logs.sh
- script: |
neutron_pod=$(oc get pods -n $NAMESPACE -l service=neutron --field-selector=status.phase=Running -o name|head -1)
oc rsh -n $NAMESPACE ${neutron_pod} crudini --get /etc/neutron/neutron.conf.d/testcm.conf DEFAULT api_workers
oc rsh -n $NAMESPACE ${neutron_pod} crudini --get /etc/neutron/neutron.conf.d/testsecret.conf DEFAULT rpc_workers
# Check config in pod logs
oc logs -n $NAMESPACE ${neutron_pod} | grep -q "api_workers.*= 1"
oc logs -n $NAMESPACE ${neutron_pod} | grep -q "rpc_workers.*= 0"
23 changes: 23 additions & 0 deletions test/kuttl/tests/change_neutron_config/02-extramounts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: neutron.openstack.org/v1beta1
kind: NeutronAPI
metadata:
name: neutron
spec:
extraMounts:
- extraVol:
- volumes:
- name: test-configmap-vol
configMap:
name: test-configmap-vol
- name: test-secret-vol
secret:
secretName: test-secret-vol
mounts:
- name: test-configmap-vol
mountPath: /etc/neutron/neutron.conf.d/testcm.conf
subPath: testcm.conf
readOnly: true
- name: test-secret-vol
mountPath: /etc/neutron/neutron.conf.d/testsecret.conf
subPath: testsecret.conf
readOnly: false

0 comments on commit 9fcb695

Please sign in to comment.