Skip to content

Commit

Permalink
Adding staff create load test
Browse files Browse the repository at this point in the history
  • Loading branch information
somayjain committed Aug 27, 2013
1 parent 56e0709 commit 78127ea
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 0 deletions.
22 changes: 22 additions & 0 deletions modules/tests/load/helpers/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<clients>
<!-- Client side setup -->
<client host="localhost" use_controller_vm="true" maxusers="200000"/>
</clients>

<servers>
<!-- Server side setup -->
<server host="127.0.0.1" port="8000" type="tcp"></server>
</servers>

<load>
<!-- several arrival phases can be set: for each phase, you can set
the mean inter-arrival time between new clients and the phase
duration -->
<arrivalphase phase="1" duration="5" unit="minute">
<users maxnumber="50" interarrival="5" unit="second"></users>
</arrivalphase>

<arrivalphase phase="2" duration="10" unit="minute">
<users maxnumber="100" interarrival="3" unit="second"></users>
</arrivalphase>
</load>
26 changes: 26 additions & 0 deletions modules/tests/load/helpers/login.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<transaction name="login_page">
<!-- Login page -->
<request>
<!-- Get the form-key from the login form -->
<dyn_variable name="_formkey" xpath="//form//div//input[@name='_formkey']/@value" />
<http url='/eden/default/user/login' version='1.1' method='GET'></http>
</request>

<!-- The requests on the login form -->
<request><http url='/eden/static/themes/IFRC/eden.min.css' version='1.1' method='GET'></http></request>
<request><http url='/eden/static/scripts/jquery-1.10.2.min.js' version='1.1' method='GET'></http></request>
<request><http url='/eden/static/scripts/jquery-migrate-1.2.1.min.js' version='1.1' method='GET'></http></request>
<request><http url='/eden/static/scripts/S3/S3.min.js' version='1.1' method='GET'></http></request>
<request><http url='/eden/static/themes/IFRC/js/nav.js' version='1.1' method='GET'></http></request>

</transaction>

<transaction name="login_query">
<!-- Submit the form -->
<request subst="true">
<http url='/eden/default/user/login?_next=%2Feden%2Fdefault%2Findex' version='1.1' contents="_formname=login&amp;_formkey=%%__formkey%%&amp;email=admin@example.com&amp;password=testing&amp;_next=/eden/default/index&amp;_utc_offset=-330" content_type='application/x-www-form-urlencoded' method='POST'></http>
</request>

<request><http url='/eden/default/index' version='1.1' method='GET'></http></request>

</transaction>
13 changes: 13 additions & 0 deletions modules/tests/load/scripts/create_staff_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import csv
import copy
fp = open('staff.csv', 'wb')
with fp as csvfiles:
writer = csv.writer(csvfiles, delimiter=',')
baseline = ['34', '1', '', 'FirstName', 'MiddleName', 'LastName', '2-Jan-1987',
'1', 'FirstName.LastName', '1234567890', '', '', '01-Jan-2012', '31-Dec-2012']
for i in range(10000):
templine = copy.deepcopy(baseline)
templine[3] = baseline[3] + str(i)
templine[8] = baseline[8] + str(i) + "@example.com"
writer.writerow(templine)
fp.close()
77 changes: 77 additions & 0 deletions modules/tests/load/staff_create.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0"?>
<!--
Instructions on how to run the test -
http://eden.sahanafoundation.org/wiki/BluePrint/Testing/TestSuite#Runningthetests
This test depends upon scripts/create_staff_data.py for its data.
Run this script from the current directory if staff.csv is not present.
-->
<!-- The filename below is specific to the system the test is run on. -->
<!DOCTYPE tsung SYSTEM "/opt/tsung-1.4.2/share/tsung/tsung-1.0.dtd" [
<!ENTITY config SYSTEM "helpers/config.xml">
<!ENTITY login_page SYSTEM "helpers/login.xml">
]>

<tsung loglevel="debug" version="1.0">

<!-- Load the configuration -->
&config;

<options>
<option name="file_server" id='newstaff' value="staff.csv"/>
<option type="ts_http" name="user_agent">
<user_agent probability="80">Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Galeon/1.3.21</user_agent>
<user_agent probability="20">Mozilla/5.0 (Windows; U; Windows NT 5.2; fr-FR; rv:1.7.8) Gecko/20050511 Firefox/1.0.4</user_agent>
</option>
</options>

<sessions>
<!-- start a session for a http user. the probability is the
frequency of this type os session. The sum of all session's
probabilities must be 100 -->
<session name='staff_create' probability='100' type='ts_http'>

&login_page;

<request>
<!-- Get the form-key from the login form -->
<dyn_variable name="_formkey" xpath="//form//div[1]//input[@name='_formkey']/@value" />
<dyn_variable name="_formname" xpath="//form//div[1]//input[@name='_formname']/@value" />
<http url='/eden/hrm/staff/create' version='1.1' method='GET'></http>
</request>


<transaction name="create_query">
<!-- Select a random string to be fed in as the query -->
<setdynvars sourcetype="file" fileid="newstaff" delimiter="," order="iter">
<var name="organisation_id"/>
<var name="site_id"/>
<var name="person_id"/>
<var name="first_name"/>
<var name="middle_name"/>
<var name="last_name"/>
<var name="date_of_birth"/>
<var name="gender"/>
<var name="email"/>
<var name="mobile_phone"/>
<var name="job_title_id"/>
<var name="department_id"/>
<var name="start_date"/>
<var name="end_date"/>
</setdynvars>

<!-- Submit Create query -->
<request subst="true">
<http url='/eden/hrm/staff/create' version='1.1' content_type='application/x-www-form-urlencoded' method='POST' contents='organisation_id=%%_organisation_id%%&amp;site_id=%%_site_id%%&amp;person_id=%%_person_id%%&amp;first_name=%%_first_name%%&amp;middle_name=%%_middle_name%%&amp;last_name=%%_last_name%%&amp;date_of_birth=%%_date_of_birth%%&amp;gender=%%_gender%%&amp;email=%%_email%%&amp;mobile_phone=%%_mobile_phone%%&amp;job_title_id=%%_job_title_id%%&amp;department_id=%%_department_id%%&amp;start_date=%%_start_date%%&amp;end_date=%%_end_date%%'></http>
</request>
</transaction>

<transaction name="logout">
<!-- Logout -->
<request><http url='http://127.0.0.1:8000/eden/default/user/logout' version='1.1' method='GET'></http></request>
<request><http url='/eden/default/index' version='1.1' method='GET'></http></request>
</transaction>
</session>
</sessions>
</tsung>

0 comments on commit 78127ea

Please sign in to comment.