From ab218f09fd170484645e10f4ce0b67b1cbeda2bd Mon Sep 17 00:00:00 2001 From: Thais Siqueira Date: Tue, 23 Aug 2016 12:26:49 -0300 Subject: Adds the script that login users concurrently. --- service/test/reactor/concurrent_logins.rb | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 service/test/reactor/concurrent_logins.rb (limited to 'service/test/reactor') diff --git a/service/test/reactor/concurrent_logins.rb b/service/test/reactor/concurrent_logins.rb new file mode 100644 index 00000000..48b765b3 --- /dev/null +++ b/service/test/reactor/concurrent_logins.rb @@ -0,0 +1,37 @@ +# We use this script to simulate the login of multiple concurrent users, with +# one login per second. +# +# To use it, you need: +# -ruby +# -pre-created users +# +# This can be run with `ruby blocking_spawner ` +# where x is the number of users you want to login. +# +# It was created to measure login times internally on the application with +# varying number of users + + +USER_PATTERN = "loadtest%d" +PASSWORD_PATTERN = "password_%d" +COUNT = ARGV[0].to_i + +def curl_command(index) + username = USER_PATTERN % [index] + password = PASSWORD_PATTERN % [index] + "curl --silent -X POST --data 'username=#{username}&password=#{password}' --cookie 'XSRF-TOKEN: blablabla' --header 'X-Requested-With: XMLHttpRequest' --header 'X-XSRF-TOKEN: blablabla' http://localhost:3333/login" +end + +ts = (1...(1+COUNT)).map do |ix| + t = Thread.new do + `#{curl_command(ix+19)}` + end + sleep 1 + t +end + +ts.each(&:join) + + + +./blocking_spawner.rb 5 -- cgit v1.2.3