wadoku/run-waku.sh

269 lines
7.9 KiB
Bash
Raw Normal View History

2023-01-11 06:57:40 +00:00
#!/bin/sh
usage(){
2023-01-21 18:28:45 +00:00
echo "Usage: ./run.sh <clean | metal | docker | kurtosis> <duration> <time> <ps|lf>"
2023-01-11 06:57:40 +00:00
exit 1
}
2023-01-21 18:28:45 +00:00
run_pair="lf"
2023-01-13 19:40:43 +00:00
# two tests per run
2023-01-21 18:28:45 +00:00
if [ lf = $4 ]; then
lpush="lightpush"
filtr="filter"
elif [ ps = $4 ]; then
lpush="publish"
filtr="subscribe"
run_pair="ps"
# two tests per run
else
echo "Unknown run pair: $4"
usage
fi
2023-01-11 06:57:40 +00:00
2023-01-13 19:40:43 +00:00
# file/dir locations
2023-01-11 06:57:40 +00:00
prefix="waku"
docker_op_dir="/go/bin/out"
enclave="enclave-waku"
2023-01-13 19:40:43 +00:00
host_output_dir="/home1/mimosa/runs"
2023-01-11 06:57:40 +00:00
2023-01-13 19:40:43 +00:00
# params for the run
ctopic="8fc1f6b30b63bdd0a65df833f1da3fa" # default ctopic, a md5
duration="100s" # duration of the run
2023-01-21 18:28:45 +00:00
iat="100ms" # pub msg inter-arrival-time
2023-01-13 19:40:43 +00:00
loglvl="info" # log level
2023-01-11 06:57:40 +00:00
duration=$2
#iat=$3
sleep_time=20
2023-01-21 18:28:45 +00:00
time=$3
2023-01-11 06:57:40 +00:00
unique="XYZ"
clean(){
2023-01-13 19:40:43 +00:00
parent=$(pwd) # no pushd / popd
#rm -rf ./data
cd waku/$filtr
rm $prefix-$filtr
cd ..
cd $lpush
rm $prefix-$lpush
cd $parent
}
2023-01-11 19:00:23 +00:00
2023-01-11 06:57:40 +00:00
build_metal() {
parent=$(pwd)
cd waku/$filtr
make
cd ..
cd $lpush
make
cd $parent
}
2023-01-11 19:00:23 +00:00
2023-01-11 06:57:40 +00:00
build_docker() {
parent=$(pwd)
cd waku/$filtr
make docker
cd ..
cd $lpush
make docker
cd $parent
wait
}
2023-01-11 19:00:23 +00:00
2023-01-11 06:57:40 +00:00
start() {
2023-01-21 18:28:45 +00:00
#time="$(\date +"%Y-%m-%d-%Hh%Mm%Ss")"
ctopic="$duration-$iat-$time-$unique"
2023-01-13 19:40:43 +00:00
echo "\t\t.............................................."
echo "\t\tBEGINNING THE $1 RUN @ $time"
echo "\t\tparams: $ctopic"
echo "\t\t.............................................."
2023-01-11 06:57:40 +00:00
}
2023-01-11 19:00:23 +00:00
2023-01-11 06:57:40 +00:00
end() {
2023-01-13 19:40:43 +00:00
echo "\t\t $1 RUN DONE @ $(\date +"%Y-%m-%d-%Hh%Mm%Ss") "
echo "\t\t params: $ctopic"
2023-01-11 06:57:40 +00:00
}
2023-01-11 19:00:23 +00:00
2023-01-11 06:57:40 +00:00
metal_run() {
parent=$(pwd)
2023-01-13 19:40:43 +00:00
#time="$(\date +"%Y-%m-%d-%Hh%Mm%Ss")"
FTDIR="$host_output_dir/data/metal/$ctopic"
LPDIR="$host_output_dir/data/metal/$ctopic"
2023-01-11 06:57:40 +00:00
2023-01-21 18:28:45 +00:00
killall -SIGTERM $prefix-$filtr $prefix-$lpush # TODO: send SIGTERM/SIGINT
2023-01-11 06:57:40 +00:00
cd waku/$filtr
[ -d $FTDIR ] || mkdir -p $FTDIR
ofname="$FTDIR/$filtr.out"
echo -n "starting $filtr... $pwd "
2023-01-13 19:40:43 +00:00
./$prefix-$filtr -o $ofname -d $duration -i $iat -l $loglvl -c $ctopic > $FTDIR/$filtr.log &
2023-01-11 06:57:40 +00:00
echo " done"
cd ..
2023-01-21 18:28:45 +00:00
cd $lpush
2023-01-11 19:00:23 +00:00
2023-01-11 06:57:40 +00:00
sleep $sleep_time
2023-01-11 19:00:23 +00:00
2023-01-11 06:57:40 +00:00
[ -d $LPDIR ] || mkdir -p $LPDIR
ofname="$LPDIR/$lpush.out"
echo -n "starting $lpush... "
2023-01-13 19:40:43 +00:00
./$prefix-$lpush -o $ofname -d $duration -i $iat -l $loglvl -c $ctopic > $LPDIR/$lpush.log &
2023-01-11 06:57:40 +00:00
echo "done"
cd $parent
echo "$(date): Waiting for the metal run to finish in $duration"
2023-01-11 19:00:23 +00:00
wait # wait for runs to complete
2023-01-11 06:57:40 +00:00
}
docker_run() {
parent=$(pwd)
2023-01-13 19:40:43 +00:00
#time="$(\date +"%Y-%m-%d-%Hh%Mm%Ss")"
FTDIR="$host_output_dir/data/docker/$ctopic"
LPDIR="$host_output_dir/data/docker/$ctopic"
#FTDIR="$host_output_dir/data/docker/$time"
#LPDIR="$host_output_dir/data/docker/$time"
2023-01-11 06:57:40 +00:00
#darg= "--network=host"
2023-01-11 06:57:40 +00:00
[ -d $FTDIR ] || mkdir -p $FTDIR
ofname="$FTDIR/$filtr.out"
echo "docker: stopping and removing $prefix-$filtr"
2023-01-21 18:28:45 +00:00
docker stop $prefix-$filtr # NOTE: docker stop sends SIGTERM; stick to it
2023-01-11 06:57:40 +00:00
docker rm $prefix-$filtr
echo "docker: starting $prefix-$filtr"
echo "docker run --name "$prefix-$filtr" -d=true "$prefix-$filtr:alpha" -o "$docker_op_dir/$filtr.out" -d $duration -l $loglvl -i $iat -c $ctopic "
docker run --name "$prefix-$filtr" -d=true "$prefix-$filtr:alpha" -o "$docker_op_dir/$filtr.out" -d $duration -l $loglvl -i $iat -c $ctopic
2023-01-11 06:57:40 +00:00
echo "$prefix-$filtr is running as $prefix-$filtr"
2023-01-11 19:00:23 +00:00
sleep $sleep_time
[ -d $LPDIR ] || mkdir -p $LPDIR
ofname="$LPDIR/$lpush.out"
echo "docker: stopping and removing $prefix-$lpush"
2023-01-21 18:28:45 +00:00
docker stop $prefix-$lpush # NOTE: docker stop sends SIGTERM; stick to it
docker rm $prefix-$lpush
echo "docker: starting $prefix-$lpush"
echo " docker run --name "$prefix-$lpush" -d=true "$prefix-$lpush:alpha" -o "$docker_op_dir/$lpush.out" -d $duration -i $iat -l $loglvl -c $ctopic"
docker run --name "$prefix-$lpush" -d=true "$prefix-$lpush:alpha" -o "$docker_op_dir/$lpush.out" -d $duration -i $iat -l $loglvl -c $ctopic
2023-01-11 19:00:23 +00:00
# now wait for runs to complete...
2023-01-11 06:57:40 +00:00
echo "$(date): Waiting for the docker run to finish in $duration"
status_code="$(docker container wait $prefix-$filtr $prefix-$lpush)"
2023-01-11 19:00:23 +00:00
# copy the output files
2023-01-11 06:57:40 +00:00
echo "Status code of docker run: ${status_code}"
echo "$(date): copying output files from docker"
docker logs $prefix-$filtr > "$FTDIR/$filtr.log"
docker logs $prefix-$lpush > "$LPDIR/$lpush.log"
2023-01-13 19:40:43 +00:00
docker cp "$prefix-$filtr:$docker_op_dir/$filtr.out" $FTDIR
docker cp "$prefix-$lpush:$docker_op_dir/$lpush.out" $LPDIR
cd $parent
2023-01-11 06:57:40 +00:00
}
2023-01-11 19:00:23 +00:00
2023-01-11 06:57:40 +00:00
kurtosis_run() {
parent=$(pwd)
2023-01-13 19:40:43 +00:00
#time="$(\date +"%Y-%m-%d-%Hh%Mm%Ss")"
FTDIR="$host_output_dir/data/kurtosis/$ctopic"
LPDIR="$host_output_dir/data/kurtosis/$ctopic"
#FTDIR="$host_output_dir/data/kurtosis/$time"
#LPDIR="$host_output_dir/data/kurtosis/$time"
2023-01-11 06:57:40 +00:00
[ -d $FTDIR ] || mkdir -p $FTDIR
[ -d $LPDIR ] || mkdir -p $LPDIR
2023-01-11 09:23:40 +00:00
#cd waku
2023-01-21 18:28:45 +00:00
kurtosis clean -a # TODO: find out what signal kurtosis sends
2023-01-11 06:57:40 +00:00
docker rm $prefix-$filtr
docker rm $prefix-$lpush
2023-01-11 19:00:23 +00:00
2023-01-13 19:40:43 +00:00
# generate the config.json
echo "{
\"output_file\": \"output.out\",
\"duration\": \"$duration\",
\"iat\": \"$iat\",
\"content_topic\": \"$ctopic\",
\"log_level\": \"$loglvl\",
\"log_file\": \"output.log\"
2023-01-21 18:28:45 +00:00
}" > waku/config.json
2023-01-13 19:40:43 +00:00
2023-01-21 18:28:45 +00:00
echo "kurtosis run --enclave-id $enclave . '{\"config\":\"github.com/logos-co/wadoku/waku/config.json\", \"run_pair\":\"$run_pair\"}' > $FTDIR/kurtosis_output.log"
kurtosis run --enclave-id $enclave . '{"config":"github.com/logos-co/wadoku/waku/config.json", "run_pair":"'$run_pair'"}' > $FTDIR/kurtosis.output
sleep $sleep_time
2023-01-11 06:57:40 +00:00
filtr_suffix="$(kurtosis enclave inspect $enclave | grep $prefix-$filtr | cut -f 1 -d ' ')"
lpush_suffix="$(kurtosis enclave inspect $enclave | grep $prefix-$lpush | cut -f 1 -d ' ')"
2023-01-11 19:00:23 +00:00
# now wait for runs to complete...
2023-01-11 06:57:40 +00:00
filtr_cid="$enclave--user-service--$filtr_suffix"
lpush_cid="$enclave--user-service--$lpush_suffix"
echo "created $filtr_cid, $lpush_cid..."
2023-01-13 19:40:43 +00:00
echo "$(date): Waiting for the kurtosis ($filtr_cid, $lpush_cid ) run to finish in $duration"
2023-01-11 06:57:40 +00:00
status_code="$(docker container wait $filtr_cid $lpush_cid)"
2023-01-13 19:40:43 +00:00
2023-01-11 19:00:23 +00:00
# copy the output files
2023-01-11 06:57:40 +00:00
docker cp "$filtr_cid:/go/bin/out/$filtr.out" $FTDIR
2023-01-13 19:40:43 +00:00
docker logs $filtr_cid > $FTDIR/$filtr.log
2023-01-11 06:57:40 +00:00
docker cp "$lpush_cid:/go/bin/out/$lpush.out" $LPDIR
2023-01-13 19:40:43 +00:00
docker logs $lpush_cid > $LPDIR/$lpush.log
#kurtosis enclave dump $enclave $FTDIR/kurtosis_dump
2023-01-13 19:40:43 +00:00
echo "Status code of the kurtosis run: ${status_code}"
2023-01-11 06:57:40 +00:00
cd $parent
}
2023-01-11 19:00:23 +00:00
2023-01-21 18:28:45 +00:00
echo "$# $1 $2 $3 $4"
[ 4 -eq "$#" ] || usage
[ metal != $1 -a docker != $1 -a kurtosis != $1 -a clean != $1 ] && usage
2023-01-11 06:57:40 +00:00
if [ clean = $1 ]; then
start $1
clean
end $1
elif [ metal = $1 ]; then
2023-01-11 06:57:40 +00:00
build_metal
start $1
metal_run
end $1
elif [ docker = $1 ]; then
build_metal
build_docker
start $1
docker_run
end $1
elif [ kurtosis = $1 ]; then
build_metal
build_docker
2023-01-13 19:40:43 +00:00
clean # stay under the 4mb limit imposed by gRPC
2023-01-11 06:57:40 +00:00
start $1
kurtosis_run
end $1
else
usage
fi
2023-01-11 19:00:23 +00:00
# debris
2023-01-11 06:57:40 +00:00
2023-01-11 19:00:23 +00:00
# docker run '$prefix-$filtr:alpha' -o /go/bin/out/$filtr.out -d $duration -i $iat > $FTDIR/$filtr.log
#filtr_cid="$(docker container ls | grep '$prefix-$filtr' | awk '{print $1}')"
#docker run --mount type=bind,source="$FTDIR",target=/go/bin/out "$filtr:alpha" -o /go/bin/out/$filtr.out -d $duration -i $iat > $FTDIR/$filtr.log &
# docker run -d --entry-point --mount type=bind,source="$(pwd)/FTDIR",target=/go/bin/out $filtr:alpha
#./filter -o $ofname > filter.log &
2023-01-11 06:57:40 +00:00
2023-01-11 19:00:23 +00:00
# echo "(docker run '$prefix-$lpush:alpha' -o /go/bin/out/$lpush.out -d $duration -i $iat > $FTDIR/$filtr.log)"
# docker run '$prefix-$lpush:alpha' -o /go/bin/out/$lpush.out -d $duration -i $iat > $FTDIR/$filtr.log
2023-01-11 06:57:40 +00:00
2023-01-11 19:00:23 +00:00
# sleep 5
# lpush_cid="$(docker container ls | grep '$prefix-$filtr' | awk '{print $1}')"
# echo "$prefix-$lpush is running as $lpush_cid"
#docker run --mount type=bind,source="$LPDIR",target=/go/bin/out "$lpush:alpha" -o /go/bin/out/$lpush.out -d $duration -i $iat > $LPDIR/$lpush.log &
#filtr_cid="$(docker container ls | grep '$prefix-$filtr' | awk '{print $1}')"
#lpush_cid="$(docker container ls | grep '$prefix-$lpush' | awk '{print $1}')"