#!/bin/bash -e
#
# Apache v2 license
# Copyright (C) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

WORKLOAD=${WORKLOAD:-django}
NODES=${2:-3}
TLS=${1:-"on"}
ATTEMPT=${ATTEMPT:-1}
SIEGE_WORKER=${SIEGE_WORKER:-88}
DURATION=${DURATION:-1}
UWSGI_WORKER=${UWSGI_WORKER:-72}
MEMCACHE_THREAD=${MEMCACHE_THREAD:-2}
MEMCACHE_MEMORY=${MEMCACHE_MEMORY:-5120}
CASSANDRA_CR=${CASSANDRA_CR:-64}
CASSANDRA_CW=${CASSANDRA_CW:-128}
CASSANDRA_CCW=${CASSANDRA_CCW:-128}

IMARCH=""
TLSVERSION="TLSv1.3"

if [ "$TLS" == "off" ]; then
  TLS="0"
else
  TLS="1"
fi

OS_SUFFIX=""
if [[ $WORKLOAD == *"ubuntu2404"* ]]; then
    OS_SUFFIX="_ubuntu2404"
fi

if [[ "$IMAGEARCH" != "linux/amd64" ]]; then
    IMARCH="-${IMAGEARCH/*\//}"
fi

# Logs Setting
DIR="$( cd "$( dirname "$0" )" &> /dev/null && pwd )"
. "$DIR/../../script/overwrite.sh"

# Workload Setting
WORKLOAD_PARAMS=(NODES TLS ATTEMPT SIEGE_WORKER DURATION TLSVERSION UWSGI_WORKER MEMCACHE_THREAD MEMCACHE_MEMORY CASSANDRA_CR CASSANDRA_CW CASSANDRA_CCW) 

# Docker Setting
DOCKER_IMAGE=""
DOCKER_OPTIONS=""

# Kubernetes Setting
RECONFIG_OPTIONS="-DNODES=$NODES -DTLS=$TLS -DATTEMPT=$ATTEMPT -DSIEGE_WORKER=$SIEGE_WORKER -DIMARCH=$IMARCH -DDURATION=$DURATION -DTLSVERSION=$TLSVERSION -DUWSGI_WORKER=$UWSGI_WORKER -DMEMCACHE_THREAD=$MEMCACHE_THREAD -DMEMCACHE_MEMORY=$MEMCACHE_MEMORY -DCASSANDRA_CR=$CASSANDRA_CR -DCASSANDRA_CW=$CASSANDRA_CW -DCASSANDRA_CCW=$CASSANDRA_CCW -DOS_SUFFIX=$OS_SUFFIX"
JOB_FILTER="job-name=benchmark"

. "$DIR/../../script/validate.sh"
