From 254a88aba5b6d67b04956e70fd7146ea4da9c8ef 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-deploy-with-defaults.yaml | 1 + .../default/watcher-api/02-assert.yaml | 20 +++++ .../watcher-api/02-deploy-watcher-api.yaml | 6 ++ .../03-cleanup-watcher-watcher-api.yaml | 9 +++ .../04-precreate-mariadbaccount.yaml | 9 +++ .../default/watcher-api/05-assert.yaml | 79 +++++++++++++++++++ .../watcher-api/05-cleanup-watcher.yaml | 1 + .../05-deploy-with-precreated-account.yaml | 15 ++++ .../default/watcher-api/06-assert.yaml | 9 +++ 13 files changed, 158 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 120000 tests/kuttl/test-suites/default/watcher-api/01-deploy-with-defaults.yaml create mode 100644 tests/kuttl/test-suites/default/watcher-api/02-assert.yaml create mode 100644 tests/kuttl/test-suites/default/watcher-api/02-deploy-watcher-api.yaml create mode 100644 tests/kuttl/test-suites/default/watcher-api/03-cleanup-watcher-watcher-api.yaml create mode 100644 tests/kuttl/test-suites/default/watcher-api/04-precreate-mariadbaccount.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-watcher.yaml create mode 100644 tests/kuttl/test-suites/default/watcher-api/05-deploy-with-precreated-account.yaml create mode 100644 tests/kuttl/test-suites/default/watcher-api/06-assert.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-deploy-with-defaults.yaml b/tests/kuttl/test-suites/default/watcher-api/01-deploy-with-defaults.yaml new file mode 120000 index 0000000..ecf8d37 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/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/02-assert.yaml b/tests/kuttl/test-suites/default/watcher-api/02-assert.yaml new file mode 100644 index 0000000..5b838c3 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/02-assert.yaml @@ -0,0 +1,20 @@ +apiVersion: watcher.openstack.org/v1beta1 +kind: WatcherAPI +metadata: + finalizers: + - openstack.org/watcherapi + name: watcherapi-kuttl +status: + conditions: + - message: Setup complete + reason: Ready + status: "True" + type: Ready + - message: Input data completed + reason: Ready + status: "True" + type: InputReady + - message: Service config create complete + reason: Ready + status: "True" + type: ServiceConfigReady diff --git a/tests/kuttl/test-suites/default/watcher-api/02-deploy-watcher-api.yaml b/tests/kuttl/test-suites/default/watcher-api/02-deploy-watcher-api.yaml new file mode 100644 index 0000000..b4f6a41 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/02-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/03-cleanup-watcher-watcher-api.yaml b/tests/kuttl/test-suites/default/watcher-api/03-cleanup-watcher-watcher-api.yaml new file mode 100644 index 0000000..94e8b02 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/03-cleanup-watcher-watcher-api.yaml @@ -0,0 +1,9 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +delete: +- apiVersion: watcher.openstack.org/v1beta1 + kind: Watcher + name: watcher-kuttl +- apiVersion: watcherapi.openstack.org/v1beta1 + kind: WatcherAPI + name: watcherapi-kuttl diff --git a/tests/kuttl/test-suites/default/watcher-api/04-precreate-mariadbaccount.yaml b/tests/kuttl/test-suites/default/watcher-api/04-precreate-mariadbaccount.yaml new file mode 100644 index 0000000..cb94f3b --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/04-precreate-mariadbaccount.yaml @@ -0,0 +1,9 @@ +apiVersion: mariadb.openstack.org/v1beta1 +kind: MariaDBAccount +metadata: + name: watcher-precreated + namespace: watcher-kuttl-default +spec: + requireTLS: false + secret: watcher-db-secret + userName: watcher_test 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..5743677 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/05-assert.yaml @@ -0,0 +1,79 @@ +apiVersion: watcher.openstack.org/v1beta1 +kind: Watcher +metadata: + finalizers: + - openstack.org/watcher + name: watcher-kuttl +spec: + databaseAccount: watcher-precreated + databaseInstance: openstack + passwordSelectors: + service: WatcherPassword + secret: osp-secret +status: + conditions: + - message: Setup complete + reason: Ready + status: "True" + type: Ready + - message: DB create completed + reason: Ready + status: "True" + type: DBReady + - message: MariaDBAccount creation complete + reason: Ready + status: "True" + type: MariaDBAccountReady +--- +apiVersion: watcherapi.openstack.org/v1beta1 +kind: WatcherAPI +spec: + databaseAccount: watcher-precreated + databaseInstance: openstack + passwordSelectors: + service: WatcherPassword + secret: osp-secret +metadata: + finalizers: + - openstack.org/watcherapi + name: watcherapi-kuttl +status: + conditions: + - message: Setup complete + reason: Ready + status: "True" + type: Ready + - message: Input data completed + reason: Ready + status: "True" + type: InputReady + - message: Service config create complete + reason: Ready + status: "True" + type: ServiceConfigReady +--- +apiVersion: v1 +kind: Secret +metadata: + name: watcher-db-secret + finalizers: + - openstack.org/watcher +--- +apiVersion: mariadb.openstack.org/v1beta1 +kind: MariaDBAccount +metadata: + name: watcher-precreated + finalizers: + - openstack.org/watcher + - openstack.org/mariadbaccount + labels: + mariaDBDatabaseName: watcher +--- +apiVersion: mariadb.openstack.org/v1beta1 +kind: MariaDBDatabase +metadata: + name: watcher + finalizers: + - openstack.org/watcher + - openstack.org/mariadbdatabase + - openstack.org/mariadbaccount-watcher-precreated diff --git a/tests/kuttl/test-suites/default/watcher-api/05-cleanup-watcher.yaml b/tests/kuttl/test-suites/default/watcher-api/05-cleanup-watcher.yaml new file mode 120000 index 0000000..740bd49 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/05-cleanup-watcher.yaml @@ -0,0 +1 @@ +03-cleanup-watcher-watcher-api.yaml \ No newline at end of file diff --git a/tests/kuttl/test-suites/default/watcher-api/05-deploy-with-precreated-account.yaml b/tests/kuttl/test-suites/default/watcher-api/05-deploy-with-precreated-account.yaml new file mode 100644 index 0000000..f337598 --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/05-deploy-with-precreated-account.yaml @@ -0,0 +1,15 @@ +apiVersion: watcher.openstack.org/v1beta1 +kind: Watcher +metadata: + name: watcher-kuttl +spec: + databaseInstance: "openstack" + databaseAccount: watcher-precreated +--- +apiVersion: watcherapi.openstack.org/v1beta1 +kind: WatcherAPI +metadata: + name: watcherapi-kuttl +spec: + databaseInstance: "openstack" + databaseAccount: watcher-precreated diff --git a/tests/kuttl/test-suites/default/watcher-api/06-assert.yaml b/tests/kuttl/test-suites/default/watcher-api/06-assert.yaml new file mode 100644 index 0000000..6de52af --- /dev/null +++ b/tests/kuttl/test-suites/default/watcher-api/06-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 ]