Skip to content

Commit

Permalink
chore: add cross namespace e2e test (#1437)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly committed Feb 24, 2024
1 parent 04b8181 commit fad450f
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/e2e/examples/crossnamespace/assertions.yaml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions tests/e2e/examples/crossnamespace/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions tests/e2e/examples/crossnamespace/resources.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fad450f

Please sign in to comment.