Skip to content

Commit a96c64b

Browse files
committed
Cleanup kuttl tests
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]>
1 parent ccebb19 commit a96c64b

18 files changed

+19
-1044
lines changed

config/samples/layout/bases/manila/manila_v1beta1_manila.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ spec:
1111
databaseInstance: openstack
1212
secret: osp-secret
1313
databaseUser: manila
14+
preserveJobs: true
1415
rabbitMqClusterName: rabbitmq
1516
manilaAPI: {}
1617
manilaScheduler: {}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241216113837-d172b3ac0f4e
1313
github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241216113837-d172b3ac0f4e
1414
github.com/openstack-k8s-operators/manila-operator/api v0.0.0-00010101000000-000000000000
15-
github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20250108071621-aa59f25c5b1a
15+
github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241217172849-1709c6e07dea
1616
k8s.io/api v0.29.13
1717
k8s.io/apimachinery v0.29.13
1818
k8s.io/client-go v0.29.13

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.202412161
9090
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241216113837-d172b3ac0f4e/go.mod h1:tfgBeLRqmlH/NQkLPe7396rj+t0whv2wPuMb8Ttvh8w=
9191
github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241216113837-d172b3ac0f4e h1:/iWDp3j+ET3gE5IjKHtdZaPd4SQyLHB/4L5jB16cV3I=
9292
github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241216113837-d172b3ac0f4e/go.mod h1:LV0jo5etIsGyINpmB37i4oWR8zU6ApIuh7fsqGGA41o=
93-
github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20250108071621-aa59f25c5b1a h1:woToPr//WF1DDDo+0AtWyuoQzRTBmw5F0U6FSN5cocE=
94-
github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20250108071621-aa59f25c5b1a/go.mod h1:wyvGgWBf18AhYLXN7apmlZxpho8N9HCEWmihO/+Albc=
93+
github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241217172849-1709c6e07dea h1:DHdJuIgmMYl21K9w/qSeKt2L0zHqzk8SxbBOLdnmYyE=
94+
github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241217172849-1709c6e07dea/go.mod h1:wyvGgWBf18AhYLXN7apmlZxpho8N9HCEWmihO/+Albc=
9595
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
9696
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
9797
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

kuttl-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ reportFormat: xml
2020
reportName: kuttl-report-manila
2121
reportGranularity: test
2222
namespace: manila-kuttl-tests
23-
timeout: 180
23+
timeout: 360
2424
parallel: 1
2525
suppress:
2626
- events

test/kuttl/tests/manila-basic/01-assert.yaml

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,8 @@ kind: Manila
1111
metadata:
1212
name: manila
1313
spec:
14-
customServiceConfig: |
15-
[DEFAULT]
16-
debug = true
17-
databaseInstance: openstack
18-
databaseAccount: manila
19-
manilaAPI:
20-
customServiceConfig: |
21-
[DEFAULT]
22-
enabled_share_protocols = cephfs
23-
replicas: 1
24-
resources: {}
25-
manilaScheduler:
26-
customServiceConfig: '# add your customization here'
27-
replicas: 1
28-
resources: {}
2914
manilaShares:
3015
share0:
31-
replicas: 1
32-
resources: {}
3316
customServiceConfig: |
3417
[DEFAULT]
3518
enabled_share_backends = cephfs
@@ -41,12 +24,6 @@ spec:
4124
cephfs_auth_id=openstack
4225
cephfs_cluster_name=ceph
4326
cephfs_protocol_helper_type=CEPHFS
44-
passwordSelectors:
45-
service: ManilaPassword
46-
preserveJobs: false
47-
rabbitMqClusterName: rabbitmq
48-
secret: osp-secret
49-
serviceUser: manila
5027
status:
5128
conditions:
5229
- message: Setup complete
@@ -113,7 +90,6 @@ status:
11390
reason: Ready
11491
status: "True"
11592
type: ServiceConfigReady
116-
databaseHostname: openstack.manila-kuttl-tests.svc
11793
manilaAPIReadyCount: 1
11894
manilaSchedulerReadyCount: 1
11995
manilaSharesReadyCounts:
@@ -124,70 +100,3 @@ apiVersion: batch/v1
124100
kind: CronJob
125101
metadata:
126102
name: manila-db-purge
127-
spec:
128-
jobTemplate:
129-
metadata:
130-
labels:
131-
service: manila
132-
spec:
133-
completions: 1
134-
parallelism: 1
135-
template:
136-
spec:
137-
containers:
138-
- args:
139-
- -c
140-
- /usr/bin/manila-manage --config-dir /etc/manila/manila.conf.d
141-
db purge 30
142-
command:
143-
- /bin/bash
144-
name: manila-db-purge
145-
volumeMounts:
146-
- mountPath: /etc/manila/manila.conf.d
147-
name: db-purge-config-data
148-
readOnly: true
149-
serviceAccount: manila-manila
150-
serviceAccountName: manila-manila
151-
volumes:
152-
- name: db-purge-config-data
153-
secret:
154-
defaultMode: 420
155-
items:
156-
- key: 00-config.conf
157-
path: 00-config.conf
158-
secretName: manila-config-data
159-
schedule: 1 0 * * *
160-
suspend: false
161-
---
162-
# when using image digests the containerImage URLs are SHA's so we verify them with a script
163-
apiVersion: kuttl.dev/v1beta1
164-
kind: TestAssert
165-
commands:
166-
- script: |
167-
tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}'
168-
imageTuples=$(oc get -n openstack-operators deployment manila-operator-controller-manager -o go-template="$tupleTemplate")
169-
# format of imageTuple is: RELATED_IMAGE_MANILA_<service>#<image URL with SHA> separated by newlines
170-
for ITEM in $(echo $imageTuples); do
171-
# it is an image
172-
if echo $ITEM | grep 'RELATED_IMAGE' &> /dev/null; then
173-
NAME=$(echo $ITEM | sed -e 's|^RELATED_IMAGE_MANILA_\([^_]*\)_.*|\1|')
174-
IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|')
175-
template='{{.spec.containerImage}}'
176-
case $NAME in
177-
API)
178-
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilaapi manila-api -o go-template="$template")
179-
;;
180-
SHARE)
181-
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilashares manila-share-share0 -o go-template="$template")
182-
;;
183-
SCHEDULER)
184-
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilascheduler manila-scheduler -o go-template="$template")
185-
;;
186-
esac
187-
if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then
188-
echo "$NAME image does not equal $VALUE"
189-
exit 1
190-
fi
191-
fi
192-
done
193-
exit 0

