apiVersion: v1
kind: ConfigMap
metadata:
  name: jmeter-load-test
  labels:
    app: influxdb-jmeter
data:
  load_test: |
    #!/bin/bash
    #Script created to invoke jmeter test script with the slave POD IP addresses
    #Script should be run like: ./load_test "path to the test script in jmx format"
    if [ -d "report" ]; then
        rm -rf report/* csv/* 
    else
        mkdir csv report
    fi
    /jmeter/apache-jmeter-*/bin/jmeter -n -t $1 -Dserver.rmi.ssl.disable=true -R `getent ahostsv4 jmeter-slaves-svc | cut -d' ' -f1 | sort -u | awk -v ORS=, '{print $1}' | sed 's/,$//'` -l /csv/Res.csv -e -o /report
    if [ -d "report" ]; then
        TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S`
        mkdir $TIMESTAMP
        mv *.csv *.xml report/
        cp -r csv report $TIMESTAMP/
        tar -czf results.tar.gz $TIMESTAMP/
    fi