diff options
author | Thais Siqueira <thais.siqueira@gmail.com> | 2016-08-23 12:26:49 -0300 |
---|---|---|
committer | Thais Siqueira <thais.siqueira@gmail.com> | 2016-08-23 12:26:49 -0300 |
commit | ab218f09fd170484645e10f4ce0b67b1cbeda2bd (patch) | |
tree | a6a70612fec6afaf90c74a55adab4cc2262df97e /service/test | |
parent | 94ce2779a01903688b22783fdef3e42e789c1211 (diff) |
Adds the script that login users concurrently.
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/reactor/concurrent_logins.rb | 37 |
1 files changed, 37 insertions, 0 deletions
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 <x>` +# 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 |