---
apiVersion: batch/v1
kind: Job
metadata:
  generateName: percona-loadgen-
  namespace: e2e
spec:
  template:
    metadata:
      name: percona-loadgen
      namespace: e2e
      labels:
        loadgen: percona-loadjob
    spec:
      serviceAccountName: e2e
      restartPolicy: Never
      containers:
      - name: ansibletest
        image: openebs/lvm-localpv-e2e:ci
        imagePullPolicy: IfNotPresent
        env: 
          - name: ANSIBLE_STDOUT_CALLBACK
            value: default
            
            # This is the namespace where percona application is running
          - name: APP_NAMESPACE
            value: 'percona'

          - name: APP_LABEL
            value: 'app=percona'
           
          - name: LOADGEN_LABEL
            value: loadgen=percona-loadgen

            # Database user name
          - name: DB_USER
            value: root

          - name: DB_PASSWORD
            value: k8sDem0

            # Bench duration (in min) 
            # TODO: Use a tpcc-template to define workload w/ more granularity
          - name: LOAD_DURATION
            value: "600"

          - name: TPCC_WAREHOUSES
            value: "1"

          - name: TPCC_CONNECTIONS
            value: "18"

          - name: TPCC_WARMUP_PERIOD
            value: "10"

          - name: LOAD_INTERVAL
            value: "10"                                    

        command: ["/bin/bash"]
        args: ["-c", "ansible-playbook ./e2e-tests/apps/percona/workload/test.yml -i /etc/ansible/hosts -v; exit 0"]