Skip to content

Commit

Permalink
Cleanup kuttl tests
Browse files Browse the repository at this point in the history
The existing kuttl tests match the whole Manila CR spec, including
parameters that are not meaninful to make the test pass or not.
This patch removes a lot of fields that are not required in the main
assertion. For example, matching the status is often sufficient to
assert the status of the reconciliation, conditions, and to check if
a resource has been properly deployed.

Signed-off-by: Francesco Pantano <[email protected]>
  • Loading branch information
fmount committed Feb 5, 2025
1 parent ccebb19 commit 47f4236
Show file tree
Hide file tree
Showing 19 changed files with 509 additions and 997 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec:
databaseInstance: openstack
secret: osp-secret
databaseUser: manila
preserveJobs: true
rabbitMqClusterName: rabbitmq
manilaAPI: {}
manilaScheduler: {}
Expand Down
2 changes: 1 addition & 1 deletion kuttl-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ reportFormat: xml
reportName: kuttl-report-manila
reportGranularity: test
namespace: manila-kuttl-tests
timeout: 180
timeout: 360
parallel: 1
suppress:
- events
File renamed without changes.
91 changes: 0 additions & 91 deletions test/kuttl/tests/manila-basic/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,8 @@ kind: Manila
metadata:
name: manila
spec:
customServiceConfig: |
[DEFAULT]
debug = true
databaseInstance: openstack
databaseAccount: manila
manilaAPI:
customServiceConfig: |
[DEFAULT]
enabled_share_protocols = cephfs
replicas: 1
resources: {}
manilaScheduler:
customServiceConfig: '# add your customization here'
replicas: 1
resources: {}
manilaShares:
share0:
replicas: 1
resources: {}
customServiceConfig: |
[DEFAULT]
enabled_share_backends = cephfs
Expand All @@ -41,12 +24,6 @@ spec:
cephfs_auth_id=openstack
cephfs_cluster_name=ceph
cephfs_protocol_helper_type=CEPHFS
passwordSelectors:
service: ManilaPassword
preserveJobs: false
rabbitMqClusterName: rabbitmq
secret: osp-secret
serviceUser: manila
status:
conditions:
- message: Setup complete
Expand Down Expand Up @@ -113,7 +90,6 @@ status:
reason: Ready
status: "True"
type: ServiceConfigReady
databaseHostname: openstack.manila-kuttl-tests.svc
manilaAPIReadyCount: 1
manilaSchedulerReadyCount: 1
manilaSharesReadyCounts:
Expand All @@ -124,70 +100,3 @@ apiVersion: batch/v1
kind: CronJob
metadata:
name: manila-db-purge
spec:
jobTemplate:
metadata:
labels:
service: manila
spec:
completions: 1
parallelism: 1
template:
spec:
containers:
- args:
- -c
- /usr/bin/manila-manage --config-dir /etc/manila/manila.conf.d
db purge 30
command:
- /bin/bash
name: manila-db-purge
volumeMounts:
- mountPath: /etc/manila/manila.conf.d
name: db-purge-config-data
readOnly: true
serviceAccount: manila-manila
serviceAccountName: manila-manila
volumes:
- name: db-purge-config-data
secret:
defaultMode: 420
items:
- key: 00-config.conf
path: 00-config.conf
secretName: manila-config-data
schedule: 1 0 * * *
suspend: false
---
# when using image digests the containerImage URLs are SHA's so we verify them with a script
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
commands:
- script: |
tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}'
imageTuples=$(oc get -n openstack-operators deployment manila-operator-controller-manager -o go-template="$tupleTemplate")
# format of imageTuple is: RELATED_IMAGE_MANILA_<service>#<image URL with SHA> separated by newlines
for ITEM in $(echo $imageTuples); do
# it is an image
if echo $ITEM | grep 'RELATED_IMAGE' &> /dev/null; then
NAME=$(echo $ITEM | sed -e 's|^RELATED_IMAGE_MANILA_\([^_]*\)_.*|\1|')
IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|')
template='{{.spec.containerImage}}'
case $NAME in
API)
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilaapi manila-api -o go-template="$template")
;;
SHARE)
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilashares manila-share-share0 -o go-template="$template")
;;
SCHEDULER)
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilascheduler manila-scheduler -o go-template="$template")
;;
esac
if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then
echo "$NAME image does not equal $VALUE"
exit 1
fi
fi
done
exit 0
72 changes: 2 additions & 70 deletions test/kuttl/tests/manila-basic/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,13 @@
#
# Check for:
#
# - 1 manilaAPI
# - 2 manilaScheduler
# - 3 manilaShares
# - 4 extraMounts
# - 1 Manila
# - 2 manilaAPI

