#!/bin/bash ncpus="" cpurange="" while [ -n "$1" ]; do if [ "$1" == "-n" ]; then ncpus="$2" shift elif [ "$1" == "-N" ]; then cpurange="$2" shift fi shift done if [ -z "$ncpus" ]; then if [ -n "$cpurange" ]; then ncpus=$(docker run --rm troll-patrol numactl -C $cpurange nproc) else ncpus=$(nproc) fi fi if [ -z "$cpurange" ]; then cpurange="0-$((ncpus - 1))" fi hosts=() for i in {1..5}; do hosts+=(lox-old) done for i in {1..5}; do hosts+=(lox-new) done for i in {1..6}; do hosts+=(troll-patrol) done cmds=( "cargo test --release --features fast -- --nocapture stats_test_trust_levels > trust_levels.log" "cargo test --release --features fast -- --nocapture stats_test_invitations > invitations.log" "cargo test --release --features fast -- --nocapture stats_test_percent_blockage_migration_05 > blockage_migration05.log" "cargo test --release --features fast -- --nocapture stats_test_percent_blockage_migration_50 > blockage_migration50.log" "cargo test --release --features fast -- --nocapture stats_test_percent_blockage_migration_100 > blockage_migration100.log" "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_trust_levels > trust_levels.log" "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_invitations > invitations.log" "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_05 > blockage_migration05.log" "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_50 > blockage_migration50.log" "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_100 > blockage_migration100.log" "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_reporting > reporting.log" "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_trust_levels > trust_levels.log" "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_invitations > invitations.log" "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_05 > blockage_migration05.log" "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_50 > blockage_migration50.log" "cargo test --release --features bridgeauth,test,fast -- --nocapture stats_test_percent_blockage_migration_100 > blockage_migration100.log" ) index=0 i=0 for i in ${!cmds[@]}; do cmd="${cmds[$i]}" file="${cmd##* }" host="${hosts[$i]}" echo "Starting command ${cmd} with docker image ${host} with index ${index}..." # New container docker run --name "${host}-${file}" --rm -d -i "${host}:latest" || exit 1 # Run command in this docker docker exec "${host}-${file}" numactl -C "$cpurange" numactl -C +$index sh -c "$cmd" & index=$((index + 1)) echo "Command started and pushed to background." if [ $index == "$ncpus" ]; then echo "Waiting for the first $ncpus commands to complete..." wait index=0 fi done wait # Extract log files from docker containers and shut them down mkdir -p parsing-results/{lox-old,lox-new,troll-patrol} for i in {0..4}; do cmd="${cmds[$i]}" file="${cmd##* }" host="${hosts[$i]}" docker cp "${host}-${file}":/home/lox/"${file}" parsing-results/lox-old/ && docker stop "${host}-${file}" done for i in {5..15}; do cmd="${cmds[$i]}" file="${cmd##* }" host="${hosts[$i]}" docker cp "${host}-${file}":/home/lox/crates/lox-extensions/"${file}" parsing-results/${host}/ && docker stop "${host}-${file}" done