From 5a0b655eadc5e8c7fa083f6140626a344ee2d90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Wed, 21 Feb 2024 17:28:44 +0100 Subject: [PATCH] chore: add cross namespace e2e test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- .../examples/crossnamespace/assertions.yaml | 45 +++++++++++++++++ .../crossnamespace/chainsaw-test.yaml | 16 ++++++ .../examples/crossnamespace/resources.yaml | 50 +++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 tests/e2e/examples/crossnamespace/assertions.yaml create mode 100755 tests/e2e/examples/crossnamespace/chainsaw-test.yaml create mode 100644 tests/e2e/examples/crossnamespace/resources.yaml diff --git a/tests/e2e/examples/crossnamespace/assertions.yaml b/tests/e2e/examples/crossnamespace/assertions.yaml new file mode 100644 index 000000000..47508961a --- /dev/null +++ b/tests/e2e/examples/crossnamespace/assertions.yaml @@ -0,0 +1,45 @@ +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 +--- +apiVersion: grafana.integreatly.org/v1beta1 +kind: GrafanaDatasource +metadata: + name: example-grafanadatasource + namespace: (join('-', ['cross', $namespace])) +status: + (lastMessage != null): true \ No newline at end of file diff --git a/tests/e2e/examples/crossnamespace/chainsaw-test.yaml b/tests/e2e/examples/crossnamespace/chainsaw-test.yaml new file mode 100755 index 000000000..b76a40a3c --- /dev/null +++ b/tests/e2e/examples/crossnamespace/chainsaw-test.yaml @@ -0,0 +1,16 @@ +# 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: crossnamespace +spec: + concurrent: false + steps: + - name: step-00 + try: + - apply: + template: true + file: resources.yaml + - assert: + template: true + file: assertions.yaml diff --git a/tests/e2e/examples/crossnamespace/resources.yaml b/tests/e2e/examples/crossnamespace/resources.yaml new file mode 100644 index 000000000..0b0c1a805 --- /dev/null +++ b/tests/e2e/examples/crossnamespace/resources.yaml @@ -0,0 +1,50 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: (join('-', ['cross', $namespace])) +--- +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 + deployment: + spec: + template: + spec: + containers: + - name: grafana + securityContext: + allowPrivilegeEscalation: true + readOnlyRootFilesystem: false + readinessProbe: + failureThreshold: 3 +--- +apiVersion: grafana.integreatly.org/v1beta1 +kind: GrafanaDatasource +metadata: + name: example-grafanadatasource + namespace: (join('-', ['cross', $namespace])) +spec: + allowCrossNamespaceImport: true + datasource: + access: proxy + database: prometheus + jsonData: + timeInterval: 5s + tlsSkipVerify: true + name: Prometheus + url: http://prometheus-service:9090 + instanceSelector: + matchLabels: + dashboards: grafana