test/kuttl/tests/manila-basic/02-assert.yaml

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,13 @@
11
#
22
# Check for:
33
#
4-
# - 1 manilaAPI
5-
# - 2 manilaScheduler
6-
# - 3 manilaShares
7-
# - 4 extraMounts
4+
# - 1 Manila
5+
# - 2 manilaAPI
86

97
apiVersion: manila.openstack.org/v1beta1
108
kind: Manila
119
metadata:
1210
name: manila
13-
spec:
14-
customServiceConfig: |
15-
[DEFAULT]
16-
debug = true
17-
databaseInstance: openstack
18-
databaseAccount: manila
19-
manilaAPI:
20-
customServiceConfig: |
21-
[DEFAULT]
22-
enabled_share_protocols = cephfs
23-
replicas: 3
24-
resources: {}
25-
manilaScheduler:
26-
replicas: 1
27-
resources: {}
28-
manilaShares:
29-
share0:
30-
replicas: 1
31-
resources: {}
32-
customServiceConfig: |
33-
[DEFAULT]
34-
enabled_share_backends = cephfs
35-
[cephfs]
36-
driver_handles_share_servers=False
37-
share_backend_name=cephfs
38-
share_driver=manila.share.drivers.cephfs.driver.CephFSDriver
39-
cephfs_conf_path=/etc/ceph/ceph.conf
40-
cephfs_auth_id=openstack
41-
cephfs_cluster_name=ceph
42-
cephfs_protocol_helper_type=CEPHFS
43-
passwordSelectors:
44-
service: ManilaPassword
45-
preserveJobs: false
46-
rabbitMqClusterName: rabbitmq
47-
secret: osp-secret
48-
serviceUser: manila
4911
status:
5012
conditions:
5113
- message: Setup complete
@@ -112,7 +74,6 @@ status:
11274
reason: Ready
11375
status: "True"
11476
type: ServiceConfigReady
115-
databaseHostname: openstack.manila-kuttl-tests.svc
11677
manilaAPIReadyCount: 3
11778
manilaSchedulerReadyCount: 1
11879
manilaSharesReadyCounts:
@@ -122,43 +83,14 @@ status:
12283
apiVersion: manila.openstack.org/v1beta1
12384
kind: ManilaAPI
12485
metadata:
125-
finalizers:
126-
- openstack.org/manilaapi
12786
name: manila-api
128-
spec:
129-
databaseHostname: openstack.manila-kuttl-tests.svc
130-
databaseAccount: manila
131-
passwordSelectors:
132-
service: ManilaPassword
133-
replicas: 3
134-
resources: {}
135-
secret: osp-secret
136-
serviceAccount: manila-manila
137-
serviceUser: manila
13887
status:
13988
readyCount: 3
14089
---
14190
apiVersion: apps/v1
14291
kind: StatefulSet
14392
metadata:
144-
labels:
145-
component: manila-api
146-
service: manila
14793
name: manila-api
148-
ownerReferences:
149-
- apiVersion: manila.openstack.org/v1beta1
150-
kind: ManilaAPI
151-
name: manila-api
152-
spec:
153-
replicas: 3
154-
template:
155-
metadata:
156-
labels:
157-
component: manila-api
158-
service: manila
159-
spec:
160-
serviceAccount: manila-manila
161-
serviceAccountName: manila-manila
16294
status:
16395
availableReplicas: 3
16496
readyReplicas: 3
Lines changed: 2 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,16 @@
11
#
22
# Check for:
33
#
4-
# - 1 manilaAPI
5-
# - 2 manilaScheduler
6-
# - 3 manilaShares
7-
# - 4 extraMounts
4+
# - 1 Manila
5+
# - 2 CronJob
86

