From 05f0545c21fd51c8a1a5ddc8ed409c58552ee4f7 Mon Sep 17 00:00:00 2001 From: Jarkko Sakkinen Date: Tue, 10 Dec 2013 13:19:02 +0200 Subject: [PATCH] tests: starting point for stress testing 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 --- tests/generate-rules.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tests/generate-rules.sh diff --git a/tests/generate-rules.sh b/tests/generate-rules.sh new file mode 100755 index 0000000..6434204 --- /dev/null +++ b/tests/generate-rules.sh @@ -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 -- 2.7.4