This patch contains scripts for applying stress on host or guest at 39/24539/17
authorShravani <shravani.p@tcs.com>
Thu, 8 Dec 2016 05:18:16 +0000 (21:18 -0800)
committerShravani <shravani.p@tcs.com>
Thu, 8 Dec 2016 06:10:36 +0000 (22:10 -0800)
run time based on the stress type(cpu/memory/io).

Change-Id: I845b3ec028f375cf0809fb3a184b1511787d263b
Signed-off-by: Shravani <shravani.p@tcs.com>
ci/envs/stress_daily.sh [new file with mode: 0755]
ci/envs/stress_scripts.sh [new file with mode: 0755]

diff --git a/ci/envs/stress_daily.sh b/ci/envs/stress_daily.sh
new file mode 100755 (executable)
index 0000000..a07c807
--- /dev/null
@@ -0,0 +1,26 @@
+##########################################################################
+#This script will pass arguments to stress script based on the stress type
+##########################################################################
+#!/bin/bash
+source host-config
+
+stress_type=$1
+timeout=10m
+
+case $stress_type in
+   cpu) # processor
+      ARGS="--cpu=100"
+      ;;
+   memory)
+      ARGS="--vm=100"
+      ;;
+   io)
+      ARGS="--io 10 --hdd 100"
+      ;;
+   *)
+      echo $"Usage: $0 {cpu|memory|io}"
+      exit 1
+esac
+
+#stress_isolcpus will hold range as a value i.e, eg :24-43
+sh stress_scripts.sh -c ${stress_isolcpus} -t $timeout -a $ARGS
diff --git a/ci/envs/stress_scripts.sh b/ci/envs/stress_scripts.sh
new file mode 100755 (executable)
index 0000000..959a0aa
--- /dev/null
@@ -0,0 +1,70 @@
+################################################################
+#This script will impose stress on specified processors with the
+#arguments passed based on stress type.
+################################################################
+#!/bin/bash
+function usage() {
+    echo ""
+    echo "Usage --> $0 [-c CPU] [-t timeout] [-a stress-args][-h]"
+    echo "  CPU : 1/0-2 ;  default is 22-43"
+    echo "  timeout : N(number)"
+    echo "  stress-args : "--cpu=100 --vm=100 --io=10 --hdd=100""
+    echo "  -h : Help section"
+    echo ""
+}
+
+##  --- Parse command line arguments / parameters ---
+while getopts ":c:t:a:h" option; do
+    case $option in
+        c) # processor
+          processors=$OPTARG
+          ;;
+        t) # output_dir
+          timeout=$OPTARG
+          ;;
+        a)#istress args
+          args=$OPTARG
+          ;;
+        :)
+          echo "Option -$OPTARG requires an argument."
+          usage
+          exit 1
+          ;;
+        h)
+          usage
+          exit 0
+          ;;
+        *)
+          echo "Unknown option: $OPTARG."
+          usage
+          exit 1
+          ;;
+        ?)
+          echo "[WARNING] Unknown parameters!!!"
+          echo "Using default values for CPU,timeout and stress parameters"
+    esac
+done
+
+
+if [[ -z "$processors" ]]
+then
+    processors='22-43'
+fi
+
+if [[ -z "$timeout" ]]
+then
+   timeout='10m'
+fi
+
+if [[ -z "$args" ]]
+then
+   args="--cpu=100"
+fi
+
+stress_params=$(echo $args | sed 's/[,=]/ /g'|sed -e 's/\r//g')
+
+cmd="taskset -c $processors stress --timeout ${timeout} ${stress_params}"
+
+echo $cmd
+
+eval "${cmd}" &>/dev/null &disown