97
apiVersion: manila.openstack.org/v1beta1
108
kind: Manila
119
metadata:
1210
name: manila
1311
spec:
14-
customServiceConfig: |
15-
[DEFAULT]
16-
debug = true
17-
databaseInstance: openstack
18-
databaseAccount: manila
19-
manilaAPI:
20-
customServiceConfig: |
21-
[DEFAULT]
22-
enabled_share_protocols = cephfs
23-
replicas: 1
24-
resources: {}
25-
manilaScheduler:
26-
customServiceConfig: '# add your customization here'
27-
replicas: 1
28-
resources: {}
2912
manilaShares:
3013
share0:
31-
replicas: 1
32-
resources: {}
3314
customServiceConfig: |
3415
[DEFAULT]
3516
enabled_share_backends = cephfs
@@ -41,12 +22,6 @@ spec:
4122
cephfs_auth_id=openstack
4223
cephfs_cluster_name=ceph
4324
cephfs_protocol_helper_type=CEPHFS
44-
passwordSelectors:
45-
service: ManilaPassword
46-
preserveJobs: false
47-
rabbitMqClusterName: rabbitmq
48-
secret: osp-secret
49-
serviceUser: manila
5025
status:
5126
conditions:
5227
- message: Setup complete
@@ -113,7 +88,6 @@ status:
11388
reason: Ready
11489
status: "True"
11590
type: ServiceConfigReady
116-
databaseHostname: openstack.manila-kuttl-tests.svc
11791
manilaAPIReadyCount: 1
11892
manilaSchedulerReadyCount: 1
11993
manilaSharesReadyCounts:
@@ -124,70 +98,3 @@ apiVersion: batch/v1
12498
kind: CronJob
12599
metadata:
126100
name: manila-db-purge
127-
spec:
128-
jobTemplate:
129-
metadata:
130-
labels:
131-
service: manila
132-
spec:
133-
completions: 1
134-
parallelism: 1
135-
template:
136-
spec:
137-
containers:
138-
- args:
139-
- -c
140-
- /usr/bin/manila-manage --config-dir /etc/manila/manila.conf.d
141-
db purge 30
142-
command:
143-
- /bin/bash
144-
name: manila-db-purge
145-
volumeMounts:
146-
- mountPath: /etc/manila/manila.conf.d
147-
name: db-purge-config-data
148-
readOnly: true
149-
serviceAccount: manila-manila
150-
serviceAccountName: manila-manila
151-
volumes:
152-
- name: db-purge-config-data
153-
secret:
154-
defaultMode: 420
155-
items:
156-
- key: 00-config.conf
157-
path: 00-config.conf
158-
secretName: manila-config-data
159-
schedule: 1 0 * * *
160-
suspend: false
161-
---
162-
# when using image digests the containerImage URLs are SHA's so we verify them with a script
163-
apiVersion: kuttl.dev/v1beta1
164-
kind: TestAssert
165-
commands:
166-
- script: |
167-
tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}'
168-
imageTuples=$(oc get -n openstack-operators deployment manila-operator-controller-manager -o go-template="$tupleTemplate")
169-
# format of imageTuple is: RELATED_IMAGE_MANILA_<service>#<image URL with SHA> separated by newlines
170-
for ITEM in $(echo $imageTuples); do
171-
# it is an image
172-
if echo $ITEM | grep 'RELATED_IMAGE' &> /dev/null; then
173-
NAME=$(echo $ITEM | sed -e 's|^RELATED_IMAGE_MANILA_\([^_]*\)_.*|\1|')
174-
IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|')
175-
template='{{.spec.containerImage}}'
176-
case $NAME in
177-
API)
178-
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilaapi manila-api -o go-template="$template")
179-
;;
180-
SHARE)
181-
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilashares manila-share-share0 -o go-template="$template")
182-
;;
183-
SCHEDULER)
184-
SERVICE_IMAGE=$(oc get -n $NAMESPACE manilascheduler manila-scheduler -o go-template="$template")
185-
;;
186-
esac
187-
if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then
188-
echo "$NAME image does not equal $VALUE"
189-
exit 1
190-
fi
191-
fi
192-
done
193-
exit 0

0 commit comments

Comments
 (0)