Stress Test - juju/juju GitHub Wiki

#!/bin/bash

# run this script from the root of a package.

set -e
go test -c $*
PKG=$(basename $(pwd))

while true ; do
  env GOMAXPROCS=$[ 1 + $[ RANDOM % 128 ]] ./$PKG.test $@ 2>&1
done

I've updated this to the following so I can see how long and how many times the test was run before triggering a race -- or failing to trigger ideally:)

#!/usr/bin/env bash
set -e

# go test -c
# comment above and uncomment below to enable the race builder
go test -c -race
PKG=$(basename $(pwd))

# Counter
C=0
START_TIME=$SECONDS

while true ; do 
        C=$((C+1))
        export GOTRACEBACK=all
        export GOMAXPROCS=$[ 1 + $[ RANDOM % 128 ]]
        ./$PKG.test $@ 2>&1
        ELAPSED_TIME=$(($SECONDS - $START_TIME))
        echo "$C successful runs in $(($ELAPSED_TIME/60)) min $(($ELAPSED_TIME%60)) sec"   
done