apiVersion: v1
kind: Pod
metadata:
  name: "{{ include "hapi-fhir-jpaserver.fullname" . }}-test-endpoints"
  labels:
    {{- include "hapi-fhir-jpaserver.labels" . | nindent 4 }}
    {{ include "hapi-fhir-jpaserver.fullname" . }}-client: "true"
  annotations:
    "helm.sh/hook": test
spec:
  restartPolicy: Never
  automountServiceAccountToken: {{ .Values.tests.automountServiceAccountToken }}
  containers:
    - name: test-metadata-endpoint
      image: "{{ .Values.curl.image.registry }}/{{ .Values.curl.image.repository }}:{{ .Values.curl.image.tag }}"
      command: ["curl", "--fail-with-body"]
      args: ["http://{{ include "hapi-fhir-jpaserver.fullname" . }}:{{ .Values.service.port }}/fhir/metadata?_summary=true"]
      {{- with .Values.restrictedContainerSecurityContext }}
      securityContext:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tests.resources }}
      resources:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      livenessProbe:
        exec:
          command: ["true"]
      readinessProbe:
        exec:
          command: ["true"]
    - name: test-patient-endpoint
      image: "{{ .Values.curl.image.registry }}/{{ .Values.curl.image.repository }}:{{ .Values.curl.image.tag }}"
      command: ["curl", "--fail-with-body"]
      args: ["http://{{ include "hapi-fhir-jpaserver.fullname" . }}:{{ .Values.service.port }}/fhir/Patient?_count=1&_summary=true"]
      {{- with .Values.restrictedContainerSecurityContext }}
      securityContext:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tests.resources }}
      resources:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      livenessProbe:
        exec:
          command: ["true"]
      readinessProbe:
        exec:
          command: ["true"]
    - name: test-metrics-endpoint
      image: "{{ .Values.curl.image.registry }}/{{ .Values.curl.image.repository }}:{{ .Values.curl.image.tag }}"
      command: ["curl", "--fail-with-body"]
      args: ["http://{{ include "hapi-fhir-jpaserver.fullname" . }}:{{ .Values.metrics.service.port }}/actuator/prometheus"]
      {{- with .Values.restrictedContainerSecurityContext }}
      securityContext:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tests.resources }}
      resources:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      livenessProbe:
        exec:
          command: ["true"]
      readinessProbe:
        exec:
          command: ["true"]
