From ae12adee4fdff41b7dc85535905fe0a2fcc017f2 Mon Sep 17 00:00:00 2001 From: jgilaber Date: Thu, 28 Nov 2024 11:32:24 +0100 Subject: [PATCH] Add kuttl tests for WatcherAPI --- .../default/common/cleanup-watcher.yaml | 1 - .../default/common/deploy-with-defaults.yaml | 7 +++++ .../default/test/01-deploy-with-defaults.yaml | 8 +----- .../watcher-api/00-cleanup-watcher.yaml | 1 + .../watcher-api/01-cleanup-watcherapi.yaml | 6 +++++ .../watcher-api/02-deploy-with-defaults.yaml | 1 + .../default/watcher-api/03-assert.yaml | 26 +++++++++++++++++++ .../watcher-api/03-deploy-watcher-api.yaml | 6 +++++ .../watcher-api/04-cleanup-watcher.yaml | 1 + .../default/watcher-api/05-assert.yaml | 9 +++++++ .../watcher-api/05-cleanup-watcherapi.yaml | 1 + 11 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 tests/kuttl/test-suites/default/common/deploy-with-defaults.yaml mode change 100644 => 120000 tests/kuttl/test-suites/default/test/01-deploy-with-defaults.yaml create mode 120000 tests/kuttl/test-suites/default/watcher-api/00-cleanup-watcher.yaml create mode 100644 tests/kuttl/test-suites/default/watcher-api/01-cleanup-watcherapi.yaml create mode 120000 tests/kuttl/test-suites/default/watcher-api/02-deploy-with-defaults.yaml create mode 100644 tests/kuttl/test-suites/default/watcher-api/03-assert.yaml create mode 100644 tests/kuttl/test-suites/default/watcher-api/03-deploy-watcher-api.yaml create mode 120000 tests/kuttl/test-suites/default/watcher-api/04-cleanup-watcher.yaml create mode 100644 tests/kuttl/test-suites/default/watcher-api/05-assert.yaml create mode 120000 tests/kuttl/test-suites/default/watcher-api/05-cleanup-watcherapi.yaml diff --git a/tests/kuttl/test-suites/default/common/cleanup-watcher.yaml b/tests/kuttl/test-suites/default/common/cleanup-watcher.yaml index 31bb5ab..7205146 100644 --- a/tests/kuttl/test-suites/default/common/cleanup-watcher.yaml +++ b/tests/kuttl/test-suites/default/common/cleanup-watcher.yaml @@ -4,4 +4,3 @@ delete: - apiVersion: watcher.openstack.org/v1beta1 kind: Watcher name: watcher-kuttl - namespace: watcher-kuttl-default diff --git a/tests/kuttl/test-suites/default/common/deploy-with-defaults.yaml b/tests/kuttl/test-suites/default/common/deploy-with-defaults.yaml new file mode 100644 index 0000000..3b969ba --- /dev/null +++ b/tests/kuttl/test-suites/default/common/deploy-with-defaults.yaml @@ -0,0 +1,7 @@ +apiVersion: watcher.openstack.org/v1beta1 +kind: Watcher +metadata: + name: watcher-kuttl + namespace: watcher-kuttl-default +spec: + databaseInstance: "openstack" diff --git a/tests/kuttl/test-suites/default/test/01-deploy-with-defaults.yaml b/tests/kuttl/test-suites/default/test/01-deploy-with-defaults.yaml deleted file mode 100644 index 3b969ba..0000000 --- a/tests/kuttl/test-suites/default/test/01-deploy-with-defaults.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: watcher.openstack.org/v1beta1 -kind: Watcher -metadata: - name: watcher-kuttl - namespace: watcher-kuttl-default -spec: - databaseInstance: "openstack" diff --git a/tests/kuttl/test-suites/default/test/01-deploy-with-defaults.yaml b/tests/kuttl/test-suites/default/test/01-deploy-with-defaults.yaml new file mode 120000 index 0000000..ecf8d37 --- /dev/null +++ b/tests/kuttl/test-suites/default/test/01-deploy-with-defaults.yaml @@ -0,0 +1 @@ +../common/deploy-with-defaults.yaml \ No newline at end of file diff --git a/tests/kuttl/test-suites/default/watcher-api/00-cleanup-watcher.yaml b/tests/kuttl/test-suites/default/watcher-api/00-cleanup-watcher.yaml new file mode 120000 index 0000000..92ed6e0 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/00-cleanup-watcher.yaml @@ -0,0 +1 @@ +../common/cleanup-watcher.yaml \ No newline at end of file diff --git a/tests/kuttl/test-suites/default/watcher-api/01-cleanup-watcherapi.yaml b/tests/kuttl/test-suites/default/watcher-api/01-cleanup-watcherapi.yaml new file mode 100644 index 0000000..b9c7650 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/01-cleanup-watcherapi.yaml @@ -0,0 +1,6 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +delete: +- apiVersion: watcher.openstack.org/v1beta1 + kind: WatcherAPI + name: watcherapi-kuttl diff --git a/tests/kuttl/test-suites/default/watcher-api/02-deploy-with-defaults.yaml b/tests/kuttl/test-suites/default/watcher-api/02-deploy-with-defaults.yaml new file mode 120000 index 0000000..ecf8d37 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/02-deploy-with-defaults.yaml @@ -0,0 +1 @@ +../common/deploy-with-defaults.yaml \ No newline at end of file diff --git a/tests/kuttl/test-suites/default/watcher-api/03-assert.yaml b/tests/kuttl/test-suites/default/watcher-api/03-assert.yaml new file mode 100644 index 0000000..f3c4cab --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/03-assert.yaml @@ -0,0 +1,26 @@ +apiVersion: watcher.openstack.org/v1beta1 +kind: WatcherAPI +metadata: + finalizers: + - openstack.org/watcherapi + name: watcherapi-kuttl +spec: + databaseAccount: watcher + databaseInstance: openstack + passwordSelectors: + service: WatcherPassword + secret: osp-secret +status: + conditions: + - message: Setup complete + reason: Ready + status: "True" + type: Ready + - message: Input data complete + reason: Ready + status: "True" + type: InputReady + - message: Service config create completed + reason: Ready + status: "True" + type: ServiceConfigReady diff --git a/tests/kuttl/test-suites/default/watcher-api/03-deploy-watcher-api.yaml b/tests/kuttl/test-suites/default/watcher-api/03-deploy-watcher-api.yaml new file mode 100644 index 0000000..b4f6a41 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/03-deploy-watcher-api.yaml @@ -0,0 +1,6 @@ +apiVersion: watcher.openstack.org/v1beta1 +kind: WatcherAPI +metadata: + name: watcherapi-kuttl +spec: + databaseInstance: "openstack" diff --git a/tests/kuttl/test-suites/default/watcher-api/04-cleanup-watcher.yaml b/tests/kuttl/test-suites/default/watcher-api/04-cleanup-watcher.yaml new file mode 120000 index 0000000..92ed6e0 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/04-cleanup-watcher.yaml @@ -0,0 +1 @@ +../common/cleanup-watcher.yaml \ No newline at end of file diff --git a/tests/kuttl/test-suites/default/watcher-api/05-assert.yaml b/tests/kuttl/test-suites/default/watcher-api/05-assert.yaml new file mode 100644 index 0000000..6de52af --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/05-assert.yaml @@ -0,0 +1,9 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +namespaced: true +commands: + - script: | + set -ex + oc get mariadbaccount -n ${NAMESPACE} --no-headers=true | [ $(grep -c ^watcher) == 0 ] + oc get mariadbdatabase -n ${NAMESPACE} --no-headers=true | [ $(grep -c ^watcher) == 0 ] + oc get secret -n ${NAMESPACE} --no-headers=true | [ $(grep -c ^watcher) == 0 ] diff --git a/tests/kuttl/test-suites/default/watcher-api/05-cleanup-watcherapi.yaml b/tests/kuttl/test-suites/default/watcher-api/05-cleanup-watcherapi.yaml new file mode 120000 index 0000000..40ff478 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/05-cleanup-watcherapi.yaml @@ -0,0 +1 @@ +01-cleanup-watcherapi.yaml \ No newline at end of file