apiVersion: v1
kind: Pod
metadata:
  name: test-{{ template "fullname" . }}-execute-tests
  annotations:
    sidecar.istio.io/inject: "true"
    helm.sh/hook: test-success
  labels:
    "helm-chart-test": "true"
    "kyma-project.io/upgrade-e2e-test": "executeTests"
spec:
  serviceAccountName:  test-{{ template "fullname" . }}
  shareProcessNamespace: true
  restartPolicy: Never
  containers:
  - name: runner
    image: "{{ .Values.containerRegistry.path }}/{{ .Values.image.dir }}e2e-upgrade-test:{{ .Values.image.version }}"
    imagePullPolicy: "{{ .Values.image.pullPolicy}}"
    command: [ "/bin/sh"]
    args: ["-c", "sleep 10; e2e-upgrade-test --action executeTests"]
    env:
    - name: APP_MAX_CONCURRENCY_LEVEL
      value: "1"
    - name: APP_LOGGER_LEVEL
      value: "info"
    - name: APP_DEX_NAMESPACE
      value: "{{ .Values.dex.namespace }}"
    - name: APP_DEX_USER_SECRET
      value: "{{ .Values.dex.userSecret }}"
  - image: eu.gcr.io/kyma-project/test-infra/alpine-kubectl:v20190325-ff66a3a
    name: manager
    command:
      - /bin/sh
      - -c
      - |
        SERVICE="e2e-upgrade-test"
        sleep 10
        while true; do
        if pgrep -x "${SERVICE}"; then
          echo "---> ${SERVICE} is running."
            sleep 10
          else
            echo "---> ${SERVICE} has stopped, stopping istio"
            pkill -TERM pilot-agent
            break
          fi
        done
