From 8f164ca42f382f2ee352e546166e48cc1712bd48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Wed, 14 Feb 2024 09:42:52 +0100 Subject: [PATCH 1/6] test: add chainsaw basic test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- tests/e2e/examples/basic/assertions.yaml | 37 ++++++++++++++ tests/e2e/examples/basic/chainsaw-test.yaml | 13 +++++ tests/e2e/examples/basic/resources.yaml | 55 +++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 tests/e2e/examples/basic/assertions.yaml create mode 100755 tests/e2e/examples/basic/chainsaw-test.yaml create mode 100644 tests/e2e/examples/basic/resources.yaml diff --git a/tests/e2e/examples/basic/assertions.yaml b/tests/e2e/examples/basic/assertions.yaml new file mode 100644 index 000000000..11289a438 --- /dev/null +++ b/tests/e2e/examples/basic/assertions.yaml @@ -0,0 +1,37 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: grafana-deployment + ownerReferences: + - apiVersion: grafana.integreatly.org/v1beta1 + kind: Grafana + name: grafana +spec: {} +--- +apiVersion: v1 +kind: Service +metadata: + name: grafana-service + ownerReferences: + - apiVersion: grafana.integreatly.org/v1beta1 + kind: Grafana + name: grafana +spec: {} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: grafana-ini + ownerReferences: + - apiVersion: grafana.integreatly.org/v1beta1 + kind: Grafana + name: grafana +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: grafana-plugins + ownerReferences: + - apiVersion: grafana.integreatly.org/v1beta1 + kind: Grafana + name: grafana diff --git a/tests/e2e/examples/basic/chainsaw-test.yaml b/tests/e2e/examples/basic/chainsaw-test.yaml new file mode 100755 index 000000000..5c201e786 --- /dev/null +++ b/tests/e2e/examples/basic/chainsaw-test.yaml @@ -0,0 +1,13 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: basic +spec: + steps: + - name: step-00 + try: + - apply: + file: resources.yaml + - assert: + file: assertions.yaml diff --git a/tests/e2e/examples/basic/resources.yaml b/tests/e2e/examples/basic/resources.yaml new file mode 100644 index 000000000..0937c7b4e --- /dev/null +++ b/tests/e2e/examples/basic/resources.yaml @@ -0,0 +1,55 @@ +apiVersion: grafana.integreatly.org/v1beta1 +kind: Grafana +metadata: + name: grafana + labels: + dashboards: "grafana" +spec: + config: + log: + mode: "console" + auth: + disable_login_form: "false" + security: + admin_user: root + admin_password: secret +--- +apiVersion: grafana.integreatly.org/v1beta1 +kind: GrafanaDashboard +metadata: + name: grafanadashboard-sample +spec: + resyncPeriod: 30s + instanceSelector: + matchLabels: + dashboards: "grafana" + json: > + { + "id": null, + "title": "Simple Dashboard", + "tags": [], + "style": "dark", + "timezone": "browser", + "editable": true, + "hideControls": false, + "graphTooltip": 1, + "panels": [], + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "time_options": [], + "refresh_intervals": [] + }, + "templating": { + "list": [] + }, + "annotations": { + "list": [] + }, + "refresh": "5s", + "schemaVersion": 17, + "version": 0, + "links": [] + } From 965aaba15eaa54f944ba7796ddc7f9a97e71cac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Wed, 14 Feb 2024 10:04:15 +0100 Subject: [PATCH 2/6] fix debug logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- .github/workflows/e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 6388d810e..112c2a981 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -87,5 +87,5 @@ jobs: kubectl -n $NAMESPACE get all kubectl -n $NAMESPACE get grafana kubectl get crd - POD=$(kubectl get pods -n $NAMESPACE -l control-plane=controller-manager --output=jsonpath={.items..metadata.name}) + POD=$(kubectl get pods -n $NAMESPACE -l control-plane=controller-manager --output=jsonpath={.items.metadata.name}) kubectl logs -n $NAMESPACE $POD -c manager From 4e1cf11ff1a7c0e47d5fb25f079b24219257480f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Wed, 14 Feb 2024 10:13:59 +0100 Subject: [PATCH 3/6] fix debug logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- .github/workflows/e2e.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 112c2a981..936bad0bb 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -83,9 +83,10 @@ jobs: - name: Debug failure if: failure() run: | + set -e kubectl version kubectl -n $NAMESPACE get all kubectl -n $NAMESPACE get grafana kubectl get crd - POD=$(kubectl get pods -n $NAMESPACE -l control-plane=controller-manager --output=jsonpath={.items.metadata.name}) + POD=$(kubectl get pods -n $NAMESPACE -l app.kubernetes.io/name=grafana-operator --output=jsonpath={.items.metadata.name}) kubectl logs -n $NAMESPACE $POD -c manager From 3c7deae1ad9f19967ebcad84e8c37738e02e8c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Wed, 14 Feb 2024 10:23:36 +0100 Subject: [PATCH 4/6] fix debug logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- .github/workflows/e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 936bad0bb..af35089ba 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -88,5 +88,5 @@ jobs: kubectl -n $NAMESPACE get all kubectl -n $NAMESPACE get grafana kubectl get crd - POD=$(kubectl get pods -n $NAMESPACE -l app.kubernetes.io/name=grafana-operator --output=jsonpath={.items.metadata.name}) + POD=$(kubectl get pods -n $NAMESPACE -l app.kubernetes.io/name=grafana-operator --output='jsonpath={.items[].metadata.name})' kubectl logs -n $NAMESPACE $POD -c manager From 3147982547aa75eed8d1f34a52382120c4bd408f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Wed, 14 Feb 2024 10:48:08 +0100 Subject: [PATCH 5/6] fix debug logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- .github/workflows/e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index af35089ba..2ce8042a8 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -88,5 +88,5 @@ jobs: kubectl -n $NAMESPACE get all kubectl -n $NAMESPACE get grafana kubectl get crd - POD=$(kubectl get pods -n $NAMESPACE -l app.kubernetes.io/name=grafana-operator --output='jsonpath={.items[].metadata.name})' + POD=$(kubectl get pods -n $NAMESPACE -l app.kubernetes.io/name=grafana-operator --output='jsonpath={.items[].metadata.name}') kubectl logs -n $NAMESPACE $POD -c manager From 8dbe48882a88c1d31723ad0cb7d3effb699c3cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Wed, 14 Feb 2024 10:48:58 +0100 Subject: [PATCH 6/6] fix debug logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- .github/workflows/e2e.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 2ce8042a8..85d68dff4 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -89,4 +89,7 @@ jobs: kubectl -n $NAMESPACE get grafana kubectl get crd POD=$(kubectl get pods -n $NAMESPACE -l app.kubernetes.io/name=grafana-operator --output='jsonpath={.items[].metadata.name}') + echo "pod logs" kubectl logs -n $NAMESPACE $POD -c manager + echo "previous pod logs (if any)" + kubectl logs -p -n $NAMESPACE $POD -c manager || true