From e0b4b682926fa3ca4646a79e353422a7eb3a9c81 Mon Sep 17 00:00:00 2001 From: Maxim Sava Date: Sun, 21 Apr 2024 16:49:35 +0300 Subject: [PATCH 1/7] Add disk_format kuttl tests This patch introduces kuttl tests to check the resources that are supposed to be generated when the disk_format is defined. --- .../tests/glance_disk_formats/00-install.yaml | 182 ++++++++++++++++++ .../glance_disk_formats/01-deploy_glance.yaml | 23 +++ .../glance_disk_formats/02-create_image.yaml | 9 + .../03-cleanup-glance.yaml | 5 + .../tests/glance_disk_formats/create-image.sh | 71 +++++++ 5 files changed, 290 insertions(+) create mode 100644 test/kuttl/tests/glance_disk_formats/00-install.yaml create mode 100644 test/kuttl/tests/glance_disk_formats/01-deploy_glance.yaml create mode 100644 test/kuttl/tests/glance_disk_formats/02-create_image.yaml create mode 100644 test/kuttl/tests/glance_disk_formats/03-cleanup-glance.yaml create mode 100644 test/kuttl/tests/glance_disk_formats/create-image.sh diff --git a/test/kuttl/tests/glance_disk_formats/00-install.yaml b/test/kuttl/tests/glance_disk_formats/00-install.yaml new file mode 100644 index 00000000..dd499cff --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/00-install.yaml @@ -0,0 +1,182 @@ +# +# Check for: +# - Glance CR +# - GlanceAPI glance-single CR +# - GlanceAPI glance-api StatefulSet +# - glance-api Pod +# - glance-internal service +# - glance-public service +# - glance internal and public endpoints + +apiVersion: glance.openstack.org/v1beta1 +kind: Glance +metadata: + name: glance +spec: + serviceUser: glance + databaseInstance: openstack + databaseAccount: glance + glanceAPIs: + default: + replicas: 1 + type: "single" + secret: osp-secret + storageRequest: 10G +status: + databaseHostname: openstack.glance-kuttl-tests.svc +--- +apiVersion: glance.openstack.org/v1beta1 +kind: GlanceAPI +metadata: + name: glance-default-single +spec: + apiType: single + databaseAccount: glance + databaseHostname: openstack.glance-kuttl-tests.svc + passwordSelectors: + service: GlancePassword + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-default-single +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-single.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: v1 +kind: Pod +metadata: + labels: + service: glance +status: + phase: Running +--- +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-single + labels: + service: glance +spec: + ports: + - name: glance-default-single + port: 9292 + protocol: TCP + targetPort: 9292 + selector: + service: glance +--- +# the actual addresses of the apiEndpoints are platform specific, so we can't rely on +# kuttl asserts to check them. This short script gathers the addresses and checks that +# the three endpoints are defined and their addresses follow the default pattern +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +namespaced: true +commands: + - script: | + template='{{.status.apiEndpoint.internal}}{{":"}}{{.status.apiEndpoint.public}}{{"\n"}}' + regex="http:\/\/glance-internal.$NAMESPACE.*:http:\/\/glance-public.$NAMESPACE.*" + apiEndpoints=$(oc get -n $NAMESPACE Glance glance -o go-template="$template") + matches=$(echo "$apiEndpoints" | sed -e "s?$regex??") + if [ -z "$matches" ]; then + exit 0 + else + exit 1 + fi +--- +# Verify that Glance CRs have the containerImage defaulted from the CSV RELATED_IMAGE parameter default +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +namespaced: true +commands: + - script: | + tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}' + imageTuples=$(oc get -n openstack-operators deployment glance-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_GLANCE_\([^_]*\)_.*|\1|') + IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|') + template='{{.spec.containerImage}}' + case $NAME in + API) + SERVICE_IMAGE=$(oc get -n $NAMESPACE glance glance -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 + diff --git a/test/kuttl/tests/glance_disk_formats/01-deploy_glance.yaml b/test/kuttl/tests/glance_disk_formats/01-deploy_glance.yaml new file mode 100644 index 00000000..a39cc2ab --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/01-deploy_glance.yaml @@ -0,0 +1,23 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + oc kustomize ../../../../config/samples/layout/single | oc apply -n $NAMESPACE -f - + - script: | + oc kustomize ../../../../config/samples/disk_formats | oc apply -n $NAMESPACE -f - +--- +# Verify if disk formats is configured +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +namespaced: true +commands: + - script: | + template='{{.spec.customServiceConfig}}' + regex=regex="disk_formats" + disk_formats=$(oc get -n $NAMESPACE Glance glance -o go-template="$template") + matches=$(echo $disk_formats | sed 's/.*disk_formats=\([^ ]*\).*/\1/') + if [ -z "$matches" ]; then + exit 0 + else + exit 1 + fi diff --git a/test/kuttl/tests/glance_disk_formats/02-create_image.yaml b/test/kuttl/tests/glance_disk_formats/02-create_image.yaml new file mode 100644 index 00000000..0e5aad72 --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/02-create_image.yaml @@ -0,0 +1,9 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: | + oc -n $NAMESPACE cp create-image.sh openstackclient:/home/cloud-admin + - command: | + oc exec -it openstackclient -n $NAMESPACE -- /bin/bash -c "bash /home/cloud-admin/create-image.sh raw bare" + - command: | + oc exec -it openstackclient -n $NAMESPACE -- /bin/bash -c "bash /home/cloud-admin/create-image.sh iso bare" diff --git a/test/kuttl/tests/glance_disk_formats/03-cleanup-glance.yaml b/test/kuttl/tests/glance_disk_formats/03-cleanup-glance.yaml new file mode 100644 index 00000000..3058481e --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/03-cleanup-glance.yaml @@ -0,0 +1,5 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + oc kustomize ../../../../config/samples/layout/single | oc delete -n $NAMESPACE -f - diff --git a/test/kuttl/tests/glance_disk_formats/create-image.sh b/test/kuttl/tests/glance_disk_formats/create-image.sh new file mode 100644 index 00000000..024f86ed --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/create-image.sh @@ -0,0 +1,71 @@ +#!/bin/bash +set -evx +# Create a dummy image with disk_format and container_format +# +# The scripts assumes: +# +# 1. an available glance cli +# 2. a single layout (file / NFS) backend and disk format is deployed +# 3. pass the password via environment variable, for example: +# +# export PASSWORD=12345678 +# +# +AUTH_URL=${AUTH_URL:-"https://keystone-public.openstack.svc:5000"} +USER=${USER:-"admin"} +TIME=5 +DOMAIN=${DOMAIN:-"glance-default-single.openstack.svc:9292"} +IMAGE_NAME="myimage-test" +EXIT_CODE=$? + + +function create_image() { + # This method is create, list and delete created image + # $1 - disk format + # $2 - container format + glance="glance --os-auth-url ${AUTH_URL} \ + --os-project-name ${USER} \ + --os-username ${USER} \ + --os-password ${PASSWORD} \ + --os-user-domain-name default \ + --os-project-domain-name default " + + echo This is a dodgy image > "${IMAGE_NAME}" + + $glance --verbose image-create \ + --disk-format "$1" \ + --container-format "$2" \ + --name "${IMAGE_NAME}" + + ID=$($glance image-list | awk -v img=$IMAGE_NAME '$0 ~ img {print $2}') + echo "Image ID: $ID" + sleep "${TIME}" + + if [ -z "$ID" ] + then + echo "Could not create image " >&2; exit 1 + else + echo "Continue" + fi + + # Stage 2 - Check the image is active + $glance image-list + status=$($glance image-show "$ID" | awk '/status/{print $4}') + printf "Image Status: %s\n" "$status" + + # Stage 3 - Delete the image + $glance image-delete "$ID" + status=$($glance image-delete "$ID" | awk '/status/{print $4}') + printf "Image Status: %s\n" "$status" +} + +create_image "$1" "$2" +if [ -z $? ] +then + echo "Could not create image "; exit 1 +elif [ $EXIT_CODE == 0 ] +then + echo "Successfully created image" +else + echo "Could not create image " >&2; exit 1 +fi From 5edd3059bbfc22d1324d03ab128dfc2a86759bdd Mon Sep 17 00:00:00 2001 From: Maxim Sava Date: Sun, 21 Apr 2024 16:49:35 +0300 Subject: [PATCH 2/7] Add disk_format kuttl tests This patch introduces kuttl tests to check the resources that are supposed to be generated when the disk_format is defined. --- config/samples/disk_formats/README.md | 68 +++++++++++++++++ config/samples/disk_formats/create-image.sh | 73 +++++++++++++++++++ .../tests/glance_disk_formats/00-assert.yaml | 46 ++++++++++++ .../tests/glance_disk_formats/00-deploy.yaml | 7 ++ .../glance_disk_formats/01-create_image.yaml | 9 +++ .../tests/glance_disk_formats/02-cleanup.yaml | 5 ++ .../tests/glance_disk_formats/03-errors.yaml | 39 ++++++++++ .../kuttl/tests/glance_disk_formats/README.md | 23 ++++++ 8 files changed, 270 insertions(+) create mode 100644 config/samples/disk_formats/create-image.sh create mode 100644 test/kuttl/tests/glance_disk_formats/00-assert.yaml create mode 100644 test/kuttl/tests/glance_disk_formats/00-deploy.yaml create mode 100644 test/kuttl/tests/glance_disk_formats/01-create_image.yaml create mode 100644 test/kuttl/tests/glance_disk_formats/02-cleanup.yaml create mode 100644 test/kuttl/tests/glance_disk_formats/03-errors.yaml create mode 100644 test/kuttl/tests/glance_disk_formats/README.md diff --git a/config/samples/disk_formats/README.md b/config/samples/disk_formats/README.md index 3e2e92f0..9911931d 100644 --- a/config/samples/disk_formats/README.md +++ b/config/samples/disk_formats/README.md @@ -59,3 +59,71 @@ from this directory to make the changes. You can find more about disk-formats configuration options in the [upstream](https://docs.openstack.org/glance/latest/configuration/configuring.html#configuring-supported-disk-formats) documentation. + +## How to test +The steps and overview about a feature described in [disk-format](../../../../config/samples/disk_formats/) document +We assume one GlanceAPIs exist, disk format is enabled with disk formats +'raw, iso' and image is created with same disk format. + +### Step 1: Create image +In this step we create images with 'raw' and 'iso' disk formats +```bash + $glance --verbose image-create \ + --disk-format "$1" \ + --container-format bare \ + --name "${IMAGE_NAME}" +``` + +## EXAMPLE + +The example assumes a glanceAPI is deployed using [single layout](https://github.com/openstack-k8s-operators/glance-operator/tree/main/config/samples/layout/single). + +Copy the [`create-image.sh`](create-image.sh) script to the target container +where the `glance` cli is available. +For example: + +```bash +$oc cp create-image.sh openstackclient:/scripts +``` + +Create image with 'raw' disk format + +```bash +sh-5.1# bash create-image.sh raw +glance --os-auth-url https://keystone-public-openstack.apps-crc.testing --os-project-name admin --os-username admin --os-password 12345678 --os-user-domain- +name default --os-project-domain-name default --verbose image-create --disk-format raw --container-format bare --name myimage-disk_format-test ++------------------+--------------------------------------+ +| Property | Value | ++------------------+--------------------------------------+ +| checksum | None | +| container_format | bare | +| created_at | 2024-05-02T13:15:45Z | +| disk_format | raw | +| id | 32737bf5-2546-4d6f-9800-80cc5afed30d | +| locations | [] | +| min_disk | 0 | +| min_ram | 0 | +| name | myimage-disk_format-test | +| os_hash_algo | None | +| os_hash_value | None | +| os_hidden | False | +| owner | 7ac7162bc58f44af824fd8f2ce68987f | +| protected | False | +| size | None | +| status | queued | +| tags | [] | +| updated_at | 2024-05-02T13:15:45Z | +| virtual_size | Not available | +| visibility | shared | ++------------------+--------------------------------------+ + +glance --os-auth-url https://keystone-public-openstack.apps-crc.testing --os-project-name admin --os-username admin --os-password 12345678 --os-user-domain-name default --os-project-domain-name default image-list ++--------------------------------------+--------------------------+ +| ID | Name | ++--------------------------------------+--------------------------+ +| 32737bf5-2546-4d6f-9800-80cc5afed30d | myimage-disk_format-test | ++--------------------------------------+--------------------------+ + ++ echo 'Successfully created image' +Successfully created image +``` diff --git a/config/samples/disk_formats/create-image.sh b/config/samples/disk_formats/create-image.sh new file mode 100644 index 00000000..5d53b5f5 --- /dev/null +++ b/config/samples/disk_formats/create-image.sh @@ -0,0 +1,73 @@ +#!/bin/bash +set -evx +# Create a image with supported disk format +# +# The scripts assumes: +# +# 1. an available glance cli +# 2. control plane configured with disk formats +# 2. a single layout (file / NFS) backend and disk format is deployed +# +# +KEYSTONE=$(awk '/auth_url/ {print $2}' "/$HOME/.config/openstack/clouds.yaml") +USER=${USER:-"admin"} +TIME=5 +DOMAIN=${DOMAIN:-"glance-default-single.openstack.svc:9292"} +IMAGE_NAME="myimage-disk_format-test" +ADMIN_PWD=${ADMIN_PWD:-12345678} +EXIT_CODE=$? + + +function create_image() { + # This method is create, list and delete image + # $1 - disk format + glance="glance --os-auth-url ${KEYSTONE} + --os-project-name ${USER} \ + --os-username ${USER} \ + --os-password ${ADMIN_PWD} \ + --os-user-domain-name default \ + --os-project-domain-name default " + + echo This is a dodgy image > "${IMAGE_NAME}" + + $glance --verbose image-create \ + --disk-format "$1" \ + --container-format bare \ + --name "${IMAGE_NAME}" + + ID=$($glance image-list | awk -v img=$IMAGE_NAME '$0 ~ img {print $2}') + echo "Image ID: $ID" + sleep "${TIME}" + + if [ -z "$ID" ] + then + echo "Could not create image " >&2 + $glance image-delete "$ID" + status=$($glance image-delete "$ID" | awk '/status/{print $4}') + printf "Image Status: %s\n" "$status" + exit 1 + else + echo "Continue" + fi + + # Stage 2 - Check the image is active + $glance image-list + status=$($glance image-show "$ID" | awk '/status/{print $4}') + printf "Image Status: %s\n" "$status" + + # Stage 3 - Delete the image + $glance image-delete "$ID" + status=$($glance image-delete "$ID" | awk '/status/{print $4}') + printf "Image Status: %s\n" "$status" +} + +create_image "$1" +if [ -z $? ] +then + echo "Could not create image "; exit 1 +elif [ $EXIT_CODE == 0 ] +then + echo "Successfully created image" +else + echo "Could not create image " >&2; exit 1 +fi diff --git a/test/kuttl/tests/glance_disk_formats/00-assert.yaml b/test/kuttl/tests/glance_disk_formats/00-assert.yaml new file mode 100644 index 00000000..5fb0bf98 --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/00-assert.yaml @@ -0,0 +1,46 @@ +# Check for: +# - Glance CR with 1 replicas for a single GlanceAPI +# - GlanceAPI glance-default-single StatefulSet with 1 replicas +# - OpenStackClient Pod available + +apiVersion: glance.openstack.org/v1beta1 +kind: Glance +metadata: + name: glance +spec: + glanceAPIs: + default: + replicas: 1 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-default-single +spec: + replicas: 1 +status: + availableReplicas: 1 + replicas: 1 +--- +apiVersion: v1 +kind: Pod +metadata: + name: openstackclient + labels: + service: openstackclient +--- +# Verify if disk formats is configured +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +namespaced: true +commands: + - script: | + template='{{.spec.customServiceConfig}}' + regex="disk_formats" + disk_formats=$(oc get -n $NAMESPACE Glance glance -o go-template="$template") + matches=$(echo $disk_formats | sed 's/.*disk_formats=\([^ ]*\).*/\1/') + if [ -z "$matches" ]; then + exit 1 + else + exit 0 + fi diff --git a/test/kuttl/tests/glance_disk_formats/00-deploy.yaml b/test/kuttl/tests/glance_disk_formats/00-deploy.yaml new file mode 100644 index 00000000..711258ed --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/00-deploy.yaml @@ -0,0 +1,7 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + oc kustomize ../../../../config/samples/layout/single | oc apply -n $NAMESPACE -f - + - script: | + oc kustomize ../../../../config/samples/disk_formats | oc apply -n $NAMESPACE -f - diff --git a/test/kuttl/tests/glance_disk_formats/01-create_image.yaml b/test/kuttl/tests/glance_disk_formats/01-create_image.yaml new file mode 100644 index 00000000..c04c2a23 --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/01-create_image.yaml @@ -0,0 +1,9 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - command: | + # oc exec -it openstackclient -n $NAMESPACE -- /bin/bash -c "bash /home/cloud-admin/create-image.sh raw" + oc -n $NAMESPACE exec -it openstackclient --stdin=false -- /bin/sh -c "DOMAIN=glance-default-single.$NAMESPACE.svc ./scripts/create-image.sh raw" + - command: | + # oc exec -it openstackclient -n $NAMESPACE -- /bin/bash -c "bash /home/cloud-admin/create-image.sh iso" + oc -n $NAMESPACE exec -it openstackclient --stdin=false -- /bin/sh -c "DOMAIN=glance-default-single.$NAMESPACE.svc ./scripts/create-image.sh iso" diff --git a/test/kuttl/tests/glance_disk_formats/02-cleanup.yaml b/test/kuttl/tests/glance_disk_formats/02-cleanup.yaml new file mode 100644 index 00000000..3058481e --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/02-cleanup.yaml @@ -0,0 +1,5 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: | + oc kustomize ../../../../config/samples/layout/single | oc delete -n $NAMESPACE -f - diff --git a/test/kuttl/tests/glance_disk_formats/03-errors.yaml b/test/kuttl/tests/glance_disk_formats/03-errors.yaml new file mode 100644 index 00000000..9f4bef69 --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/03-errors.yaml @@ -0,0 +1,39 @@ +# +# Check for: +# - No Glance CR +# - No GlanceAPI glance-single CR +# - No GlanceAPI glance-api StatefulSet +# - No glance-api Pod +# - No glance-public service +# - No glance internal and public endpoints + +apiVersion: glance.openstack.org/v1beta1 +kind: Glance +metadata: + name: glance +--- +apiVersion: glance.openstack.org/v1beta1 +kind: GlanceAPI +metadata: + name: glance-default-single +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-default-single +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + service: glance +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-internal +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-public diff --git a/test/kuttl/tests/glance_disk_formats/README.md b/test/kuttl/tests/glance_disk_formats/README.md new file mode 100644 index 00000000..5e699176 --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/README.md @@ -0,0 +1,23 @@ +# How to test + +The goal of this test is to verify if user can set disk format for image that should be created + +## Kuttl test steps +The steps and overview about a feature described in [disk-format](../../../../config/samples/disk_formats/) document +We assume one GlanceAPIs exist, disk format is enabled with disk formats +'raw, iso' and image is created with same disk format. + +### Step 1: Create image +In this step we create images with disk formats 'raw,iso' +```bash + $glance --verbose image-create \ + --disk-format "$1" \ + --container-format bare \ + --name "${IMAGE_NAME}" +``` + +## Conclusion +The steps described above are automated by this +[script](../../../../config/samples/glance_disk_formats/create-image.sh) +that is executed by the kuttl test once the environment is deployed and the +`openstackclient` is ready. From b02ae9645a53e0a6de3232f37ed3142ca321e409 Mon Sep 17 00:00:00 2001 From: Maxim Sava Date: Sun, 21 Apr 2024 16:49:35 +0300 Subject: [PATCH 3/7] Add disk_format kuttl tests This patch introduces kuttl tests to check the resources that are supposed to be generated when the disk_format is defined. --- config/samples/disk_formats/README.md | 11 +++--- config/samples/disk_formats/create-image.sh | 30 +++++--------- .../glance_disk_formats/01-create_image.yaml | 2 - .../tests/glance_disk_formats/02-errors.yaml | 39 +++++++++++++++++++ .../kuttl/tests/glance_disk_formats/README.md | 4 +- 5 files changed, 56 insertions(+), 30 deletions(-) create mode 100644 test/kuttl/tests/glance_disk_formats/02-errors.yaml diff --git a/config/samples/disk_formats/README.md b/config/samples/disk_formats/README.md index 9911931d..d7decd1a 100644 --- a/config/samples/disk_formats/README.md +++ b/config/samples/disk_formats/README.md @@ -68,10 +68,10 @@ We assume one GlanceAPIs exist, disk format is enabled with disk formats ### Step 1: Create image In this step we create images with 'raw' and 'iso' disk formats ```bash - $glance --verbose image-create \ + openstack image create \ --disk-format "$1" \ --container-format bare \ - --name "${IMAGE_NAME}" + "${IMAGE_NAME}" ``` ## EXAMPLE @@ -79,7 +79,7 @@ In this step we create images with 'raw' and 'iso' disk formats The example assumes a glanceAPI is deployed using [single layout](https://github.com/openstack-k8s-operators/glance-operator/tree/main/config/samples/layout/single). Copy the [`create-image.sh`](create-image.sh) script to the target container -where the `glance` cli is available. +where the `openstack` cli is available. For example: ```bash @@ -90,8 +90,7 @@ Create image with 'raw' disk format ```bash sh-5.1# bash create-image.sh raw -glance --os-auth-url https://keystone-public-openstack.apps-crc.testing --os-project-name admin --os-username admin --os-password 12345678 --os-user-domain- -name default --os-project-domain-name default --verbose image-create --disk-format raw --container-format bare --name myimage-disk_format-test +openstack image create --disk-format raw --container-format bare myimage-disk_format-test +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ @@ -117,7 +116,7 @@ name default --os-project-domain-name default --verbose image-create --disk-form | visibility | shared | +------------------+--------------------------------------+ -glance --os-auth-url https://keystone-public-openstack.apps-crc.testing --os-project-name admin --os-username admin --os-password 12345678 --os-user-domain-name default --os-project-domain-name default image-list ++ openstack image list +--------------------------------------+--------------------------+ | ID | Name | +--------------------------------------+--------------------------+ diff --git a/config/samples/disk_formats/create-image.sh b/config/samples/disk_formats/create-image.sh index 5d53b5f5..ac36a8d7 100644 --- a/config/samples/disk_formats/create-image.sh +++ b/config/samples/disk_formats/create-image.sh @@ -4,46 +4,36 @@ set -evx # # The scripts assumes: # -# 1. an available glance cli +# 1. an available openstack cli # 2. control plane configured with disk formats # 2. a single layout (file / NFS) backend and disk format is deployed # # -KEYSTONE=$(awk '/auth_url/ {print $2}' "/$HOME/.config/openstack/clouds.yaml") -USER=${USER:-"admin"} TIME=5 -DOMAIN=${DOMAIN:-"glance-default-single.openstack.svc:9292"} IMAGE_NAME="myimage-disk_format-test" -ADMIN_PWD=${ADMIN_PWD:-12345678} EXIT_CODE=$? function create_image() { # This method is create, list and delete image # $1 - disk format - glance="glance --os-auth-url ${KEYSTONE} - --os-project-name ${USER} \ - --os-username ${USER} \ - --os-password ${ADMIN_PWD} \ - --os-user-domain-name default \ - --os-project-domain-name default " echo This is a dodgy image > "${IMAGE_NAME}" - $glance --verbose image-create \ + openstack image create \ --disk-format "$1" \ --container-format bare \ - --name "${IMAGE_NAME}" + "${IMAGE_NAME}" - ID=$($glance image-list | awk -v img=$IMAGE_NAME '$0 ~ img {print $2}') + ID=$(openstack image list | awk -v img=$IMAGE_NAME '$0 ~ img {print $2}') echo "Image ID: $ID" sleep "${TIME}" if [ -z "$ID" ] then echo "Could not create image " >&2 - $glance image-delete "$ID" - status=$($glance image-delete "$ID" | awk '/status/{print $4}') + openstack image delete "$ID" + status=$(openstack image delete "$ID" | awk '/status/{print $4}') printf "Image Status: %s\n" "$status" exit 1 else @@ -51,13 +41,13 @@ function create_image() { fi # Stage 2 - Check the image is active - $glance image-list - status=$($glance image-show "$ID" | awk '/status/{print $4}') + openstack image list + status=$(openstack image show "$ID" | awk '/status/{print $4}') printf "Image Status: %s\n" "$status" # Stage 3 - Delete the image - $glance image-delete "$ID" - status=$($glance image-delete "$ID" | awk '/status/{print $4}') + openstack image delete "$ID" + status=$(openstack image delete "$ID" | awk '/status/{print $4}') printf "Image Status: %s\n" "$status" } diff --git a/test/kuttl/tests/glance_disk_formats/01-create_image.yaml b/test/kuttl/tests/glance_disk_formats/01-create_image.yaml index c04c2a23..e7585a37 100644 --- a/test/kuttl/tests/glance_disk_formats/01-create_image.yaml +++ b/test/kuttl/tests/glance_disk_formats/01-create_image.yaml @@ -2,8 +2,6 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep commands: - command: | - # oc exec -it openstackclient -n $NAMESPACE -- /bin/bash -c "bash /home/cloud-admin/create-image.sh raw" oc -n $NAMESPACE exec -it openstackclient --stdin=false -- /bin/sh -c "DOMAIN=glance-default-single.$NAMESPACE.svc ./scripts/create-image.sh raw" - command: | - # oc exec -it openstackclient -n $NAMESPACE -- /bin/bash -c "bash /home/cloud-admin/create-image.sh iso" oc -n $NAMESPACE exec -it openstackclient --stdin=false -- /bin/sh -c "DOMAIN=glance-default-single.$NAMESPACE.svc ./scripts/create-image.sh iso" diff --git a/test/kuttl/tests/glance_disk_formats/02-errors.yaml b/test/kuttl/tests/glance_disk_formats/02-errors.yaml new file mode 100644 index 00000000..9f4bef69 --- /dev/null +++ b/test/kuttl/tests/glance_disk_formats/02-errors.yaml @@ -0,0 +1,39 @@ +# +# Check for: +# - No Glance CR +# - No GlanceAPI glance-single CR +# - No GlanceAPI glance-api StatefulSet +# - No glance-api Pod +# - No glance-public service +# - No glance internal and public endpoints + +apiVersion: glance.openstack.org/v1beta1 +kind: Glance +metadata: + name: glance +--- +apiVersion: glance.openstack.org/v1beta1 +kind: GlanceAPI +metadata: + name: glance-default-single +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: glance-default-single +--- +apiVersion: v1 +kind: Pod +metadata: + labels: + service: glance +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-internal +--- +apiVersion: v1 +kind: Service +metadata: + name: glance-default-public diff --git a/test/kuttl/tests/glance_disk_formats/README.md b/test/kuttl/tests/glance_disk_formats/README.md index 5e699176..ecd01eae 100644 --- a/test/kuttl/tests/glance_disk_formats/README.md +++ b/test/kuttl/tests/glance_disk_formats/README.md @@ -10,10 +10,10 @@ We assume one GlanceAPIs exist, disk format is enabled with disk formats ### Step 1: Create image In this step we create images with disk formats 'raw,iso' ```bash - $glance --verbose image-create \ + $openstack image create \ --disk-format "$1" \ --container-format bare \ - --name "${IMAGE_NAME}" + "${IMAGE_NAME}" ``` ## Conclusion From 5a46b3b7199dc04c5454a717374541e04a1299a2 Mon Sep 17 00:00:00 2001 From: Maxim Sava Date: Sun, 21 Apr 2024 16:49:35 +0300 Subject: [PATCH 4/7] Add disk_format kuttl tests This patch introduces kuttl tests to check the resources that are supposed to be generated when the disk_format is defined. --- .../tests/glance_disk_formats/00-install.yaml | 182 ------------------ .../glance_disk_formats/01-deploy_glance.yaml | 23 --- .../glance_disk_formats/02-create_image.yaml | 9 - .../03-cleanup-glance.yaml | 5 - .../tests/glance_disk_formats/03-errors.yaml | 39 ---- .../tests/glance_disk_formats/create-image.sh | 71 ------- 6 files changed, 329 deletions(-) delete mode 100644 test/kuttl/tests/glance_disk_formats/00-install.yaml delete mode 100644 test/kuttl/tests/glance_disk_formats/01-deploy_glance.yaml delete mode 100644 test/kuttl/tests/glance_disk_formats/02-create_image.yaml delete mode 100644 test/kuttl/tests/glance_disk_formats/03-cleanup-glance.yaml delete mode 100644 test/kuttl/tests/glance_disk_formats/03-errors.yaml delete mode 100644 test/kuttl/tests/glance_disk_formats/create-image.sh diff --git a/test/kuttl/tests/glance_disk_formats/00-install.yaml b/test/kuttl/tests/glance_disk_formats/00-install.yaml deleted file mode 100644 index dd499cff..00000000 --- a/test/kuttl/tests/glance_disk_formats/00-install.yaml +++ /dev/null @@ -1,182 +0,0 @@ -# -# Check for: -# - Glance CR -# - GlanceAPI glance-single CR -# - GlanceAPI glance-api StatefulSet -# - glance-api Pod -# - glance-internal service -# - glance-public service -# - glance internal and public endpoints - -apiVersion: glance.openstack.org/v1beta1 -kind: Glance -metadata: - name: glance -spec: - serviceUser: glance - databaseInstance: openstack - databaseAccount: glance - glanceAPIs: - default: - replicas: 1 - type: "single" - secret: osp-secret - storageRequest: 10G -status: - databaseHostname: openstack.glance-kuttl-tests.svc ---- -apiVersion: glance.openstack.org/v1beta1 -kind: GlanceAPI -metadata: - name: glance-default-single -spec: - apiType: single - databaseAccount: glance - databaseHostname: openstack.glance-kuttl-tests.svc - passwordSelectors: - service: GlancePassword - replicas: 1 ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: glance-default-single -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-single.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: v1 -kind: Pod -metadata: - labels: - service: glance -status: - phase: Running ---- -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-single - labels: - service: glance -spec: - ports: - - name: glance-default-single - port: 9292 - protocol: TCP - targetPort: 9292 - selector: - service: glance ---- -# the actual addresses of the apiEndpoints are platform specific, so we can't rely on -# kuttl asserts to check them. This short script gathers the addresses and checks that -# the three endpoints are defined and their addresses follow the default pattern -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -namespaced: true -commands: - - script: | - template='{{.status.apiEndpoint.internal}}{{":"}}{{.status.apiEndpoint.public}}{{"\n"}}' - regex="http:\/\/glance-internal.$NAMESPACE.*:http:\/\/glance-public.$NAMESPACE.*" - apiEndpoints=$(oc get -n $NAMESPACE Glance glance -o go-template="$template") - matches=$(echo "$apiEndpoints" | sed -e "s?$regex??") - if [ -z "$matches" ]; then - exit 0 - else - exit 1 - fi ---- -# Verify that Glance CRs have the containerImage defaulted from the CSV RELATED_IMAGE parameter default -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -namespaced: true -commands: - - script: | - tupleTemplate='{{ range (index .spec.template.spec.containers 1).env }}{{ .name }}{{ "#" }}{{ .value}}{{"\n"}}{{ end }}' - imageTuples=$(oc get -n openstack-operators deployment glance-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_GLANCE_\([^_]*\)_.*|\1|') - IMG_FROM_ENV=$(echo $ITEM | sed -e 's|^.*#\(.*\)|\1|') - template='{{.spec.containerImage}}' - case $NAME in - API) - SERVICE_IMAGE=$(oc get -n $NAMESPACE glance glance -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 - diff --git a/test/kuttl/tests/glance_disk_formats/01-deploy_glance.yaml b/test/kuttl/tests/glance_disk_formats/01-deploy_glance.yaml deleted file mode 100644 index a39cc2ab..00000000 --- a/test/kuttl/tests/glance_disk_formats/01-deploy_glance.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: | - oc kustomize ../../../../config/samples/layout/single | oc apply -n $NAMESPACE -f - - - script: | - oc kustomize ../../../../config/samples/disk_formats | oc apply -n $NAMESPACE -f - ---- -# Verify if disk formats is configured -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -namespaced: true -commands: - - script: | - template='{{.spec.customServiceConfig}}' - regex=regex="disk_formats" - disk_formats=$(oc get -n $NAMESPACE Glance glance -o go-template="$template") - matches=$(echo $disk_formats | sed 's/.*disk_formats=\([^ ]*\).*/\1/') - if [ -z "$matches" ]; then - exit 0 - else - exit 1 - fi diff --git a/test/kuttl/tests/glance_disk_formats/02-create_image.yaml b/test/kuttl/tests/glance_disk_formats/02-create_image.yaml deleted file mode 100644 index 0e5aad72..00000000 --- a/test/kuttl/tests/glance_disk_formats/02-create_image.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - command: | - oc -n $NAMESPACE cp create-image.sh openstackclient:/home/cloud-admin - - command: | - oc exec -it openstackclient -n $NAMESPACE -- /bin/bash -c "bash /home/cloud-admin/create-image.sh raw bare" - - command: | - oc exec -it openstackclient -n $NAMESPACE -- /bin/bash -c "bash /home/cloud-admin/create-image.sh iso bare" diff --git a/test/kuttl/tests/glance_disk_formats/03-cleanup-glance.yaml b/test/kuttl/tests/glance_disk_formats/03-cleanup-glance.yaml deleted file mode 100644 index 3058481e..00000000 --- a/test/kuttl/tests/glance_disk_formats/03-cleanup-glance.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: | - oc kustomize ../../../../config/samples/layout/single | oc delete -n $NAMESPACE -f - diff --git a/test/kuttl/tests/glance_disk_formats/03-errors.yaml b/test/kuttl/tests/glance_disk_formats/03-errors.yaml deleted file mode 100644 index 9f4bef69..00000000 --- a/test/kuttl/tests/glance_disk_formats/03-errors.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# -# Check for: -# - No Glance CR -# - No GlanceAPI glance-single CR -# - No GlanceAPI glance-api StatefulSet -# - No glance-api Pod -# - No glance-public service -# - No glance internal and public endpoints - -apiVersion: glance.openstack.org/v1beta1 -kind: Glance -metadata: - name: glance ---- -apiVersion: glance.openstack.org/v1beta1 -kind: GlanceAPI -metadata: - name: glance-default-single ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: glance-default-single ---- -apiVersion: v1 -kind: Pod -metadata: - labels: - service: glance ---- -apiVersion: v1 -kind: Service -metadata: - name: glance-default-internal ---- -apiVersion: v1 -kind: Service -metadata: - name: glance-default-public diff --git a/test/kuttl/tests/glance_disk_formats/create-image.sh b/test/kuttl/tests/glance_disk_formats/create-image.sh deleted file mode 100644 index 024f86ed..00000000 --- a/test/kuttl/tests/glance_disk_formats/create-image.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -set -evx -# Create a dummy image with disk_format and container_format -# -# The scripts assumes: -# -# 1. an available glance cli -# 2. a single layout (file / NFS) backend and disk format is deployed -# 3. pass the password via environment variable, for example: -# -# export PASSWORD=12345678 -# -# -AUTH_URL=${AUTH_URL:-"https://keystone-public.openstack.svc:5000"} -USER=${USER:-"admin"} -TIME=5 -DOMAIN=${DOMAIN:-"glance-default-single.openstack.svc:9292"} -IMAGE_NAME="myimage-test" -EXIT_CODE=$? - - -function create_image() { - # This method is create, list and delete created image - # $1 - disk format - # $2 - container format - glance="glance --os-auth-url ${AUTH_URL} \ - --os-project-name ${USER} \ - --os-username ${USER} \ - --os-password ${PASSWORD} \ - --os-user-domain-name default \ - --os-project-domain-name default " - - echo This is a dodgy image > "${IMAGE_NAME}" - - $glance --verbose image-create \ - --disk-format "$1" \ - --container-format "$2" \ - --name "${IMAGE_NAME}" - - ID=$($glance image-list | awk -v img=$IMAGE_NAME '$0 ~ img {print $2}') - echo "Image ID: $ID" - sleep "${TIME}" - - if [ -z "$ID" ] - then - echo "Could not create image " >&2; exit 1 - else - echo "Continue" - fi - - # Stage 2 - Check the image is active - $glance image-list - status=$($glance image-show "$ID" | awk '/status/{print $4}') - printf "Image Status: %s\n" "$status" - - # Stage 3 - Delete the image - $glance image-delete "$ID" - status=$($glance image-delete "$ID" | awk '/status/{print $4}') - printf "Image Status: %s\n" "$status" -} - -create_image "$1" "$2" -if [ -z $? ] -then - echo "Could not create image "; exit 1 -elif [ $EXIT_CODE == 0 ] -then - echo "Successfully created image" -else - echo "Could not create image " >&2; exit 1 -fi From 855106476d3074ea66c80b0b307b075fcc8a4914 Mon Sep 17 00:00:00 2001 From: Maxim Sava Date: Sun, 21 Apr 2024 16:49:35 +0300 Subject: [PATCH 5/7] Add disk_format kuttl tests This patch introduces kuttl tests to check the resources that are supposed to be generated when the disk_format is defined. --- config/samples/disk_formats/README.md | 10 +++---- config/samples/disk_formats/create-image.sh | 31 +++++++++++---------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/config/samples/disk_formats/README.md b/config/samples/disk_formats/README.md index d7decd1a..2701d30a 100644 --- a/config/samples/disk_formats/README.md +++ b/config/samples/disk_formats/README.md @@ -117,11 +117,11 @@ openstack image create --disk-format raw --container-format bare myimage-disk_fo +------------------+--------------------------------------+ + openstack image list -+--------------------------------------+--------------------------+ -| ID | Name | -+--------------------------------------+--------------------------+ -| 32737bf5-2546-4d6f-9800-80cc5afed30d | myimage-disk_format-test | -+--------------------------------------+--------------------------+ ++--------------------------------------+--------------------------+--------+ +| ID | Name | Status | ++--------------------------------------+--------------------------+--------+ +| 5bdde056-b7c6-451d-a7dd-cbee9c8ed4a5 | myimage-disk_format-test | active | ++--------------------------------------+--------------------------+--------+ + echo 'Successfully created image' Successfully created image diff --git a/config/samples/disk_formats/create-image.sh b/config/samples/disk_formats/create-image.sh index ac36a8d7..31416ad9 100644 --- a/config/samples/disk_formats/create-image.sh +++ b/config/samples/disk_formats/create-image.sh @@ -5,8 +5,8 @@ set -evx # The scripts assumes: # # 1. an available openstack cli -# 2. control plane configured with disk formats -# 2. a single layout (file / NFS) backend and disk format is deployed +# 2. glanceAPI configured with disk formats +# 3. a single layout (file / NFS) backend and disk format is deployed # # TIME=5 @@ -20,10 +20,15 @@ function create_image() { echo This is a dodgy image > "${IMAGE_NAME}" + # Stage 0 - Delete any pre-existing image + openstack image list -c ID -f value | xargs -n 1 openstack image delete + sleep "${TIME}" + + # Stage 1 - Create image openstack image create \ --disk-format "$1" \ --container-format bare \ - "${IMAGE_NAME}" + "${IMAGE_NAME}" ID=$(openstack image list | awk -v img=$IMAGE_NAME '$0 ~ img {print $2}') echo "Image ID: $ID" @@ -31,24 +36,22 @@ function create_image() { if [ -z "$ID" ] then - echo "Could not create image " >&2 - openstack image delete "$ID" - status=$(openstack image delete "$ID" | awk '/status/{print $4}') - printf "Image Status: %s\n" "$status" + openstack image list -c ID -f value | xargs -n 1 openstack image delete exit 1 - else - echo "Continue" fi # Stage 2 - Check the image is active openstack image list status=$(openstack image show "$ID" | awk '/status/{print $4}') - printf "Image Status: %s\n" "$status" + if [ "$status" == 'active' ] + then + printf "Image Status: %s\n" "$status" + exit 0 + else + printf "Image Status: %s\n" "$status" + exit 1 + fi - # Stage 3 - Delete the image - openstack image delete "$ID" - status=$(openstack image delete "$ID" | awk '/status/{print $4}') - printf "Image Status: %s\n" "$status" } create_image "$1" From 559678fcf03ceb6e241bb5f704f39a642a34c409 Mon Sep 17 00:00:00 2001 From: Maxim Sava Date: Sun, 21 Apr 2024 16:49:35 +0300 Subject: [PATCH 6/7] Add disk_format kuttl tests This patch introduces kuttl tests to check the resources that are supposed to be generated when the disk_format is defined. --- config/samples/disk_formats/create-image.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/samples/disk_formats/create-image.sh b/config/samples/disk_formats/create-image.sh index 31416ad9..415311b0 100644 --- a/config/samples/disk_formats/create-image.sh +++ b/config/samples/disk_formats/create-image.sh @@ -12,6 +12,7 @@ set -evx TIME=5 IMAGE_NAME="myimage-disk_format-test" EXIT_CODE=$? +DEBUG=0 function create_image() { @@ -41,7 +42,9 @@ function create_image() { fi # Stage 2 - Check the image is active - openstack image list + if [ "$DEBUG" -eq 1 ]; then + openstack image list + status=$(openstack image show "$ID" | awk '/status/{print $4}') if [ "$status" == 'active' ] then From 119dc0fdfed02fbcdf14395e0ad425a25d028cd5 Mon Sep 17 00:00:00 2001 From: Maxim Sava Date: Sun, 21 Apr 2024 16:49:35 +0300 Subject: [PATCH 7/7] Add disk_format kuttl tests This patch introduces kuttl tests to check the resources that are supposed to be generated when the disk_format is defined. --- .../samples/layout/disk_format/disk_format.yaml | 17 +++++++++++++++++ .../tests/glance_disk_formats/00-deploy.yaml | 2 +- .../glance_disk_formats/01-create_image.yaml | 4 ++-- .../tests/glance_disk_formats/02-cleanup.yaml | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 config/samples/layout/disk_format/disk_format.yaml diff --git a/config/samples/layout/disk_format/disk_format.yaml b/config/samples/layout/disk_format/disk_format.yaml new file mode 100644 index 00000000..45dc51dc --- /dev/null +++ b/config/samples/layout/disk_format/disk_format.yaml @@ -0,0 +1,17 @@ +# Inject inject_metadata config +apiVersion: glance.openstack.org/v1beta1 +kind: Glance +metadata: + name: glance +spec: + serviceUser: glance + databaseInstance: openstack + databaseAccount: glance + keystoneEndpoint: default + customServiceConfig: | + [image_format] + disk_formats=raw,iso + glanceAPIs: + default: + type: single + replicas: 1 diff --git a/test/kuttl/tests/glance_disk_formats/00-deploy.yaml b/test/kuttl/tests/glance_disk_formats/00-deploy.yaml index 711258ed..aa23c869 100644 --- a/test/kuttl/tests/glance_disk_formats/00-deploy.yaml +++ b/test/kuttl/tests/glance_disk_formats/00-deploy.yaml @@ -2,6 +2,6 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep commands: - script: | - oc kustomize ../../../../config/samples/layout/single | oc apply -n $NAMESPACE -f - + oc kustomize ../../../../config/samples/layout/disk_format | oc apply -n $NAMESPACE -f - - script: | oc kustomize ../../../../config/samples/disk_formats | oc apply -n $NAMESPACE -f - diff --git a/test/kuttl/tests/glance_disk_formats/01-create_image.yaml b/test/kuttl/tests/glance_disk_formats/01-create_image.yaml index e7585a37..a993ddcb 100644 --- a/test/kuttl/tests/glance_disk_formats/01-create_image.yaml +++ b/test/kuttl/tests/glance_disk_formats/01-create_image.yaml @@ -2,6 +2,6 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep commands: - command: | - oc -n $NAMESPACE exec -it openstackclient --stdin=false -- /bin/sh -c "DOMAIN=glance-default-single.$NAMESPACE.svc ./scripts/create-image.sh raw" + oc -n $NAMESPACE exec -it openstackclient --stdin=false -- /bin/sh -c "./scripts/create-image.sh raw" - command: | - oc -n $NAMESPACE exec -it openstackclient --stdin=false -- /bin/sh -c "DOMAIN=glance-default-single.$NAMESPACE.svc ./scripts/create-image.sh iso" + oc -n $NAMESPACE exec -it openstackclient --stdin=false -- /bin/sh -c "./scripts/create-image.sh iso" diff --git a/test/kuttl/tests/glance_disk_formats/02-cleanup.yaml b/test/kuttl/tests/glance_disk_formats/02-cleanup.yaml index 3058481e..10b01d93 100644 --- a/test/kuttl/tests/glance_disk_formats/02-cleanup.yaml +++ b/test/kuttl/tests/glance_disk_formats/02-cleanup.yaml @@ -2,4 +2,4 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep commands: - script: | - oc kustomize ../../../../config/samples/layout/single | oc delete -n $NAMESPACE -f - + oc kustomize ../../../../config/samples/layout/disk_format | oc delete -n $NAMESPACE -f -