Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
494 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
# | ||
# Sample grinder.properties | ||
# | ||
# | ||
# The properties can be specified in three ways. | ||
# - In the console. A properties file in the distribution directory | ||
# can be selected in the console. | ||
# - As a Java system property in the command line used to start the | ||
# agent. (e.g. java -Dgrinder.threads=20 net.grinder.Grinder). | ||
# - In an agent properties file. A local properties file named | ||
# "grinder.properties" can be placed in the working directory of | ||
# each agent, or a different file name passed as an agent command | ||
# line argument. | ||
# | ||
# Properties present in a console selected file take precedence over | ||
# agent command line properties, which in turn override those in | ||
# an agent properties file. | ||
# | ||
# Any line which starts with a ; (semi-colon) or a # (hash) is a | ||
# comment and is ignored. In this example we will use a # for | ||
# commentary and a ; for parts of the config file that you may wish to | ||
# enable | ||
# | ||
# Please refer to | ||
# http://net.grinder.sourceforge.net/g3/properties.html for further | ||
# documentation. | ||
|
||
|
||
# | ||
# Commonly used properties | ||
# | ||
|
||
# The file name of the script to run. | ||
# | ||
# Relative paths are evaluated from the directory containing the | ||
# properties file. The default is "grinder.py". | ||
grinder.script = simpleeval_factor.py | ||
|
||
# The number of worker processes each agent should start. The default | ||
# is 1. | ||
grinder.processes = 1 | ||
|
||
# The number of worker threads each worker process should start. The | ||
# default is 1. | ||
grinder.threads = 10 | ||
|
||
# The number of runs each worker process will perform. When using the | ||
# console this is usually set to 0, meaning "run until the console | ||
# sneds a stop or reset signal". The default is 1. | ||
grinder.runs = 0 | ||
|
||
# The IP address or host name that the agent and worker processes use | ||
# to contact the console. The default is all the network interfaces | ||
# of the local machine. | ||
; grinder.consoleHost = consolehost | ||
|
||
# The IP port that the agent and worker processes use to contact the | ||
# console. Defaults to 6372. | ||
; grinder.consolePort | ||
|
||
|
||
|
||
# | ||
# Less frequently used properties | ||
# | ||
|
||
|
||
### Logging ### | ||
|
||
# The directory in which worker process logs should be created. If not | ||
# specified, the agent's working directory is used. | ||
grinder.logDirectory = log | ||
|
||
# The number of archived logs from previous runs that should be kept. | ||
# The default is 1. | ||
grinder.numberOfOldLogs = 2 | ||
|
||
# Overrides the "host" string used in log filenames and logs. The | ||
# default is the host name of the machine running the agent. | ||
; grinder.hostID = myagent | ||
|
||
# Set to false to disable the logging of output and error steams for | ||
# worker processes. You might want to use this to reduce the overhead | ||
# of running a client thread. The default is true. | ||
grinder.logProcessStreams = false | ||
|
||
|
||
### Script sleep time #### | ||
|
||
# The maximum time in milliseconds that each thread waits before | ||
# starting. Unlike the sleep times specified in scripts, this is | ||
# varied according to a flat random distribution. The actual sleep | ||
# time will be a random value between 0 and the specified value. | ||
# Affected by grinder.sleepTimeFactor, but not | ||
# grinder.sleepTimeVariation. The default is 0ms. | ||
; grinder.initialSleepTime=500 | ||
|
||
# Apply a factor to all the sleep times you've specified, either | ||
# through a property of in a script. Setting this to 0.1 would run the | ||
# script ten times as fast. The default is 1. | ||
; grinder.sleepTimeFactor=0.01 | ||
|
||
# The Grinder varies the sleep times specified in scripts according to | ||
# a Normal distribution. This property specifies a fractional range | ||
# within which nearly all (99.75%) of the times will lie. E.g., if the | ||
# sleep time is specified as 1000 and the sleepTimeVariation is set to | ||
# 0.1, then 99.75% of the actual sleep times will be between 900 and | ||
# 1100 milliseconds. The default is 0.2. | ||
; grinder.sleepTimeVariation=0.005 | ||
|
||
|
||
### Worker process control ### | ||
|
||
# If set, the agent will ramp up the number of worker processes, | ||
# starting the number specified every | ||
# grinder.processesIncrementInterval milliseconds. The upper limit is | ||
# set by grinder.processes. The default is to start all worker | ||
# processes together. | ||
; grinder.processIncrement = 1 | ||
|
||
# Used in conjunction with grinder.processIncrement, this property | ||
# sets the interval in milliseconds at which the agent starts new | ||
# worker processes. The value is in milliseconds. The default is 60000 | ||
# ms. | ||
; grinder.processIncrementInterval = 10000 | ||
|
||
# Used in conjunction with grinder.processIncrement, this property | ||
# sets the initial number of worker processes to start. The default is | ||
# the value of grinder.processIncrement. | ||
; process.initialProcesses = 1 | ||
|
||
# The maximum length of time in milliseconds that each worker process | ||
# should run for. grinder.duration can be specified in conjunction | ||
# with grinder.runs, in which case the worker processes will terminate | ||
# if either the duration time or the number of runs is exceeded. The | ||
# default is to run forever. | ||
; grinder.duration = 60000 | ||
|
||
# If set to true, the agent process spawns engines in threads rather | ||
# than processes, using special class loaders to isolate the engines. | ||
# This allows the engine to be easily run in a debugger. This is | ||
# primarily a tool for debugging The Grinder engine, but it might also | ||
# be useful to advanced users. The default is false. | ||
; grinder.debug.singleprocess = true | ||
|
||
# If set to true, the new DCR instrumentation engine will be used. The | ||
# new engine will always be used if Jython 2.1/2.2 is not found. | ||
; grinder.dcrinstrumentation = false | ||
|
||
|
||
### Java ### | ||
|
||
# Use an alternate JVM for worker processes. The default is "java" so | ||
# you do not need to specify this if java is in your PATH. | ||
; grinder.jvm = /opt/jrockit/jrockit-R27.5.0-jdk1.5.0_14/bin/java | ||
|
||
# Use to adjust the classpath used for the worker process JVMs. | ||
# Anything specified here will be prepended to the classpath used to | ||
# start the Grinder processes. | ||
; grinder.jvm.classpath = /tmp/myjar.jar | ||
|
||
# Additional arguments to worker process JVMs. | ||
grinder.jvm.arguments = -Dpython.home=/usr/share/jython | ||
|
||
|
||
### Console communications ### | ||
|
||
# (See above for console address properties). | ||
|
||
# If you are not using the console, and don't want the agent to try to | ||
# contact it, set grinder.useConsole = false. The default is true. | ||
; grinder.useConsole = false | ||
|
||
# The period at which each process sends updates to the console. This | ||
# also controls the frequency at which the data files are flushed. | ||
# The default is 500 ms. | ||
; grinder.reportToConsole.interval = 100 | ||
|
||
|
||
### Statistics ### | ||
|
||
# Set to false to disable reporting of timing information to the | ||
# console; other statistics are still reported. See | ||
# http://grinder.sourceforge.net/faq.html#timing for why you might | ||
# want to do this. The default is true. | ||
; grinder.reportTimesToConsole = false | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from net.grinder.script.Grinder import grinder | ||
from net.grinder.script import Test | ||
from net.grinder.plugin.http import HTTPRequest | ||
from HTTPClient import NVPair | ||
from java.util import Random | ||
|
||
protectedResourceTest = Test(1, "Request home") | ||
authenticationTest = Test(2, "POST to login") | ||
newCellTest = Test(3, "Make a new Cell") | ||
evaluationTest = Test(4, "Evaluate 2 + 2") | ||
updateTest = Test(5, "Get 4") | ||
deleteCellTest = Test(6, "Delete Cell") | ||
|
||
class TestRunner: | ||
def __call__(self): | ||
worksheet = '1' | ||
request = protectedResourceTest.wrap( | ||
HTTPRequest(url="http://localhost:8000/")) | ||
|
||
result = request.GET() | ||
result = maybeAuthenticate(result) | ||
result = request.GET('/home/admin/%s/' % worksheet) | ||
#print 'test sheet seen: ', (result.text.find('test') != -1) | ||
#print result.text | ||
|
||
base_url = 'http://localhost:8000/home/admin/%s' % worksheet | ||
request = newCellTest.wrap(HTTPRequest(url=base_url + "/new_cell_after")) | ||
result = request.POST((NVPair("id","0"),)) | ||
new_cell = result.text.split()[0].rstrip('___S_A_G_E___') | ||
#print 'new cell number', new_cell | ||
|
||
request = evaluationTest.wrap(HTTPRequest(url=base_url + "/eval")) | ||
random = Random() | ||
a, b = random.nextInt(10**1), random.nextInt(10**1) | ||
# print 'random test',a,b, | ||
evalData = ( NVPair("id", new_cell), | ||
NVPair("input", "%s * %s"% (a,b)), | ||
NVPair("newcell", "0"),) | ||
result = request.POST(evalData) | ||
#print 'input', result.text | ||
|
||
count = 0 | ||
while (True): | ||
#grinder.sleep(5000) | ||
request = updateTest.wrap(HTTPRequest(url=base_url + "/cell_update")) | ||
getData = ( NVPair("id", new_cell),) | ||
result = request.POST(getData) | ||
#print 'full result:', result.text | ||
count += 1 | ||
if result.text.find('pre') != -1: | ||
#print 'full result:', result.text | ||
print 'wait',count,'test',a,'*',b,'=', strip_answer(result.text) | ||
break | ||
|
||
request = deleteCellTest.wrap(HTTPRequest(url=base_url + "/delete_cell")) | ||
getData = ( NVPair("id", new_cell),) | ||
result = request.POST(getData) | ||
|
||
# Function that checks the passed HTTPResult to see whether | ||
# authentication is necessary. If it is, perform the authentication | ||
# and record performance information against Test 2. | ||
def maybeAuthenticate(lastResult): | ||
if lastResult.statusCode == 401 \ | ||
or lastResult.text.find("password") != -1: | ||
|
||
#print "Challenged, authenticating" | ||
|
||
authenticationFormData = ( NVPair("email", "admin"), | ||
NVPair("password", "test"),) | ||
|
||
request = authenticationTest.wrap( | ||
HTTPRequest(url="%s/login" % lastResult.originalURI)) | ||
|
||
return request.POST(authenticationFormData) | ||
|
||
def strip_answer(text): | ||
#<pre class="shrunk">532962756677</pre> | ||
st = text.find('<pre') | ||
end = text.find('</pre>') | ||
return text[st + 20 : end] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
for i in {1..50} | ||
do | ||
curl -d username=test$i localhost:8000/adduser | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
for i in {1..50} | ||
do | ||
curl localhost:8000/new_worksheet | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
GRINDERPATH=/Users/rado/grinder-3.4 | ||
GRINDERPROPERTIES=/home/Users/grinder-3.4/sage-grinder/grinder/grinder.properties | ||
CLASSPATH=$GRINDERPATH/lib/grinder.jar:$CLASSPATH | ||
export CLASSPATH GRINDERPROPERTIES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from net.grinder.script.Grinder import grinder | ||
from net.grinder.script import Test | ||
from net.grinder.plugin.http import HTTPRequest | ||
from HTTPClient import NVPair | ||
from java.util import Random | ||
|
||
newCellTest = Test(1, "Make a new Cell") | ||
evaluationTest = Test(2, "Evaluate") | ||
updateTest = Test(3, "Poll until evaluated") | ||
deleteCellTest = Test(4, "Delete Cell") | ||
|
||
class TestRunner: | ||
def __call__(self): | ||
sheets = 10 | ||
random = Random() | ||
worksheet = str(40 + random.nextInt(sheets)) | ||
|
||
base_url = 'http://localhost:8000/home/admin/%s' % worksheet | ||
request = newCellTest.wrap(HTTPRequest(url=base_url + "/new_cell_after")) | ||
result = request.POST((NVPair("id","0"),)) | ||
new_cell = result.text.split()[0].rstrip('___S_A_G_E___') | ||
|
||
request = evaluationTest.wrap(HTTPRequest(url=base_url + "/eval")) | ||
a, b = random.nextInt(10**1), random.nextInt(10**1) | ||
evalData = ( NVPair("id", new_cell), | ||
NVPair("input", "%s * %s"% (a,b)), | ||
NVPair("newcell", "0"),) | ||
result = request.POST(evalData) | ||
|
||
count = 0 | ||
while (True): | ||
request = updateTest.wrap(HTTPRequest(url=base_url + "/cell_update")) | ||
getData = ( NVPair("id", new_cell),) | ||
result = request.POST(getData) | ||
count += 1 | ||
if result.text.find('pre') != -1: | ||
print 'wait',count,'test',a,'*',b,'=', strip_answer(result.text) | ||
break | ||
|
||
request = deleteCellTest.wrap(HTTPRequest(url=base_url + "/delete_cell")) | ||
getData = ( NVPair("id", new_cell),) | ||
result = request.POST(getData) | ||
|
||
def strip_answer(text): | ||
#<pre class="shrunk">532962756677</pre> | ||
st = text.find('<pre') | ||
end = text.find('</pre>') | ||
return text[st + 20 : end] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from net.grinder.script.Grinder import grinder | ||
from net.grinder.script import Test | ||
from net.grinder.plugin.http import HTTPRequest | ||
from HTTPClient import NVPair | ||
from java.util import Random | ||
|
||
newCellTest = Test(1, "Make a new Cell") | ||
evaluationTest = Test(2, "Evaluate") | ||
updateTest = Test(3, "Poll until evaluated") | ||
deleteCellTest = Test(4, "Delete Cell") | ||
|
||
class TestRunner: | ||
def __call__(self): | ||
sheets = 10 | ||
random = Random() | ||
worksheet = str(40 + random.nextInt(sheets)) | ||
|
||
base_url = 'http://localhost:8000/home/admin/%s' % worksheet | ||
request = newCellTest.wrap(HTTPRequest(url=base_url + "/new_cell_after")) | ||
result = request.POST((NVPair("id","0"),)) | ||
new_cell = result.text.split()[0].rstrip('___S_A_G_E___') | ||
|
||
request = evaluationTest.wrap(HTTPRequest(url=base_url + "/eval")) | ||
a = random.nextInt(2**30) | ||
b = random.nextInt(2**30) | ||
evalData = ( NVPair("id", new_cell), | ||
NVPair("input", "factor(%s%s)"% (a,b)), | ||
NVPair("newcell", "0"),) | ||
result = request.POST(evalData) | ||
|
||
count = 0 | ||
while (True): | ||
request = updateTest.wrap(HTTPRequest(url=base_url + "/cell_update")) | ||
getData = ( NVPair("id", new_cell),) | ||
result = request.POST(getData) | ||
count += 1 | ||
if result.text.find('pre') != -1: | ||
print 'wait %s test factor %s%s = %s' % (count, a, b, strip_answer(result.text)) | ||
break | ||
|
||
request = deleteCellTest.wrap(HTTPRequest(url=base_url + "/delete_cell")) | ||
getData = ( NVPair("id", new_cell),) | ||
result = request.POST(getData) | ||
|
||
def strip_answer(text): | ||
#<pre class="shrunk">532962756677</pre> | ||
st = text.find('<pre') | ||
end = text.find('</pre>') | ||
return text[st + 20 : end] |
Oops, something went wrong.