tests: starting point for stress testing
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tue, 10 Dec 2013 11:19:02 +0000 (13:19 +0200)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tue, 10 Dec 2013 11:19:02 +0000 (13:19 +0200)
This starting point for stress testing. Generates 200 files each
with 10000 random access rules. Does not yet support modify rules.
Next step would be probably making this more parametrized.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
tests/generate-rules.sh [new file with mode: 0755]

diff --git a/tests/generate-rules.sh b/tests/generate-rules.sh
new file mode 100755 (executable)
index 0000000..6434204
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+LABELS=(`aspell dump master | tr "'" "_" | shuf | head -200`)
+ACCESS=('r' 'w' 'x' 'a' 't')
+LABELS_LEN=${#LABELS[@]}
+
+function get_access_code()
+{
+    local result
+    for i in `seq 0 1 4`; do
+       if test `expr $RANDOM % 2` -eq 0; then
+           result="$result${ACCESS[$i]}"
+       else
+           result="$result-"
+       fi
+    done
+
+    eval "$1=$result"
+}
+
+function print_access_rules()
+{
+    for i in `seq 0 1 10000`; do
+       local subject_i=`expr $RANDOM % $LABELS_LEN`
+       local object_i=`expr $RANDOM % $LABELS_LEN`
+       local acc=''
+       get_access_code acc
+       echo ${LABELS[$subject_i]} ${LABELS[$object_i]} $acc >> $1
+    done
+}
+
+for i in `seq 0 1 200`; do
+       print_access_rules $i.txt
+done