Skip to content

Commit

Permalink
Add kuttl test for neutron operator
Browse files Browse the repository at this point in the history
Implement a kuttl test to ensure that any modifications to the neutron service settings
lead to the creation of a new pod with the updated settings.
These tests should first confirm that the default logging setting excludes debug details.
Then, after adjusting the neutron configuration to enable debug mode (debug = true),
the tests should verify that the logs from the newly created pod now contain debug information.
  • Loading branch information
brfrenkel committed Mar 27, 2024
1 parent 4c24f97 commit 4eb9cd5
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/kuttl/common/scripts/check_debug_in_neutron_pod_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

pod=$(oc get pods -n $NAMESPACE -l service=neutron -o name)

# Check if the neutron pod logs contain DEBUG messages
oc logs -n $NAMESPACE "$pod" | grep -q "DEBUG"
exit $?
1 change: 1 addition & 0 deletions test/kuttl/tests/change_neutron_config/01-assert.yaml
6 changes: 6 additions & 0 deletions test/kuttl/tests/change_neutron_config/01-deploy-neutron.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
cp ../../../../config/samples/neutron_v1beta1_neutronapi.yaml deploy
oc kustomize deploy | oc apply -n $NAMESPACE -f -
6 changes: 6 additions & 0 deletions test/kuttl/tests/change_neutron_config/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# check that by default, debug is set in neutron config
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
commands:
- script: |
$NEUTRON_KUTTL_DIR/../common/scripts/check_debug_in_neutron_pod_logs.sh
7 changes: 7 additions & 0 deletions test/kuttl/tests/change_neutron_config/03-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# check that now, debug is not set in neutron config
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
commands:
- script: |
$NEUTRON_KUTTL_DIR/../common/scripts/check_debug_in_neutron_pod_logs.sh
test $? -ne 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: neutron.openstack.org/v1beta1
kind: NeutronAPI
metadata:
name: neutron
spec:
customServiceConfig: |
[DEFAULT]
debug = false
1 change: 1 addition & 0 deletions test/kuttl/tests/change_neutron_config/04-errors.yaml
13 changes: 13 additions & 0 deletions test/kuttl/tests/change_neutron_config/deploy/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./neutron_v1beta1_neutronapi.yaml
patches:
- patch: |-
- op: replace
path: /spec/secret
value: osp-secret
- op: remove
path: /metadata/namespace
target:
kind: NeutronAPI

0 comments on commit 4eb9cd5

Please sign in to comment.