apiVersion: v1
kind: Pod
metadata:
  name: "{{ template "neo4j.fullname" . }}-service-test-{{ randAlphaNum 5 | lower }}"
  labels:
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    app: {{ template "neo4j.name" . }}
  annotations:
    "helm.sh/hook": test-success
    "helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded"
spec:
  containers:
    - name: {{ .Release.Name }}-ui-test
      image: {{ .Values.testImage }}:{{ .Values.testImageTag }}
      env:
        - name: "STATEFULSET_NAME"
          value: "{{ template "neo4j.fullname" . }}"
        - name: "CORE_REPLICAS"
          value: "{{ .Values.core.numberOfServers }}"
        - name: "NAMESPACE"
          value: {{ .Release.Namespace }}
        - name: NEO4J_SECRETS_PASSWORD
          valueFrom:
            secretKeyRef:
              name: {{ template "neo4j.secrets.fullname" . }}
              key: neo4j-password
      command: ["/tools/bats/bats", "-t", "/tests/run.sh"]
      volumeMounts:
      - mountPath: /tests
        name: tests
        readOnly: true
      - mountPath: /tools
        name: tools
  initContainers:
  - name: test-framework
    image: "dduportal/bats:0.4.0"
    command: ["bash", "-c", "set -ex\ncp -R /usr/local/libexec/ /tools/bats/"]
    volumeMounts:
      - mountPath: "/tools"
        name: tools
  volumes:
  - name: tests
    configMap:
      name: {{ template "neo4j.fullname" . }}-tests
  - name: tools
    emptyDir: {}
  restartPolicy: Never
