Skip to content

Commit

Permalink
Merge pull request #265 from omersch381/add_kuttl_tests
Browse files Browse the repository at this point in the history
Improve Kuttl testing coverage
  • Loading branch information
openshift-merge-bot[bot] authored Jan 7, 2025
2 parents e991dfd + 3551dad commit cc1380d
Show file tree
Hide file tree
Showing 16 changed files with 724 additions and 5 deletions.
123 changes: 121 additions & 2 deletions tests/kuttl/common/assert-sample-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,88 @@ spec:
customServiceConfig: |
[DEFAULT]
debug = true
# status:
# transportURLSecret: rabbitmq-transport-url-designate-designate-transport
status:
designateAPIReadyCount: 1
designateBackendbind9ReadyCount: 1
designateCentralReadyCount: 1
designateMdnsReadyCount: 1
designateProducerReadyCount: 1
designateUnboundReadyCount: 1
designateWorkerReadyCount: 1
databaseHostname: openstack.designate-kuttl-tests.svc
conditions:
- message: Setup complete
reason: Ready
status: "True"
type: Ready
- message: DB create completed
reason: Ready
status: "True"
type: DBReady
- message: DBsync completed
reason: Ready
status: "True"
type: DBSyncReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateAPIReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateBackendbind9Ready
- message: Setup complete
reason: Ready
status: "True"
type: DesignateCentralReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateMdnsReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateProducerReady
- message: DesignateRabbitMqTransportURL successfully created
reason: Ready
status: "True"
type: DesignateRabbitMqTransportURLReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateUnboundReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateWorkerReady
- message: Input data complete
reason: Ready
status: "True"
type: InputReady
- message: MariaDBAccount creation complete
reason: Ready
status: "True"
type: MariaDBAccountReady
- message: NetworkAttachments completed
reason: Ready
status: "True"
type: NetworkAttachmentsReady
- message: RoleBinding created
reason: Ready
status: "True"
type: RoleBindingReady
- message: Role created
reason: Ready
status: "True"
type: RoleReady
- message: ServiceAccount created
reason: Ready
status: "True"
type: ServiceAccountReady
- message: Service config create completed
reason: Ready
status: "True"
type: ServiceConfigReady
---
apiVersion: v1
kind: Service
Expand Down Expand Up @@ -64,3 +144,42 @@ commands:
exit 1
fi
exit 0
- script: |
tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}'
imageTuples=$(oc get -n openstack-operators deployment designate-operator-controller-manager -o go-template="$tupleTemplate")
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_DESIGNATE_\([^_]*\)_.*|\1|')
IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|')
case $NAME in
API)
template='{{.spec.designateAPI.containerImage}}'
;;
CENTRAL)
template='{{.spec.designateCentral.containerImage}}'
;;
MDNS)
template='{{.spec.designateMdns.containerImage}}'
;;
PRODUCER)
template='{{.spec.designateProducer.containerImage}}'
;;
WORKER)
template='{{.spec.designateWorker.containerImage}}'
;;
BACKENDBIND9)
template='{{.spec.designateBackendbind9.containerImage}}'
;;
UNBOUND)
template='{{.spec.designateUnbound.containerImage}}'
;;
esac
SERVICE_IMAGE=$(oc get -n $NAMESPACE designate designate -o go-template="$template")
if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then
echo "$NAME image does not equal $IMG_FROM_ENV (its current value is $SERVICE_IMAGE)"
exit 1
fi
fi
done
exit 0
1 change: 0 additions & 1 deletion tests/kuttl/tests/basic/01-assert.yaml

This file was deleted.

