---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: tpcc
  namespace: tipocket-job
spec:
  schedule: "0 */4 * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: tipocket
            imagePullPolicy: Always
            image: pingcap/tipocket:latest
            command:
              - "sh"
              - "-c"
              - |
                /bin/tpcc \
                -namespace=tipocket-tpcc-test \
                -image-version=v3.0.9 \
                -client=100 \
                -hub=hub.pingcap.net \
                -nemesis=random_kill,short_kill_tikv_1node,short_kill_pd_leader,kill_tikv_1node_5min \
                -round=10 \
                -checker=qos \
                -run-time=10m \
                -request-count=1073741824 \
                -qos-file=/qos.log

                if [ $? != "0" ]; then
                  echo "ERROR OCCURED, PTAL..."
                  while true; do sleep 60; done
                fi

                cat /qos.log
            env:
            - name: KUBECONFIG
              value: "/etc/config/kube_config"
            volumeMounts:
            - name: kube-config
              mountPath: /etc/config
          volumes:
          - name: kube-config
            configMap:
              name: kube-config
          restartPolicy: Never
      backoffLimit: 0
