From 82d7669d2dfc40738fa540489cca57360bd2e161 Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Fri, 29 Mar 2024 15:22:00 +0100 Subject: [PATCH] Kuttl test to cover an edge deployment scenario This patch introduces a kuttl test that is supposed to cover an Edge use case deployment. It asserts that the required resources exist and the Pods are available. This change also updates the Edge sample to make sure it reflects the right type. Signed-off-by: Francesco Pantano --- .../layout/edge/glance_v1beta1_glance.yaml | 27 +- test/kuttl/tests/glance_edge/01-assert.yaml | 374 ++++++++++++++++++ .../tests/glance_edge/01-deploy_glance.yaml | 5 + .../tests/glance_edge/02-cleanup_glance.yaml | 5 + test/kuttl/tests/glance_edge/02-errors.yaml | 114 ++++++ 5 files changed, 513 insertions(+), 12 deletions(-) create mode 100644 test/kuttl/tests/glance_edge/01-assert.yaml create mode 100644 test/kuttl/tests/glance_edge/01-deploy_glance.yaml create mode 100644 test/kuttl/tests/glance_edge/02-cleanup_glance.yaml create mode 100644 test/kuttl/tests/glance_edge/02-errors.yaml diff --git a/config/samples/layout/edge/glance_v1beta1_glance.yaml b/config/samples/layout/edge/glance_v1beta1_glance.yaml index b3ae2c0c..848a4138 100644 --- a/config/samples/layout/edge/glance_v1beta1_glance.yaml +++ b/config/samples/layout/edge/glance_v1beta1_glance.yaml @@ -4,25 +4,28 @@ metadata: name: glance spec: serviceUser: glance - customServiceConfig: | - [DEFAULT] - debug = true databaseInstance: openstack databaseAccount: glance - keystoneEndpoint: central + keystoneEndpoint: default glanceAPIs: - edge1: - preserveJobs: false + default: + customServiceConfig: | + [DEFAULT] + enabled_backends=default_backend:rbd,az1:rbd,az2:rbd replicas: 1 - type: edge - edge2: - preserveJobs: false + type: split + az1: + customServiceConfig: | + [DEFAULT] + enabled_backends=az1:rbd replicas: 1 type: edge - central: - preserveJobs: false + az2: + customServiceConfig: | + [DEFAULT] + enabled_backends=az2:rbd replicas: 1 - type: single + type: edge secret: osp-secret storageClass: local-storage storageRequest: 10G diff --git a/test/kuttl/tests/glance_edge/01-assert.yaml b/test/kuttl/tests/glance_edge/01-assert.yaml new file mode 100644 index 00000000..1756bcc4 --- /dev/null +++ b/test/kuttl/tests/glance_edge/01-assert.yaml @@ -0,0 +1,374 @@ +# +# Check for: +# - Glance CR +# - GlanceAPI glance-default-external CR +# - GlanceAPI glance-default-internal CR +# - GlanceAPI glance-az1-edge CR +# - GlanceAPI glance-az2-edge CR +# - GlanceAPI glance-default-external-api StatefulSet +# - GlanceAPI glance-default-internal-api StatefulSet +# - GlanceAPI glance-az1-edge-api StatefulSet +# - GlanceAPI glance-az2-edge-api StatefulSet +# - glance-default-internal service +# - glance-default-public service +# - glance-default-headless service +# - glance-az1-internal service +# - glance-az1-headless service +# - glance-az2-internal service +# - glance-az2-headless service + +apiVersion: glance.openstack.org/v1beta1 +kind: Glance +metadata: + name: glance +spec: + serviceUser: glance + databaseInstance: openstack + databaseAccount: glance + glanceAPIs: + default: + replicas: 1 + az1: + replicas: 1 + az2: + replicas: 1 + secret: osp-secret + storageRequest: 10G +--- +apiVersion: glance.openstack.org/v1beta1 +kind: GlanceAPI +metadata: + name: glance-default-external +spec: + apiType: external + databaseAccount: glance + passwordSelectors: + service: GlancePassword + replicas: 1 +--- +apiVersion: glance.openstack.org/v1beta1 +kind: GlanceAPI +metadata: + name: glance-default-internal +spec: + apiType: internal + databaseAccount: glance + passwordSelectors: + service: GlancePassword + replicas: 1 +--- +apiVersion: glance.openstack.org/v1beta1 +kind: GlanceAPI +metadata: + name: glance-az1-edge +spec: + apiType: edge + databaseAccount: glance + passwordSelectors: + service: GlancePassword + replicas: 1 +--- +apiVersion: glance.openstack.org/v1beta1 +kind: GlanceAPI +metadata: + name: glance-az2-edge +spec: + apiType: edge + databaseAccount: glance + passwordSelectors: + service: GlancePassword + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-default-external-api +spec: + replicas: 1 + selector: + matchLabels: + service: glance + template: + metadata: + labels: + service: glance + spec: + containers: + - args: + - --single-child + - -- + - /usr/bin/tail + - -n+1 + - -F + - /var/log/glance/glance-default-external.log + command: + - /usr/bin/dumb-init + name: glance-log + - args: + - -c + - /usr/sbin/httpd -DFOREGROUND + command: + - /bin/bash + name: glance-httpd + - args: + - -c + - /usr/local/bin/kolla_set_configs && /usr/local/bin/kolla_start + command: + - /bin/bash + name: glance-api + serviceAccount: glance-glance + serviceAccountName: glance-glance +status: + availableReplicas: 1 + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-default-internal-api +spec: + replicas: 1 + selector: + matchLabels: + service: glance + template: + metadata: + labels: + service: glance + spec: + containers: + - args: + - --single-child + - -- + - /usr/bin/tail + - -n+1 + - -F + - /var/log/glance/glance-default-internal.log + command: + - /usr/bin/dumb-init + name: glance-log + - args: + - -c + - /usr/sbin/httpd -DFOREGROUND + command: + - /bin/bash + name: glance-httpd + - args: + - -c + - /usr/local/bin/kolla_set_configs && /usr/local/bin/kolla_start + command: + - /bin/bash + name: glance-api + serviceAccount: glance-glance + serviceAccountName: glance-glance +status: + availableReplicas: 1 + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-az1-edge-api +spec: + replicas: 1 + selector: + matchLabels: + service: glance + template: + metadata: + labels: + service: glance + spec: + containers: + - args: + - --single-child + - -- + - /usr/bin/tail + - -n+1 + - -F + - /var/log/glance/glance-az1-edge.log + command: + - /usr/bin/dumb-init + name: glance-log + - args: + - -c + - /usr/sbin/httpd -DFOREGROUND + command: + - /bin/bash + name: glance-httpd + - args: + - -c + - /usr/local/bin/kolla_set_configs && /usr/local/bin/kolla_start + command: + - /bin/bash + name: glance-api + serviceAccount: glance-glance + serviceAccountName: glance-glance +status: + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-az2-edge-api +spec: + replicas: 1 + selector: + matchLabels: + service: glance + template: + metadata: + labels: + service: glance + spec: + containers: + - args: + - --single-child + - -- + - /usr/bin/tail + - -n+1 + - -F + - /var/log/glance/glance-az2-edge.log + command: + - /usr/bin/dumb-init + name: glance-log + - args: + - -c + - /usr/sbin/httpd -DFOREGROUND + command: + - /bin/bash + name: glance-httpd + - args: + - -c + - /usr/local/bin/kolla_set_configs && /usr/local/bin/kolla_start + command: + - /bin/bash + name: glance-api + serviceAccount: glance-glance + serviceAccountName: glance-glance +status: + replicas: 1 +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-internal + labels: + endpoint: internal + service: glance +spec: + ports: + - name: glance-default-internal + port: 9292 + protocol: TCP + targetPort: 9292 + selector: + service: glance +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-public + labels: + endpoint: public + service: glance +spec: + ports: + - name: glance-default-public + port: 9292 + protocol: TCP + targetPort: 9292 + selector: + service: glance +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-external-api + labels: + service: glance +spec: + ports: + - name: glance-default-external-api + port: 9292 + protocol: TCP + targetPort: 9292 + selector: + service: glance +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-internal-api + labels: + service: glance +spec: + ports: + - name: glance-default-internal-api + port: 9292 + protocol: TCP + targetPort: 9292 + selector: + service: glance +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-az1-internal + labels: + service: glance +spec: + ports: + - name: glance-az1-internal + port: 9292 + protocol: TCP + targetPort: 9292 + selector: + service: glance +--- +# headless service for az1 +apiVersion: v1 +kind: Service +metadata: + name: glance-az1-edge-api + labels: + service: glance +spec: + ports: + - name: glance-az1-edge-api + port: 9292 + protocol: TCP + targetPort: 9292 + selector: + service: glance +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-az2-internal + labels: + service: glance +spec: + ports: + - name: glance-az2-internal + port: 9292 + protocol: TCP + targetPort: 9292 + selector: + service: glance +--- +# headless service for az2 +apiVersion: v1 +kind: Service +metadata: + name: glance-az2-edge-api + labels: + service: glance +spec: + ports: + - name: glance-az2-edge-api + port: 9292 + protocol: TCP + targetPort: 9292 + selector: + service: glance diff --git a/test/kuttl/tests/glance_edge/01-deploy_glance.yaml b/test/kuttl/tests/glance_edge/01-deploy_glance.yaml new file mode 100644 index 00000000..4a6d5045 --- /dev/null +++ b/test/kuttl/tests/glance_edge/01-deploy_glance.yaml @@ -0,0 +1,5 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + oc kustomize ../../../../config/samples/layout/edge | oc apply -n $NAMESPACE -f - diff --git a/test/kuttl/tests/glance_edge/02-cleanup_glance.yaml b/test/kuttl/tests/glance_edge/02-cleanup_glance.yaml new file mode 100644 index 00000000..dab533a5 --- /dev/null +++ b/test/kuttl/tests/glance_edge/02-cleanup_glance.yaml @@ -0,0 +1,5 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + oc kustomize ../../../../config/samples/layout/split | oc delete -n $NAMESPACE -f - diff --git a/test/kuttl/tests/glance_edge/02-errors.yaml b/test/kuttl/tests/glance_edge/02-errors.yaml new file mode 100644 index 00000000..fb49d498 --- /dev/null +++ b/test/kuttl/tests/glance_edge/02-errors.yaml @@ -0,0 +1,114 @@ +# +# Check for: +# - No Glance CR +# - No GlanceAPI glance-default-external CR +# - No GlanceAPI glance-default-internal CR +# - No GlanceAPI glance-az1-edge CR +# - No GlanceAPI glance-az2-edge CR +# - No GlanceAPI glance-default-external-api StatefulSet +# - No GlanceAPI glance-default-internal-api StatefulSet +# - No GlanceAPI glance-az1-edge-api StatefulSet +# - No GlanceAPI glance-az2-edge-api StatefulSet +# - No glance-default-internal service +# - No glance-default-public service +# - No glance-default-external-headless service +# - No glance-default-internal-headless service +# - No glance-az1-internal service +# - No glance-az1-headless service +# - No glance-az2-internal service +# - No glance-az2-headless service + +apiVersion: glance.openstack.org/v1beta1 +kind: Glance +metadata: + name: glance +--- +apiVersion: glance.openstack.org/v1beta1 +kind: GlanceAPI +metadata: + name: glance-default-external +--- +apiVersion: glance.openstack.org/v1beta1 +kind: GlanceAPI +metadata: + name: glance-default-internal +--- +apiVersion: glance.openstack.org/v1beta1 +kind: GlanceAPI +metadata: + name: glance-az1-edge +--- +apiVersion: glance.openstack.org/v1beta1 +kind: GlanceAPI +metadata: + name: glance-az2-edge +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-default-external-api +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-default-internal-api +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-az1-edge-api +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-az2-edge-api +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-internal +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-public +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-internal-api +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-external-api +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-az1-internal +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-az1-public +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-az1-edge-api +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-az2-public +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-az2-internal +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-az2-edge-api