# helm_source_test-runner.yaml
apiVersion: v1
kind: Pod
metadata:
  name: "{{ template "mariadb.fullname" . }}-test-{{ randAlphaNum 5 | lower }}"
  annotations:
    "helm.sh/hook": test-success
spec:
  initContainers:
    - name: "test-framework"
      image: "dduportal/bats:0.4.0"
      command:
        - "bash"
        - "-c"
        - |
          set -ex
          # copy bats to tools dir
          cp -R /usr/local/libexec/ /tools/bats/
      volumeMounts:
      - mountPath: /tools
        name: tools
  containers:
    - name: mariadb-test
      image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
      imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
      command: ["/tools/bats/bats", "-t", "/tests/run.sh"]
      env:
        - name: MARIADB_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: {{ template "mariadb.fullname" . }}
              key: mariadb-root-password
      volumeMounts:
      - mountPath: /tests
        name: tests
        readOnly: true
      - mountPath: /tools
        name: tools
  volumes:
  - name: tests
    configMap:
      name: {{ template "mariadb.fullname" . }}-tests
  - name: tools
    emptyDir: {}
  restartPolicy: Never