diff options
| -rwxr-xr-x | bin/disk_stress_ng | 40 | ||||
| -rwxr-xr-x | bin/memory_stress_ng | 7 | ||||
| -rwxr-xr-x | bin/network | 57 | ||||
| -rwxr-xr-x | bin/storage_test | 29 |
4 files changed, 105 insertions, 28 deletions
diff --git a/bin/disk_stress_ng b/bin/disk_stress_ng index 802d116..a47ab79 100755 --- a/bin/disk_stress_ng +++ b/bin/disk_stress_ng @@ -131,7 +131,7 @@ find_largest_partition() { # $mounted_part -- Sets to "Y" if script mounted partition # $made_mountpoint -- Sets to "Y" if script created the mount point mount_filesystem() { - test_dir="/tmp/disk_stress_ng" + test_dir="/tmp/disk_stress_ng_$(uuidgen)" if [ -b $disk_device ] then echo "$disk_device is a block device" @@ -167,9 +167,9 @@ mount_filesystem() { mounted_part="Y" fi if [ "$mount_point" == "/" ] ; then - test_dir="/tmp/disk_stress_ng" + test_dir="/tmp/disk_stress_ng_$(uuidgen)" else - test_dir="$mount_point/tmp/disk_stress_ng" + test_dir="$mount_point/tmp/disk_stress_ng_$(uuidgen)" fi echo "Test will use $largest_part, mounted at \"$mount_point\", using $largest_fs" else @@ -200,11 +200,28 @@ run_stressor() { echo "Running stress-ng $1 stressor for $2 seconds...." # Use "timeout" command to launch stress-ng, to catch it should it go into # la-la land - timeout -s 9 $end_time stress-ng --aggressive --verify --timeout $runtime \ - --temp-path $test_dir --$1 0 + timeout -s 14 $end_time stress-ng --aggressive --verify --timeout $runtime \ + --temp-path $test_dir --$1 0 --hdd-opts dsync --readahead-bytes 16M -k return_code="$?" echo "return_code is $return_code" if [ "$return_code" != "0" ] ; then + # + # a small grace period to allow stressors to terminate + # + sleep 10 + # + # still running? aggressively kill all stressors + # + pids=$(pidof stress-ng) + if [ -n "$pids" ]; then + kill -9 $pids + sleep 1 + kill -9 $pids + pids=$(pidof stress-ng) + if [ -n "$pids" ]; then + echo "Note: stress-ng (PIDS $pids) could not be killed" + fi + fi had_error=1 echo "*****************************************************************" if [ $return_code = "137" ] ; then @@ -244,6 +261,19 @@ disk_stressors=("aio" "aiol" "chdir" "chmod" "dentry" "dir" "fallocate" \ total_runtime=$((${#disk_stressors[@]}*$base_time)) +# +# Ensure we have emnough async I/O events available, scale it +# based on number of CPUs on the machine +# +if [ -e /proc/sys/fs/aio-max-nr ] ; then + aiomax=$((8192 * $(nproc))) + aionow=$(cat /proc/sys/fs/aio-max-nr) + if [ $aiomax -gt $aionow ] ; then + echo $aiomax > /proc/sys/fs/aio-max-nr + echo "Setting aio-max-nr to $aiomax" + fi +fi + echo "Estimated total run time is $total_runtime seconds" echo "" diff --git a/bin/memory_stress_ng b/bin/memory_stress_ng index e619772..35c7725 100755 --- a/bin/memory_stress_ng +++ b/bin/memory_stress_ng @@ -114,7 +114,12 @@ echo "Variable run time is $variable_time seconds per stressor" had_error=0 -numa_nodes=$(numactl --hardware | grep available | head -n 1 | cut -f 2 -d " ") +command -v numactl >/dev/null 2>&1 +if [ $? == 0 ] ; then + numa_nodes=$(numactl --hardware | grep available | head -n 1 | cut -f 2 -d " ") +else + numa_nodes=1 +fi # NOTE: Specify stressors in two arrays rather than rely on stress-ng's # --class memory,vm option for two reasons: diff --git a/bin/network b/bin/network index 19c2ac3..8291674 100755 --- a/bin/network +++ b/bin/network @@ -280,29 +280,46 @@ class Interface(socket.socket): @property def max_speed(self): - # Parse mii-tool data for max speed - # search for numbers in the line starting with 'capabilities' - # return largest number as max_speed + speeds = [0] + # parse ethtool output, look for things like: + # 100baseSX, 40000baseNX, 10000baseT try: - info = check_output(['mii-tool', '-v', self.interface], - universal_newlines=True, - stderr=STDOUT).split('\n') - except FileNotFoundError: - logging.warning('mii-tool not found! Unable to get max speed') - ethinfo = None - except CalledProcessError as e: - logging.error('mii-tool returned an error!') - logging.error(e.output) - ethinfo = None - finally: - regex = re.compile(r'(\d+)(base)([A-Z]+)') - speeds = [0] - for line in filter(lambda l: 'capabilities' in l, info): - for s in line.split(' '): - hit = regex.search(s) + ethinfo = check_output(['ethtool', self.interface], + universal_newlines=True, + stderr=STDOUT).split(' ') + expression = '(\\d+)(base)([A-Z]+)|(\d+)(Mb/s)' + + regex = re.compile(expression) + if ethinfo: + for i in ethinfo: + hit = regex.search(i) if hit: speeds.append(int(re.sub("\D", "", hit.group(0)))) - return max(speeds) + except CalledProcessError as e: + logging.error('ethtool returned an error!') + logging.error(e.output) + except FileNotFoundError: + logging.warning('ethtool not found! Trying mii-tool') + # Parse mii-tool data for max speed + # search for numbers in the line starting with 'capabilities' + # return largest number as max_speed + try: + info = check_output(['mii-tool', '-v', self.interface], + universal_newlines=True, + stderr=STDOUT).split('\n') + regex = re.compile(r'(\d+)(base)([A-Z]+)') + speeds = [0] + for line in filter(lambda l: 'capabilities' in l, info): + for s in line.split(' '): + hit = regex.search(s) + if hit: + speeds.append(int(re.sub("\D", "", hit.group(0)))) + except FileNotFoundError: + logging.warning('mii-tool not found! Unable to get max speed') + except CalledProcessError as e: + logging.error('mii-tool returned an error!') + logging.error(e.output) + return max(speeds) @property def macaddress(self): diff --git a/bin/storage_test b/bin/storage_test index 40cc3f2..1aed0da 100755 --- a/bin/storage_test +++ b/bin/storage_test @@ -59,6 +59,7 @@ find_largest_partition() { } # find_largest_partition() disk=/dev/$1 +scripted_mount=0 if [ -b $disk ] then @@ -93,10 +94,13 @@ then find_largest_partition if [ -n "$largest_part" ] then - dest=/tmp/drive/$partition + dest=`mktemp -dq --tmpdir drive.XXX` echo "Mounting $largest_part into $dest..." - mkdir -p $dest mount $largest_part $dest + if [[ $? == 0 ]] + then + scripted_mount=1 + fi else echo "$disk has no partition. Please format this drive and re-launch the test." exit 1 @@ -115,12 +119,33 @@ then if [ $size_int -gt 10 ] then run_bonnie $disk + if [[ $scripted_mount == 1 ]] + then + echo "$largest_part was mounted by this script. Unmounting it now..." + umount $largest_part + echo "Removing temporary mount directory $dest..." + rm -rf $dest + fi else echo "$disk is too small to be used for testing." + if [[ $scripted_mount == 1 ]] + then + echo "$largest_part was mounted by this script. Unmounting it now..." + umount $largest_part + echo "Removing temporary mount directory $dest..." + rm -rf $dest + fi exit 1 fi else run_bonnie $disk + if [[ $scripted_mount == 1 ]] + then + echo "$largest_part was mounted by this script. Unmounting it now..." + umount $largest_part + echo "Removing temporary mount directory $dest..." + rm -rf $dest + fi fi else echo "$disk doesn't report a size." |
