#!/bin/sh
# - nr_threads
# - duration
# - insert
# - simple1

: ${nr_threads:=1}
: ${duration:=300}
: ${insert:=0}
: ${simple1:=0}

. $LKP_SRC/lib/reproduce-log.sh
. $LKP_SRC/lib/tests/cassandra.sh

cd "$BENCHMARK_ROOT"/cassandra || die "cassandra database has not been installed yet"

setup_java_home

export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

# Cassandra server usually takes about 15 seconds to launch successfully.
# Here waiting for 25 seconds to ensure the daemon can be launched successfully before the client tries to connect it.

echo "waiting for 25 seconds for launching cassandra server..."
sleep 25

database="$BENCHMARK_ROOT"/cassandra/tools/cqlstress-example.yaml

log_test ./tools/bin/cassandra-stress user profile="$database" ops\(insert="$insert",simple1="$simple1"\) duration="$duration" -rate threads="$nr_threads"
