Add prefix to run multiple xp in parallel

This commit is contained in:
Quentin Dufour 2020-01-19 19:43:02 +00:00
parent 4027b8ef75
commit a3c41400ec

View file

@ -5,6 +5,7 @@
die() { echo "$*" 1>&2 ; exit 1; } die() { echo "$*" 1>&2 ; exit 1; }
DOCKNAME=`mktemp -u XXXXX`
WAITFOR=7200 # 2 hours WAITFOR=7200 # 2 hours
# SPLIT CLIENT AND SERVER TARGETS # SPLIT CLIENT AND SERVER TARGETS
@ -54,14 +55,14 @@ echo "__reset containers"
for i in $(seq 0 $(expr $instances - 1)); do for i in $(seq 0 $(expr $instances - 1)); do
echo "____clear $i" echo "____clear $i"
docker container inspect donarxp_server_${i} > /dev/null 2>&1 && docker kill donarxp_server_${i} docker container inspect ${DOCKNAME}_donarxp_server_${i} > /dev/null 2>&1 && docker kill ${DOCKNAME}_donarxp_server_${i}
docker container inspect donarxp_client_${i} > /dev/null 2>&1 && docker kill donarxp_client_${i} docker container inspect ${DOCKNAME}_donarxp_client_${i} > /dev/null 2>&1 && docker kill ${DOCKNAME}_donarxp_client_${i}
echo "____spawning container for instance=$i..." echo "____spawning container for instance=$i..."
docker run \ docker run \
--rm \ --rm \
-d \ -d \
--name "donarxp_server_${i}" \ --name "${DOCKNAME}_donarxp_server_${i}" \
--privileged \ --privileged \
--cap-add=SYS_PTRACE \ --cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \ --security-opt seccomp=unconfined \
@ -76,15 +77,15 @@ for i in $(seq 0 $(expr $instances - 1)); do
--privileged \ --privileged \
--cap-add=SYS_PTRACE \ --cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \ --security-opt seccomp=unconfined \
--name "donarxp_client_${i}" \ --name "${DOCKNAME}_donarxp_client_${i}" \
-e HOME='/tmp' \ -e HOME='/tmp' \
-v `pwd`/out:/home/donar/out \ -v `pwd`/out:/home/donar/out \
registry.gitlab.inria.fr/qdufour/donar \ registry.gitlab.inria.fr/qdufour/donar \
${TOR_DAEMON_CLIENT[$i]} ${TOR_DAEMON_CLIENT[$i]}
echo "____create folder struct..." echo "____create folder struct..."
docker exec donarxp_client_${i} sh -c "mkdir -p $run_fold-$i; echo repeat=$REPEAT,identifier=$IDENTIFIER > $run_fold-$i/info.txt" docker exec ${DOCKNAME}_donarxp_client_${i} sh -c "mkdir -p $run_fold-$i; echo repeat=$REPEAT,identifier=$IDENTIFIER > $run_fold-$i/info.txt"
docker exec donarxp_client_${i} sh -c "echo instance=$i - server=${SERVER_TARGETS[$i]} - client=${CLIENT_TARGETS[$i]} - tor server=${TOR_DAEMON_SERVER[$i]} - tor client=${TOR_DAEMON_CLIENT[$i]}>> $run_fold-$i/info.txt" docker exec ${DOCKNAME}_donarxp_client_${i} sh -c "echo instance=$i - server=${SERVER_TARGETS[$i]} - client=${CLIENT_TARGETS[$i]} - tor server=${TOR_DAEMON_SERVER[$i]} - tor client=${TOR_DAEMON_CLIENT[$i]}>> $run_fold-$i/info.txt"
done done
sleep 10 sleep 10
@ -92,7 +93,7 @@ sleep 10
echo "__launch servers" echo "__launch servers"
for i in $(seq 0 $(expr $instances - 1)); do for i in $(seq 0 $(expr $instances - 1)); do
echo " instance=$i - exec=${SERVER_TARGETS[$i]}" echo " instance=$i - exec=${SERVER_TARGETS[$i]}"
docker exec donarxp_server_$i ${SERVER_TARGETS[$i]} ${run_fold}-$i & docker exec ${DOCKNAME}_donarxp_server_$i ${SERVER_TARGETS[$i]} ${run_fold}-$i &
sleep 1 sleep 1
done done
@ -103,15 +104,15 @@ echo "__launch clients"
(sleep $WAITFOR; echo " timeout"; kill -9 $subshellpid) & (sleep $WAITFOR; echo " timeout"; kill -9 $subshellpid) &
(for i in $(seq 0 $(expr $instances - 1)); do (for i in $(seq 0 $(expr $instances - 1)); do
echo " instance=$i - exec=${CLIENT_TARGETS[$i]}" echo " instance=$i - exec=${CLIENT_TARGETS[$i]}"
docker exec donarxp_client_$i ${CLIENT_TARGETS[$i]} ${run_fold}-$i & docker exec ${DOCKNAME}_donarxp_client_$i ${CLIENT_TARGETS[$i]} ${run_fold}-$i &
sleep 1 sleep 1
done; done;
wait; wait;
echo " ok"; echo " ok";
for i in $(seq 0 $(expr $instances - 1)); do for i in $(seq 0 $(expr $instances - 1)); do
docker exec donarxp_client_${i} killall -15 donar; docker exec ${DOCKNAME}_donarxp_client_${i} killall -15 donar;
docker exec donarxp_server_${i} killall -15 donar; docker exec ${DOCKNAME}_donarxp_server_${i} killall -15 donar;
done; done;
kill -15 $subshellpid kill -15 $subshellpid
@ -124,6 +125,6 @@ done
echo ":: Clear Resources" echo ":: Clear Resources"
for i in $(seq 0 $(expr $instances - 1)); do for i in $(seq 0 $(expr $instances - 1)); do
echo "clear $i" echo "clear $i"
docker kill "donarxp_server_${i}" docker kill "${DOCKNAME}_donarxp_server_${i}"
docker kill "donarxp_client_${i}" docker kill "${DOCKNAME}_donarxp_client_${i}"
done done