apiVersion: manila.openstack.org/v1beta1
kind: Manila
metadata:
name: manila
spec:
customServiceConfig: |
[DEFAULT]
debug = true
databaseInstance: openstack
databaseAccount: manila
manilaAPI:
customServiceConfig: |
[DEFAULT]
enabled_share_protocols = cephfs
replicas: 3
resources: {}
manilaScheduler:
replicas: 1
resources: {}
manilaShares:
share0:
replicas: 1
resources: {}
customServiceConfig: |
[DEFAULT]
enabled_share_backends = cephfs
[cephfs]
driver_handles_share_servers=False
share_backend_name=cephfs
share_driver=manila.share.drivers.cephfs.driver.CephFSDriver
cephfs_conf_path=/etc/ceph/ceph.conf
cephfs_auth_id=openstack
cephfs_cluster_name=ceph
cephfs_protocol_helper_type=CEPHFS
passwordSelectors:
service: ManilaPassword
preserveJobs: false
rabbitMqClusterName: rabbitmq
secret: osp-secret
serviceUser: manila
status:
conditions:
- message: Setup complete
Expand Down Expand Up @@ -112,7 +74,6 @@ status:
reason: Ready
status: "True"
type: ServiceConfigReady
databaseHostname: openstack.manila-kuttl-tests.svc
manilaAPIReadyCount: 3
manilaSchedulerReadyCount: 1
manilaSharesReadyCounts:
Expand All @@ -122,43 +83,14 @@ status:
apiVersion: manila.openstack.org/v1beta1
kind: ManilaAPI
metadata:
finalizers:
- openstack.org/manilaapi
name: manila-api
spec:
databaseHostname: openstack.manila-kuttl-tests.svc
databaseAccount: manila
passwordSelectors:
service: ManilaPassword
replicas: 3
resources: {}
secret: osp-secret
serviceAccount: manila-manila
serviceUser: manila
status:
readyCount: 3
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
component: manila-api
service: manila
name: manila-api
ownerReferences:
- apiVersion: manila.openstack.org/v1beta1
kind: ManilaAPI
name: manila-api
spec:
replicas: 3
template:
metadata:
labels:
component: manila-api
service: manila
spec:
serviceAccount: manila-manila
serviceAccountName: manila-manila
status:
availableReplicas: 3
readyReplicas: 3
Expand Down
97 changes: 2 additions & 95 deletions test/kuttl/tests/manila-basic/03-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
#
# Check for:
#
# - 1 manilaAPI
# - 2 manilaScheduler
# - 3 manilaShares
# - 4 extraMounts
# - 1 Manila
# - 2 CronJob

apiVersion: manila.openstack.org/v1beta1
kind: Manila
metadata:
name: manila
spec:
customServiceConfig: |
[DEFAULT]
debug = true
databaseInstance: openstack
databaseAccount: manila
manilaAPI:
customServiceConfig: |
[DEFAULT]
enabled_share_protocols = cephfs
replicas: 1
resources: {}
manilaScheduler:
customServiceConfig: '# add your customization here'
replicas: 1
resources: {}
manilaShares:
share0:
replicas: 1
resources: {}
customServiceConfig: |
[DEFAULT]
enabled_share_backends = cephfs
Expand All @@ -41,12 +22,6 @@ spec:
cephfs_auth_id=openstack
cephfs_cluster_name=ceph
cephfs_protocol_helper_type=CEPHFS
passwordSelectors:
service: ManilaPassword
preserveJobs: false
rabbitMqClusterName: rabbitmq
secret: osp-secret
serviceUser: manila
status:
conditions:
- message: Setup complete
Expand Down Expand Up @@ -113,7 +88,6 @@ status:
reason: Ready
status: "True"
type: ServiceConfigReady
databaseHostname: openstack.manila-kuttl-tests.svc
manilaAPIReadyCount: 1
manilaSchedulerReadyCount: 1
manilaSharesReadyCounts:
Expand All @@ -124,70 +98,3 @@ apiVersion: batch/v1
kind: CronJob
metadata:
name: manila-db-purge
spec:
jobTemplate:
metadata:
labels:
service: manila
spec:
completions: 1
parallelism: 1
template:
spec:
containers:
- args:
- -c
- /usr/bin/manila-manage --config-dir /etc/manila/manila.conf.d
db purge 30
command:
- /bin/bash
name: manila-db-purge
volumeMounts:
- mountPath: /etc/manila/manila.conf.d
name: db-purge-config-data
readOnly: true
serviceAccount: manila-manila
serviceAccountName: manila-manila
volumes:
- name: db-purge-config-data
secret:
defaultMode: 420
items:
- key: 00-config.conf
path: 00-config.conf
secretName: manila-config-data
schedule: 1 0 * * *
suspend: false
---
# when using image digests the containerImage URLs are SHA's so we verify them with a script
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
commands:
- script: |
tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}'
imageTuples=$(oc get -n openstack-operators deployment manila-operator-controller-manager -o go-template="$tupleTemplate")
# format of imageTuple is: RELATED_IMAGE_MANILA_<service>#<image URL with SHA> separated by newlines
for ITEM in $(echo $imageTuples); do
# it is an image
if echo $ITEM | grep 'RELATED_IMAGE' &> /dev/null; then
NAME=$(echo $ITEM | sed -e 's|^RELATED_IMAGE_MANILA_\([^_]*\)_.*|\1|')
IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|')
template='{{.spec.containerImage}}'
case $NAME in
API)
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilaapi manila-api -o go-template="$template")
;;
SHARE)
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilashares manila-share-share0 -o go-template="$template")
;;
SCHEDULER)
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilascheduler manila-scheduler -o go-template="$template")
;;
esac
if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then
echo "$NAME image does not equal $VALUE"
exit 1
fi
fi
done
exit 0
Loading

0 comments on commit 47f4236

Please sign in to comment.