Loading scripts/bench_run.sh +26 −9 Changes for scripts/bench_run.sh: 26 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -23,15 +23,18 @@ # CAPTURE_FILTER capture filter (default: "sctp or udp port 2152") # DRY_RUN=1 print the commands instead of running them # # Usage: scripts/bench_run.sh [--sync] [--build] [--deploy-ut] [--no-ut] [--name NAME] # Usage: scripts/bench_run.sh [--sync] [--build] [--deploy-ut] [--no-ut] [--no-ut-restart] [--name NAME] # --name NAME base name of the capture (default: the first active test case of the [EXECUTE] section) # --no-ut do not touch the upper tester (no restart, no journal) # --no-ut-restart do not restart the upper tester, but still copy back its journal (e.g. it was just restarted, # or it runs in a terminal for debugging: then there is no journal to copy) # # Requirements, to avoid password prompts (the script still works with them, interactively): # - ssh keys: ssh-copy-id $PI_USER@$PI_HOST (and ATS_HOST when run from the development machine); # - on the Pi: sudo without password for the restart of the upper tester (upper_tester/deploy/sudoers-upper-tester), # and the Pi user in the systemd-journal group to read its journal (sudo usermod -aG systemd-journal $PI_USER); # - on the ATS host: sudo for tcpdump (asked for when the capture starts and stops). # - on the ATS host: tcpdump able to capture without sudo (setcap, Annex A.8 of TODO.md), or sudo without password # for tcpdump; otherwise the test runs without capture. set -u Loading @@ -50,6 +53,7 @@ SYNC=0 BUILD=0 DEPLOY_UT=0 USE_UT=1 RESTART_UT=1 NAME="" usage() { Loading @@ -62,6 +66,7 @@ while [[ $# -gt 0 ]]; do --build) BUILD=1; shift ;; --deploy-ut) DEPLOY_UT=1; shift ;; --no-ut) USE_UT=0; shift ;; --no-ut-restart) RESTART_UT=0; shift ;; --name) NAME="$2"; shift 2 ;; -h|--help) usage; exit 0 ;; *) echo "Unknown option: $1" >&2; usage >&2; exit 2 ;; Loading Loading @@ -130,7 +135,9 @@ if [[ $DEPLOY_UT == 1 ]]; then step "Deploying the upper tester to $PI:$UT_DIR" run rsync -a --delete --exclude __pycache__ --exclude docs "$TOP/upper_tester/" "$PI:$UT_DIR/" || exit 1 fi if [[ $USE_UT == 1 ]]; then if [[ $USE_UT == 1 && $RESTART_UT == 0 ]]; then step "Upper tester ($UT_SERVICE) on $PI: not restarted (--no-ut-restart)" elif [[ $USE_UT == 1 ]]; then step "Restarting the upper tester ($UT_SERVICE) on $PI" # -t: sudo can ask for its password, unless upper_tester/deploy/sudoers-upper-tester is installed run ssh -t "$PI" "sudo systemctl restart $UT_SERVICE && sleep 2 && systemctl is-active $UT_SERVICE" || exit 1 Loading @@ -139,24 +146,34 @@ fi START=$(date -u '+%Y-%m-%d %H:%M:%S') step "Starting the capture on $ATS_HOST ($CAPTURE_IF: $CAPTURE_FILTER)" # sudo -v first, interactively, so that the background tcpdump does not wait for a password ats -t "sudo -v && (sudo nohup tcpdump -i $CAPTURE_IF -w $CAPTURE_TMP '$CAPTURE_FILTER' >/dev/null 2>&1 & echo \$! > $PID_TMP)" || exit 1 [[ "$DRY_RUN" == "1" ]] || sleep 2 # tcpdump runs without sudo when it has the capture capabilities (see Annex A.8 of TODO.md), otherwise with sudo if # that needs no password. Without either, the test still runs, without capture: a password cannot be typed for a # background process CAPTURE=1 ats "rm -f $CAPTURE_TMP $PID_TMP; if timeout 2 tcpdump -i $CAPTURE_IF -c 1 -w /dev/null >/dev/null 2>&1 || [ \$? -eq 124 ]; then SUDO=; elif sudo -n true 2>/dev/null; then SUDO=sudo; else echo 'No capture: tcpdump needs root and sudo asks for a password (see Annex A.8 of TODO.md)'; exit 3; fi; \$SUDO nohup tcpdump -i $CAPTURE_IF -w $CAPTURE_TMP '$CAPTURE_FILTER' >/dev/null 2>&1 & echo \$! > $PID_TMP; echo \"\$SUDO\" > $PID_TMP.sudo; sleep 2; kill -0 \$(cat $PID_TMP) 2>/dev/null || \$SUDO kill -0 \$(cat $PID_TMP) 2>/dev/null || { echo 'tcpdump did not start'; exit 3; }" || CAPTURE=0 step "Running $ATS on $ATS_HOST" ats -t "cd $ATS_DIR/scripts && ATS=$ATS ./run_all.bash" if [[ $CAPTURE == 1 ]]; then step "Stopping the capture" ats -t "sudo kill -INT \$(cat $PID_TMP); sleep 1; sudo chmod a+r $CAPTURE_TMP" ats "SUDO=\$(cat $PID_TMP.sudo); \$SUDO kill -INT \$(cat $PID_TMP); sleep 1; \$SUDO chmod a+r $CAPTURE_TMP" fi mkdir -p "$TOP/logs/$ATS" "$TOP/captures" if [[ $ATS_LOCAL == 1 ]]; then step "Keeping the capture (the logs are already in logs/$ATS)" run cp "$CAPTURE_TMP" "$TOP/captures/$NAME.pcap" [[ $CAPTURE == 1 ]] && run cp "$CAPTURE_TMP" "$TOP/captures/$NAME.pcap" else step "Copying back the logs and the capture" run scp -q "$ATS_HOST:$ATS_DIR/logs/$ATS/*.log" "$TOP/logs/$ATS/" run scp -q "$ATS_HOST:$CAPTURE_TMP" "$TOP/captures/$NAME.pcap" [[ $CAPTURE == 1 ]] && run scp -q "$ATS_HOST:$CAPTURE_TMP" "$TOP/captures/$NAME.pcap" fi if [[ $USE_UT == 1 ]]; then step "Copying back the upper tester journal since $START (UTC)" Loading Loading
scripts/bench_run.sh +26 −9 Changes for scripts/bench_run.sh: 26 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -23,15 +23,18 @@ # CAPTURE_FILTER capture filter (default: "sctp or udp port 2152") # DRY_RUN=1 print the commands instead of running them # # Usage: scripts/bench_run.sh [--sync] [--build] [--deploy-ut] [--no-ut] [--name NAME] # Usage: scripts/bench_run.sh [--sync] [--build] [--deploy-ut] [--no-ut] [--no-ut-restart] [--name NAME] # --name NAME base name of the capture (default: the first active test case of the [EXECUTE] section) # --no-ut do not touch the upper tester (no restart, no journal) # --no-ut-restart do not restart the upper tester, but still copy back its journal (e.g. it was just restarted, # or it runs in a terminal for debugging: then there is no journal to copy) # # Requirements, to avoid password prompts (the script still works with them, interactively): # - ssh keys: ssh-copy-id $PI_USER@$PI_HOST (and ATS_HOST when run from the development machine); # - on the Pi: sudo without password for the restart of the upper tester (upper_tester/deploy/sudoers-upper-tester), # and the Pi user in the systemd-journal group to read its journal (sudo usermod -aG systemd-journal $PI_USER); # - on the ATS host: sudo for tcpdump (asked for when the capture starts and stops). # - on the ATS host: tcpdump able to capture without sudo (setcap, Annex A.8 of TODO.md), or sudo without password # for tcpdump; otherwise the test runs without capture. set -u Loading @@ -50,6 +53,7 @@ SYNC=0 BUILD=0 DEPLOY_UT=0 USE_UT=1 RESTART_UT=1 NAME="" usage() { Loading @@ -62,6 +66,7 @@ while [[ $# -gt 0 ]]; do --build) BUILD=1; shift ;; --deploy-ut) DEPLOY_UT=1; shift ;; --no-ut) USE_UT=0; shift ;; --no-ut-restart) RESTART_UT=0; shift ;; --name) NAME="$2"; shift 2 ;; -h|--help) usage; exit 0 ;; *) echo "Unknown option: $1" >&2; usage >&2; exit 2 ;; Loading Loading @@ -130,7 +135,9 @@ if [[ $DEPLOY_UT == 1 ]]; then step "Deploying the upper tester to $PI:$UT_DIR" run rsync -a --delete --exclude __pycache__ --exclude docs "$TOP/upper_tester/" "$PI:$UT_DIR/" || exit 1 fi if [[ $USE_UT == 1 ]]; then if [[ $USE_UT == 1 && $RESTART_UT == 0 ]]; then step "Upper tester ($UT_SERVICE) on $PI: not restarted (--no-ut-restart)" elif [[ $USE_UT == 1 ]]; then step "Restarting the upper tester ($UT_SERVICE) on $PI" # -t: sudo can ask for its password, unless upper_tester/deploy/sudoers-upper-tester is installed run ssh -t "$PI" "sudo systemctl restart $UT_SERVICE && sleep 2 && systemctl is-active $UT_SERVICE" || exit 1 Loading @@ -139,24 +146,34 @@ fi START=$(date -u '+%Y-%m-%d %H:%M:%S') step "Starting the capture on $ATS_HOST ($CAPTURE_IF: $CAPTURE_FILTER)" # sudo -v first, interactively, so that the background tcpdump does not wait for a password ats -t "sudo -v && (sudo nohup tcpdump -i $CAPTURE_IF -w $CAPTURE_TMP '$CAPTURE_FILTER' >/dev/null 2>&1 & echo \$! > $PID_TMP)" || exit 1 [[ "$DRY_RUN" == "1" ]] || sleep 2 # tcpdump runs without sudo when it has the capture capabilities (see Annex A.8 of TODO.md), otherwise with sudo if # that needs no password. Without either, the test still runs, without capture: a password cannot be typed for a # background process CAPTURE=1 ats "rm -f $CAPTURE_TMP $PID_TMP; if timeout 2 tcpdump -i $CAPTURE_IF -c 1 -w /dev/null >/dev/null 2>&1 || [ \$? -eq 124 ]; then SUDO=; elif sudo -n true 2>/dev/null; then SUDO=sudo; else echo 'No capture: tcpdump needs root and sudo asks for a password (see Annex A.8 of TODO.md)'; exit 3; fi; \$SUDO nohup tcpdump -i $CAPTURE_IF -w $CAPTURE_TMP '$CAPTURE_FILTER' >/dev/null 2>&1 & echo \$! > $PID_TMP; echo \"\$SUDO\" > $PID_TMP.sudo; sleep 2; kill -0 \$(cat $PID_TMP) 2>/dev/null || \$SUDO kill -0 \$(cat $PID_TMP) 2>/dev/null || { echo 'tcpdump did not start'; exit 3; }" || CAPTURE=0 step "Running $ATS on $ATS_HOST" ats -t "cd $ATS_DIR/scripts && ATS=$ATS ./run_all.bash" if [[ $CAPTURE == 1 ]]; then step "Stopping the capture" ats -t "sudo kill -INT \$(cat $PID_TMP); sleep 1; sudo chmod a+r $CAPTURE_TMP" ats "SUDO=\$(cat $PID_TMP.sudo); \$SUDO kill -INT \$(cat $PID_TMP); sleep 1; \$SUDO chmod a+r $CAPTURE_TMP" fi mkdir -p "$TOP/logs/$ATS" "$TOP/captures" if [[ $ATS_LOCAL == 1 ]]; then step "Keeping the capture (the logs are already in logs/$ATS)" run cp "$CAPTURE_TMP" "$TOP/captures/$NAME.pcap" [[ $CAPTURE == 1 ]] && run cp "$CAPTURE_TMP" "$TOP/captures/$NAME.pcap" else step "Copying back the logs and the capture" run scp -q "$ATS_HOST:$ATS_DIR/logs/$ATS/*.log" "$TOP/logs/$ATS/" run scp -q "$ATS_HOST:$CAPTURE_TMP" "$TOP/captures/$NAME.pcap" [[ $CAPTURE == 1 ]] && run scp -q "$ATS_HOST:$CAPTURE_TMP" "$TOP/captures/$NAME.pcap" fi if [[ $USE_UT == 1 ]]; then step "Copying back the upper tester journal since $START (UTC)" Loading