From 5befb6a9546c154eb723f93fd1402ab3d7e1837d Mon Sep 17 00:00:00 2001 From: rhuairahrighairigh Date: Fri, 4 Oct 2019 13:44:51 -0400 Subject: [PATCH] sim script UX improvements --- simulations/run-then-upload.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/simulations/run-then-upload.sh b/simulations/run-then-upload.sh index d862adf3..3bf54c3e 100755 --- a/simulations/run-then-upload.sh +++ b/simulations/run-then-upload.sh @@ -7,24 +7,27 @@ # Parse Input Args +# get simulation type +simType=$1 # get seed -startingSeed=$1 +startingSeed=$2 # compute the seed from the starting and the job index # add two nums together, hence the $(()), and use 0 as the default value for array index, hence the ${:-} syntax seed=$(($startingSeed+${AWS_BATCH_JOB_ARRAY_INDEX:-0})) -echo "seed: " $seed # get sim parameters -numBlocks=$2 -blockSize=$3 +numBlocks=$3 +blockSize=$4 # Run The Sim -# redirect stdout and stderr to a file -go test ./app -run TestFullAppSimulation -Enabled=true -NumBlocks=$numBlocks -BlockSize=$blockSize -Commit=true -Period=5 -Seed=$seed -v -timeout 24h > out.log 2>&1 +# record cli arguments in the log file (in json in case we need to parse this) and stdout (https://stackoverflow.com/questions/418896/how-to-redirect-output-to-a-file-and-stdout) +printf "{\"simType\": \"%s\", \"startingSeed\": %s, \"seed\": %s, \"numBlocks\": %s, \"blockSize\": %s}\n" $simType $startingSeed $seed $numBlocks $blockSize | tee out.log +# run sim and redirect stdout and stderr to a file) +go test ./app -run $simType -Enabled=true -NumBlocks=$numBlocks -BlockSize=$blockSize -Commit=true -Period=5 -Seed=$seed -v -timeout 24h >> out.log 2>&1 # get the exit code to determine how to upload results simExitStatus=$? if [ $simExitStatus -eq 0 ];then - echo "simulations passed" + echo "simulation passed" simResult="pass" else echo "simulation failed" @@ -39,5 +42,5 @@ jobID=${AWS_BATCH_JOB_ID:-"testJobID:"} jobID=$(echo $jobID | sed 's/\(.*\):\d*/\1/') # create the filename from the array job index (which won't be set if this is a normal job) -fileName=out$AWS_BATCH_JOB_ARRAY_INDEX.log +fileName=$(printf "out%05d.log" $AWS_BATCH_JOB_ARRAY_INDEX) aws s3 cp out.log s3://simulations-1/$jobID/$simResult/$fileName \ No newline at end of file