summaryrefslogtreecommitdiffstats
path: root/stress.sh
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-04-06 14:47:53 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-04-06 16:26:13 +0200
commitf3afb0c16cca4556b01a3839eaba5a80f654b25e (patch)
tree76936b623db2bfdeb1a66185586117eab4d77651 /stress.sh
parentc186dfbdbd43f5b51a67812ad48e1df1eacf131e (diff)
Add a script for stressing the daemon
Change-Id: Ic8c5241339106376daaf91acafca1e4fb0f5f818 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'stress.sh')
-rwxr-xr-xstress.sh76
1 files changed, 76 insertions, 0 deletions
diff --git a/stress.sh b/stress.sh
new file mode 100755
index 00000000..f4a78bbe
--- /dev/null
+++ b/stress.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+ROOT=$(dirname $0)
+
+AFB=$ROOT/build/src/afb-daemon
+CLI=$ROOT/build/src/afb-client-demo
+HELLO=$ROOT/build/bindings/samples/helloWorld.so
+PORT=12345
+TEST=$ROOT/test
+TOKEN=knock-knock-knoc
+OUT=$ROOT/stress-out
+
+rm $OUT*
+
+echo -n launch afb...
+$AFB --session-max=100 --port=$PORT --rootdir=$ROOT --roothttp=$TEST --tracereq=all --token=$TOKEN --ldpaths=/tmp --binding=$HELLO --verbose --verbose --verbose > $OUT.0 2>&1 &
+afbpid=$!
+strace -tt -f -o $OUT-strace.0 -p $afbpid &
+echo done
+
+sleep 3
+
+CMDS='
+hello ping true
+HELLO PING false
+hello pIngNull true
+hello PingBug true
+hello PiNgJsOn {"well":"formed","json":[1,2,3,4.5,true,false,null,"oups"]}
+hello subcall {"api":"hello","verb":"pingjson","args":[{"key1":"value1"}]}
+hello subcall {"api":"hello","verb":"subcall","args":{"api":"hello","verb":"pingjson","args":[{"key1":"value1"}]}}
+hello subcallsync {"api":"hello","verb":"pingjson","args":[{"key1":"value1"}]}
+hello subcallsync {"api":"hello","verb":"subcall","args":{"api":"hello","verb":"pingjson","args":[{"key1":"value1"}]}}
+hello subcall {"api":"hello","verb":"subcallsync","args":{"api":"hello","verb":"pingjson","args":[{"key1":"value1"}]}}
+hello subcallsync {"api":"hello","verb":"subcallsync","args":{"api":"hello","verb":"pingjson","args":[{"key1":"value1"}]}}
+hello eventadd {"tag":"ev1","name":"event-A"}
+hello eventadd {"tag":"ev2","name":"event-B"}
+hello eventpush {"tag":"ev1","data":[1,2,"hello"]}
+hello eventpush {"tag":"ev2","data":{"item":0}}
+hello eventsub {"tag":"ev2"}
+hello eventpush {"tag":"ev1","data":[1,2,"hello"]}
+hello eventpush {"tag":"ev2","data":{"item":0}}
+hello eventsub {"tag":"ev1"}
+hello subcall {"api":"hello","verb":"eventpush","args":{"tag":"ev1","data":[1,2,"hello"]}}
+hello subcall {"api":"hello","verb":"eventpush","args":{"tag":"ev2","data":{"item":0}}}
+hello subcallsync {"api":"hello","verb":"eventpush","args":{"tag":"ev1","data":[1,2,"hello"]}}
+hello subcallsync {"api":"hello","verb":"eventpush","args":{"tag":"ev2","data":{"item":0}}}
+hello eventunsub {"tag":"ev2"}
+hello eventpush {"tag":"ev1","data":[1,2,"hello"]}
+hello eventpush {"tag":"ev2","data":{"item":0}}
+hello eventdel {"tag":"ev1"}
+hello eventpush {"tag":"ev1","data":[1,2,"hello"]}
+hello eventpush {"tag":"ev2","data":{"item":0}}
+'
+
+r() {
+ while :; do echo "$CMDS"; done | while read x; do echo $x; sleep 0.005; done | strace -tt -f -o $OUT-strace.$1 $CLI "localhost:$PORT/api?token=$TOKEN" > $OUT.$1 2>&1 &
+}
+
+echo -n launch clients...
+r 1
+r 2
+r 3
+r 4
+r 5
+r 7
+r 8
+r 9
+r a
+r b
+r c
+echo done
+
+sleep 3
+
+kill $afbpid
+