Skip to content

Commit

Permalink
add helm tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cbarbian-sap committed Jul 17, 2023
1 parent 054d9e9 commit 383372f
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
58 changes: 58 additions & 0 deletions chart/templates/tests/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "project-operator.fullname" . }}-test
labels:
{{- include "project-operator.labels" . | nindent 4 }}
annotations:
helm.sh/hook: test
helm.sh/hook-weight: "-1"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "project-operator.fullname" . }}-test
labels:
{{- include "project-operator.labels" . | nindent 4 }}
annotations:
helm.sh/hook: test
helm.sh/hook-weight: "-1"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
rules:
- apiGroups:
- core.cs.sap.com
resources:
- projects
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "project-operator.fullname" . }}-test
labels:
{{- include "project-operator.labels" . | nindent 4 }}
annotations:
helm.sh/hook: test
helm.sh/hook-weight: "-1"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
subjects:
- kind: ServiceAccount
namespace: {{ .Release.Namespace }}
name: {{ include "project-operator.fullname" . }}-test
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "project-operator.fullname" . }}-test
36 changes: 36 additions & 0 deletions chart/templates/tests/test-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- $projectName := printf "%s-test-1-%s" (include "project-operator.fullname" .) (randAlphaNum 10 | lower) }}
---
apiVersion: core.cs.sap.com/v1alpha1
kind: Project
metadata:
name: {{ $projectName }}
labels:
{{- include "project-operator.labels" . | nindent 4 }}
annotations:
helm.sh/hook: test
helm.sh/hook-weight: "0"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
---
apiVersion: v1
kind: Pod
metadata:
name: {{ include "project-operator.fullname" . }}-test-1
labels:
{{- include "project-operator.labels" . | nindent 4 }}
annotations:
helm.sh/hook: test
helm.sh/hook-weight: "1"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
spec:
containers:
- name: kubectl
image: bitnami/kubectl:{{ .Capabilities.KubeVersion.Version | trimPrefix "v" }}
command:
- bash
- -ec
- |
kubectl wait projects.core.cs.sap.com/{{ $projectName }} --for condition=Ready --timeout 30s
kubectl get namespace project-{{ $projectName }}
serviceAccountName: {{ include "project-operator.fullname" . }}-test
terminationGracePeriodSeconds: 3
restartPolicy: Never

0 comments on commit 383372f

Please sign in to comment.