176 changes: 176 additions & 0 deletions tests/kuttl/tests/basic/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
apiVersion: designate.openstack.org/v1beta1
kind: Designate
metadata:
name: designate
spec:
databaseInstance: openstack
databaseAccount: designate
serviceUser: designate
secret: osp-secret
preserveJobs: false
designateAPI:
replicas: 1
designateCentral:
replicas: 1
designateWorker:
replicas: 1
designateProducer:
replicas: 1
designateUnbound:
replicas: 1
customServiceConfig: |
[DEFAULT]
debug = true
status:
designateAPIReadyCount: 1
designateBackendbind9ReadyCount: 1
designateCentralReadyCount: 1
designateMdnsReadyCount: 1
designateProducerReadyCount: 1
designateUnboundReadyCount: 1
designateWorkerReadyCount: 1
databaseHostname: openstack.designate-kuttl-tests.svc
conditions:
- message: Setup complete
reason: Ready
status: "True"
type: Ready
- message: DB create completed
reason: Ready
status: "True"
type: DBReady
- message: DBsync completed
reason: Ready
status: "True"
type: DBSyncReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateAPIReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateBackendbind9Ready
- message: Setup complete
reason: Ready
status: "True"
type: DesignateCentralReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateMdnsReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateProducerReady
- message: DesignateRabbitMqTransportURL successfully created
reason: Ready
status: "True"
type: DesignateRabbitMqTransportURLReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateUnboundReady
- message: Setup complete
reason: Ready
status: "True"
type: DesignateWorkerReady
- message: Input data complete
reason: Ready
status: "True"
type: InputReady
- message: MariaDBAccount creation complete
reason: Ready
status: "True"
type: MariaDBAccountReady
- message: NetworkAttachments completed
reason: Ready
status: "True"
type: NetworkAttachmentsReady
- message: RoleBinding created
reason: Ready
status: "True"
type: RoleBindingReady
- message: Role created
reason: Ready
status: "True"
type: RoleReady
- message: ServiceAccount created
reason: Ready
status: "True"
type: ServiceAccountReady
- message: Service config create completed
reason: Ready
status: "True"
type: ServiceConfigReady
---
apiVersion: v1
kind: Service
metadata:
labels:
endpoint: internal
service: designate
name: designate-internal
spec:
ports:
- name: designate-internal
selector:
service: designate
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
labels:
endpoint: public
service: designate
name: designate-public
spec:
ports:
- name: designate-public
selector:
service: designate
type: ClusterIP
---
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 designate-operator-controller-manager -o go-template="$tupleTemplate")
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_DESIGNATE_\([^_]*\)_.*|\1|')
IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|')
case $NAME in
API)
template='{{.spec.designateAPI.containerImage}}'
;;
CENTRAL)
template='{{.spec.designateCentral.containerImage}}'
;;
MDNS)
template='{{.spec.designateMdns.containerImage}}'
;;
PRODUCER)
template='{{.spec.designateProducer.containerImage}}'
;;
WORKER)
template='{{.spec.designateWorker.containerImage}}'
;;
BACKENDBIND9)
template='{{.spec.designateBackendbind9.containerImage}}'
;;
UNBOUND)
template='{{.spec.designateUnbound.containerImage}}'
;;
esac
SERVICE_IMAGE=$(oc get -n $NAMESPACE designate designate -o go-template="$template")
if [ "$SERVICE_IMAGE" != "$IMG_FROM_ENV" ]; then
echo "$NAME image does not equal $IMG_FROM_ENV (its current value is $SERVICE_IMAGE)"
exit 1
fi
fi
done
exit 0
4 changes: 2 additions & 2 deletions tests/kuttl/tests/basic/ns-records-configmap/02-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: designate-ns-records-params
data:
ns_records: |
- host: host1
- hostname: ns1.example.com
priority: 1
- host: host2
- hostname: ns2.example.com
priority: 2
4 changes: 4 additions & 0 deletions tests/kuttl/tests/designate_scale/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: designate
6 changes: 6 additions & 0 deletions tests/kuttl/tests/designate_scale/00-test-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
cp ../../common/designate_nad.yaml .
oc apply -n $NAMESPACE -f designate_nad.yaml
Loading

0 comments on commit cc1380d

Please sign in to comment.