diff --git a/acceptance-tests/.helmignore b/acceptance-tests/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/acceptance-tests/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/acceptance-tests/Chart.yaml b/acceptance-tests/Chart.yaml new file mode 100644 index 0000000..7888c06 --- /dev/null +++ b/acceptance-tests/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: acceptance-tests +description: A Helm chart for launching "tests non regression" + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.0.0" diff --git a/acceptance-tests/templates/_helpers.tpl b/acceptance-tests/templates/_helpers.tpl new file mode 100644 index 0000000..e04d091 --- /dev/null +++ b/acceptance-tests/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "acceptance-tests.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "acceptance-tests.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "acceptance-tests.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "acceptance-tests.labels" -}} +helm.sh/chart: {{ include "acceptance-tests.chart" . }} +{{ include "acceptance-tests.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "acceptance-tests.selectorLabels" -}} +app.kubernetes.io/name: {{ include "acceptance-tests.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "acceptance-tests.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "acceptance-tests.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/acceptance-tests/templates/cronjob.yaml b/acceptance-tests/templates/cronjob.yaml new file mode 100644 index 0000000..bb242d7 --- /dev/null +++ b/acceptance-tests/templates/cronjob.yaml @@ -0,0 +1,88 @@ +{{- $job := .Values.job -}} +{{- $jobConfiguration := .Values.configuration -}} +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "acceptance-tests.fullname" . }} + labels: + {{- include "acceptance-tests.labels" . | nindent 4 }} +spec: + schedule: {{ $job.schedule | quote }} + successfulJobsHistoryLimit: {{ $job.successfulJobsHistoryLimit }} + jobTemplate: + spec: + ttlSecondsAfterFinished: 86400 + template: + metadata: + labels: + {{- include "acceptance-tests.labels" . | nindent 12 }} + spec: + {{- with $job.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 10 }} + {{- end }} + {{- with $job.podSecurityContext }} + securityContext: + {{ toYaml . | nindent 10 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ $job.image.repository }}:{{ $job.image.tag }}" + imagePullPolicy: {{ $job.image.pullPolicy }} + {{- with .Values.podVolumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + env: + - name: RENATER_USERNAME + valueFrom: + secretKeyRef: + name: {{ include "acceptance-tests.fullname" . }}-job-secrets + key: renaterUsername + - name: RENATER_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "acceptance-tests.fullname" . }}-job-secrets + key: renaterPassword + - name: RENATER_IDP_ID + value: {{ $jobConfiguration.renater.idpId | quote }} + - name: BASE_URL + value: {{ $jobConfiguration.georchestra.baseUrl | quote }} + - name: LOCAL_ACCOUNT_USERNAME + valueFrom: + secretKeyRef: + name: {{ include "acceptance-tests.fullname" . }}-job-secrets + key: georchestraLocalAccountUsername + - name: LOCAL_ACCOUNT_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "acceptance-tests.fullname" . }}-job-secrets + key: georchestraLocalAccountPassword + {{- with $job.extraEnv }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with $job.resources }} + resources: + {{ toYaml . | nindent 12 }} + {{- end }} + {{- with $job.securityContext }} + securityContext: + {{ toYaml . | nindent 12 }} + {{- end }} + restartPolicy: {{ $job.restartPolicy }} + {{- with .Values.podVolumeMounts }} + volumes: + {{- toYaml . | nindent 10 }} + {{- end }} + {{- with $job.nodeSelector }} + nodeSelector: + {{ toYaml . | nindent 10 }} + {{- end }} + {{- with $job.affinity }} + affinity: + {{ toYaml . | nindent 10 }} + {{- end }} + {{- with $job.tolerations }} + tolerations: + {{ toYaml . | nindent 10 }} + {{- end }} \ No newline at end of file diff --git a/acceptance-tests/templates/job-secrets.yaml b/acceptance-tests/templates/job-secrets.yaml new file mode 100644 index 0000000..ac87c3e --- /dev/null +++ b/acceptance-tests/templates/job-secrets.yaml @@ -0,0 +1,13 @@ +{{- $jobConfiguration := .Values.configuration -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "acceptance-tests.fullname" . }}-job-secrets + labels: + {{- include "acceptance-tests.labels" . | nindent 4 }} +type: Opaque +data: + georchestraLocalAccountUsername: {{ required ".Values.configuration.georchestra.localAccount.username is required." $jobConfiguration.georchestra.localAccount.username | b64enc | quote }} + georchestraLocalAccountPassword: {{ required ".Values.configuration.georchestra.localAccount.password is required" $jobConfiguration.georchestra.localAccount.password | b64enc | quote }} + renaterUsername: {{ required ".Values.configuration.renater.username is required." $jobConfiguration.renater.username | b64enc | quote }} + renaterPassword: {{ required ".Values.configuration.renater.password is required" $jobConfiguration.renater.password | b64enc | quote }} diff --git a/acceptance-tests/values.yaml b/acceptance-tests/values.yaml new file mode 100644 index 0000000..0d3e15a --- /dev/null +++ b/acceptance-tests/values.yaml @@ -0,0 +1,59 @@ +nameOverride: "" +fullnameOverride: "" + +podVolumeMounts: + volumeMounts: + - name: reports-output + mountPath: /output + # the application will work in the folder /output/public/non-regression + # change it if needed + subPath: public/non-regression + +volumes: +- name: "reports-output" + persistentVolumeClaim: + claimName: apache-nas + +job: + image: + repository: ghcr.io/camptocamp/mel-docker-images/acceptance-tests + pullPolicy: Always + tag: "latest" + schedule: "0 13 * * *" + successfulJobsHistoryLimit: 3 + restartPolicy: Never + nodeSelector: {} + tolerations: [] + affinity: {} + extraEnv: {} + resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + podSecurityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + securityContext: {} + imagePullSecrets: [] + +configuration: + renater: + username: testuser + password: testuser + idpId: "My IDP integration" + georchestra: + baseUrl: "http://mygeorchestra.com" + localAccount: + username: myusername + password: mypassword