2023-01-11 06:57:40 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
usage(){
|
2023-01-11 07:10:42 +00:00
|
|
|
echo "Usage: ./run.sh < clean | metal | docker | kurtosis>"
|
2023-01-11 06:57:40 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
filtr="filter"
|
|
|
|
lpush="lightpush"
|
|
|
|
|
|
|
|
prefix="waku"
|
|
|
|
docker_op_dir="/go/bin/out"
|
|
|
|
enclave="waku-enclave"
|
|
|
|
|
2023-01-11 19:00:23 +00:00
|
|
|
content_topic="80fc1f6b30b63bdd0a65df833f1da3fa" #just to be unique, a md5
|
|
|
|
duration="1000s" # run duration is 16.666 mins
|
|
|
|
iat="300ms" # pub msg inter-arrival-time is 300ms
|
2023-01-11 06:57:40 +00:00
|
|
|
|
|
|
|
sleep_time=5
|
|
|
|
|
2023-01-11 07:10:42 +00:00
|
|
|
clean(){
|
|
|
|
parent=$(pwd)
|
|
|
|
#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() {
|
|
|
|
echo "\t\t.........................."
|
|
|
|
echo "\t\tBEGINNING THE $1 RUN..."
|
|
|
|
echo "\t\t.........................."
|
|
|
|
}
|
|
|
|
|
2023-01-11 19:00:23 +00:00
|
|
|
|
2023-01-11 06:57:40 +00:00
|
|
|
end() {
|
|
|
|
echo "\t\t $1 RUN DONE..."
|
|
|
|
}
|
|
|
|
|
2023-01-11 19:00:23 +00:00
|
|
|
|
2023-01-11 06:57:40 +00:00
|
|
|
metal_run() {
|
|
|
|
parent=$(pwd)
|
|
|
|
time="$(\date +"%Y-%m-%d-%Hh%Mm%Ss")"
|
|
|
|
FTDIR="$(pwd)/data/metal/$time"
|
|
|
|
LPDIR="$(pwd)/data/metal/$time"
|
|
|
|
|
|
|
|
cd waku/$filtr
|
|
|
|
[ -d $FTDIR ] || mkdir -p $FTDIR
|
|
|
|
ofname="$FTDIR/$filtr.out"
|
|
|
|
echo -n "starting $filtr... $pwd "
|
|
|
|
./$prefix-$filtr -o $ofname -d $duration -i $iat > $FTDIR/$filtr.log &
|
|
|
|
echo " done"
|
|
|
|
cd ..
|
|
|
|
cd lightpush
|
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... "
|
|
|
|
./$prefix-$lpush -o $ofname -d $duration -i $iat > $LPDIR/$lpush.log &
|
|
|
|
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)
|
|
|
|
time="$(\date +"%Y-%m-%d-%Hh%Mm%Ss")"
|
|
|
|
FTDIR="$(pwd)/data/docker/$time"
|
|
|
|
LPDIR="$(pwd)/data/docker/$time"
|
|
|
|
|
|
|
|
[ -d $FTDIR ] || mkdir -p $FTDIR
|
|
|
|
ofname="$FTDIR/$filtr.out"
|
|
|
|
echo "docker run $filtr $ofname"
|
|
|
|
docker rm $prefix-$filtr
|
|
|
|
echo "(docker run --name "$prefix-$filtr" "$prefix-$filtr:alpha" -o /go/bin/out/$filtr.out -d $duration -i $iat > $FTDIR/$filtr.log)"
|
|
|
|
docker run --name "$prefix-$filtr" "$prefix-$filtr:alpha" -o /go/bin/out/$filtr.out -d $duration -i $iat > $FTDIR/$filtr.log &
|
|
|
|
echo "$prefix-$filtr is running as $prefix-$filtr"
|
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 "docker run $lpush $ofname"
|
|
|
|
docker rm $prefix-$lpush
|
|
|
|
docker run --name "$prefix-$lpush" "$prefix-$lpush:alpha" -o /go/bin/out/$lpush.out -d $duration -i $iat > $LPDIR/$lpush.log &
|
|
|
|
echo "$prefix-$filtr is running as $prefix-$lpush"
|
|
|
|
cd $parent
|
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"
|
2023-01-11 19:00:23 +00:00
|
|
|
docker cp "$prefix-$filtr:/go/bin/out/$filtr.out" $FTDIR
|
|
|
|
docker cp "$prefix-$lpush:/go/bin/out/$lpush.out" $LPDIR
|
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)
|
|
|
|
time="$(\date +"%Y-%m-%d-%Hh%Mm%Ss")"
|
|
|
|
FTDIR="$(pwd)/data/kurtosis/$time"
|
|
|
|
LPDIR="$(pwd)/data/kurtosis/$time"
|
|
|
|
|
|
|
|
[ -d $FTDIR ] || mkdir -p $FTDIR
|
|
|
|
[ -d $LPDIR ] || mkdir -p $LPDIR
|
2023-01-11 09:23:40 +00:00
|
|
|
#cd waku
|
2023-01-11 06:57:40 +00:00
|
|
|
kurtosis clean -a
|
|
|
|
docker rm $prefix-$filtr
|
|
|
|
docker rm $prefix-$lpush
|
2023-01-11 19:00:23 +00:00
|
|
|
|
2023-01-11 09:37:25 +00:00
|
|
|
kurtosis run --enclave-id $enclave main.star '{"config":"github.com/logos-co/wadoku/waku/config.json"}' > $FTDIR/kurtosis_output.log
|
2023-01-11 19:00:23 +00:00
|
|
|
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..."
|
|
|
|
echo "$(date): Waiting for the kurtosis run to finish in $duration"
|
|
|
|
status_code="$(docker container wait $filtr_cid $lpush_cid)"
|
|
|
|
echo "Status code of the kurtosis run: ${status_code}"
|
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
|
|
|
|
docker cp "$lpush_cid:/go/bin/out/$lpush.out" $LPDIR
|
|
|
|
cd $parent
|
|
|
|
}
|
|
|
|
|
2023-01-11 19:00:23 +00:00
|
|
|
|
2023-01-11 06:57:40 +00:00
|
|
|
echo "$# $1"
|
|
|
|
[ 1 -eq "$#" ] || usage
|
2023-01-11 07:10:42 +00:00
|
|
|
[ metal != $1 -a docker != $1 -a kurtosis != $1 -a clean != $1 ] && usage
|
2023-01-11 06:57:40 +00:00
|
|
|
|
|
|
|
|
2023-01-11 07:10:42 +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
|
|
|
|
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}')"
|