Mi Alibasic | 1 Oct 2007 09:57
Picon
Favicon

max size of the python script

Hallo,
 
I'm new with The Grinder 3. My question is what is the maximum size of the python script recorded with the TCPProxy wich can be replyed??
 
 
Thank you,
 
Mirhan

Publiceer JOUW leven online met Windows Live Spaces: weblog, foto, video en muziek! Het is gratis! Het is gratis!
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
grinder-use mailing list
grinder-use@...
https://lists.sourceforge.net/lists/listinfo/grinder-use
Mi Alibasic | 1 Oct 2007 10:06
Picon
Favicon

max size of the python script

Hallo,
 
I'm new with The Grinder 3. My question is what is the maximum size of the python script recorded with the TCPProxy wich can be replyed??
 
 
Thank you,
 
Mirhan

Publiceer JOUW leven online met Windows Live Spaces: weblog, foto, video en muziek! Het is gratis! Het is gratis!
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
grinder-use mailing list
grinder-use@...
https://lists.sourceforge.net/lists/listinfo/grinder-use
Philip Aston | 1 Oct 2007 18:55

Re: max size of the python script

Mi Alibasic wrote:
> I'm new with The Grinder 3. My question is what is the maximum size of 
> the python script recorded with the TCPProxy wich can be replyed??

Jython has a limitation on the maximum size of a function, around 65000 
characters, which it inherits from a Java limit.

This caused problems with HTTP scripts  recorded by earlier versions of 
The Grinder 3, but the new HTTP recording filter (introduced in beta 29) 
splits the script up into many functions, so shouldn't be affected by 
this limit.

- Phil

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc., 
its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual or entity named in this message.
If you are not the intended recipient, and have received this message in error, please immediately return
this by email and then delete it.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Ying Moy | 4 Oct 2007 02:46
Picon
Favicon

How to run more than one script files in sequence

Hi,

I like to create a script file testAll.py to contain
another script files, such as test1.py, test2.py,
test3.py and test4.py. 
I hope I can run testAll.py with grinder to run all
the script files (test1.py, test2.py, test3.py and
test4.py) one by one.
Is it possible?, If yes, could someone tell me how to
do it?

Thanks,
Ying Moy

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
sys | 4 Oct 2007 15:54

Test statistics concurrent modification exception

Hi,

I'm getting ConcurrentModificationException on the statistics map for
large (> ~20) thread counts; at almost every run when the thread count
is 100.

I'm testing on a single host, 1 grinder process, 1 run, 1 script
(below). Grinder version 3.0-beta33. Java version 1.6.0_02, Win32
(Windows XP SP2).

What's the best way to fix this? :)

Best regards,
/Oshadi

Here's the stack (the "Request succeeded" messages are emitted by the
test script):

04.10.07 14:53:56 (thread 3 run 0 test 30): Request succeeded
04.10.07 14:53:56 (thread 7 run 0 test 35): Request succeeded
Exception in thread "Timer-0" java.util.ConcurrentModificationException
        at java.util.TreeMap$PrivateEntryIterator.nextEntry(Unknown
Source)
        at java.util.TreeMap$EntryIterator.next(Unknown Source)
        at java.util.TreeMap$EntryIterator.next(Unknown Source)
        at
net.grinder.statistics.TestStatisticsMap$Iterator.next(TestStatisticsMap.java:390)
        at
net.grinder.statistics.TestStatisticsMap$ForEach.iterate(TestStatisticsMap.java:442)
        at
net.grinder.statistics.TestStatisticsMap.reset(TestStatisticsMap.java:151)
        at
net.grinder.engine.process.GrinderProcess$ReportToConsoleTimerTask.run(GrinderProcess.java:385)
        at java.util.TimerThread.mainLoop(Unknown Source)
        at java.util.TimerThread.run(Unknown Source)
04.10.07 14:53:56 (thread 2 run 0 test 22): Request succeeded
04.10.07 14:53:56 (process 425-6000-0): finished

And here's the script:

from projectname import mk_request
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest
from net.grinder.common import GrinderException

log = grinder.logger.output
stdout = grinder.logger.TERMINAL
logfile = grinder.logger.LOG
fngen = grinder.filenameFactory

HOST = "http://localhost:8080"
SERVICE = "/path/to/servlet/in/TomCat"
REQUEST_NO = 1

#
# Input: a python dictionary and perhaps a URL
# Output: The response from the server, a JSON structure as a string
#
def run_request(json, service=HOST+SERVICE):
    global REQUEST_NO

    testid = "m=%s,c=%s,s=%s,c2=%s" % 
        (json['hdr']['m'], \
	 json['hdr']['c'], \
	 json['hdr']['s'], \
         json['hdr']['c2'])
    thistest = Test(REQUEST_NO, testid)
    log(str(json), logfile)
    httprequest = thistest.wrap(HTTPRequest())
    httpresp = httprequest.POST(service, str(json))
    log(httpresp.getText(), logfile)

    REQUEST_NO += 1
    return httpresp.getText()

def assert_resp(json_str, tocheck):
    if json_str.find(tocheck) == -1:
	return 0
    return 1

#
# run a request, and an assertion on the response too
# returns success==1/failure==0
#
def assert_request(json, check, service=HOST+SERVICE):
    json_resp = run_request(json, service)
    status = assert_resp(json_resp, check)
    if not status:
	log("Request FAILED", logfile)
	log("Request FAILED", stdout)
    else:
	log("Request succeeded", stdout)
    return status

#
# __call__
#
def run_test():
    run_request(mk_request(m='start'))
    assert_request(mk_request(m='buy', \
        p='0000000000003', \
	p2='000000003'), "BUYBUYBUY")
    assert_request(mk_request(m='pay', p='666', 
        p2='000000003', \
    	t='200'), "PAYPAYPAY")

def TestRunner():
    return run_test

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
Philip Aston | 5 Oct 2007 18:17

Re: How to run more than one script files in sequence

Ying Moy wrote:
> I like to create a script file testAll.py to contain
> another script files, such as test1.py, test2.py,
> test3.py and test4.py. 
> I hope I can run testAll.py with grinder to run all
> the script files (test1.py, test2.py, test3.py and
> test4.py) one by one.
> Is it possible?, If yes, could someone tell me how to
> do it?
>   

http://grinder.sourceforge.net/g3/script-gallery.html#sequence

- Phil

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc., 
its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual or entity named in this message.
If you are not the intended recipient, and have received this message in error, please immediately return
this by email and then delete it.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
praveen_m | 6 Oct 2007 13:56

AttributeError

hi all..

   While trying to run the script, am getting the error given below.

 Aborted run due to Jython exception "AttributeError: instance of
'net.grinder.plugin.http.HTTPRequest' has no attribute '__target__'"
whilst invoking test runner
AttributeError: instance of 'net.grinder.plugin.http.HTTPRequest' has no
attribute '__target__'
	File
"D:\grinder-3\bin\.\atech-189c5051f-file-store\current\EMR_CoverSheet_ActiveMedications.py",
line 4029, in page28
	File
"D:\grinder-3\bin\.\atech-189c5051f-file-store\current\EMR_CoverSheet_ActiveMedications.py",
line 4586, in __call__

Please help me in resolving this, if anybody had already encountered with
this.

Praveen

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
Philip Aston | 7 Oct 2007 09:43

Re: Test statistics concurrent modification exception

I've opened bug 1808854 and made a speculative fix 
(http://grinder.svn.sourceforge.net/viewvc/grinder?view=rev&revision=3526).

Please try the attached patch and let me know whether it works for you. 
Just add the jar file to your CLASSPATH before grinder.jar.

Thanks,

- Phil

sys@... wrote:
> Hi,
>
> I'm getting ConcurrentModificationException on the statistics map for
> large (> ~20) thread counts; at almost every run when the thread count
> is 100.
>
> I'm testing on a single host, 1 grinder process, 1 run, 1 script
> (below). Grinder version 3.0-beta33. Java version 1.6.0_02, Win32
> (Windows XP SP2).
>
> What's the best way to fix this? :)
>
> Best regards,
> /Oshadi
>
> Here's the stack (the "Request succeeded" messages are emitted by the
> test script):
>
> 04.10.07 14:53:56 (thread 3 run 0 test 30): Request succeeded
> 04.10.07 14:53:56 (thread 7 run 0 test 35): Request succeeded
> Exception in thread "Timer-0" java.util.ConcurrentModificationException
>         at java.util.TreeMap$PrivateEntryIterator.nextEntry(Unknown
> Source)
>         at java.util.TreeMap$EntryIterator.next(Unknown Source)
>         at java.util.TreeMap$EntryIterator.next(Unknown Source)
>         at
> net.grinder.statistics.TestStatisticsMap$Iterator.next(TestStatisticsMap.java:390)
>         at
> net.grinder.statistics.TestStatisticsMap$ForEach.iterate(TestStatisticsMap.java:442)
>         at
> net.grinder.statistics.TestStatisticsMap.reset(TestStatisticsMap.java:151)
>         at
> net.grinder.engine.process.GrinderProcess$ReportToConsoleTimerTask.run(GrinderProcess.java:385)
>         at java.util.TimerThread.mainLoop(Unknown Source)
>         at java.util.TimerThread.run(Unknown Source)
> 04.10.07 14:53:56 (thread 2 run 0 test 22): Request succeeded
> 04.10.07 14:53:56 (process 425-6000-0): finished
>
>
> And here's the script:
>
> from projectname import mk_request
> from net.grinder.script.Grinder import grinder
> from net.grinder.script import Test
> from net.grinder.plugin.http import HTTPRequest
> from net.grinder.common import GrinderException
>
> log = grinder.logger.output
> stdout = grinder.logger.TERMINAL
> logfile = grinder.logger.LOG
> fngen = grinder.filenameFactory
>
> HOST = "http://localhost:8080"
> SERVICE = "/path/to/servlet/in/TomCat"
> REQUEST_NO = 1
>
> #
> # Input: a python dictionary and perhaps a URL
> # Output: The response from the server, a JSON structure as a string
> #
> def run_request(json, service=HOST+SERVICE):
>     global REQUEST_NO
>
>     testid = "m=%s,c=%s,s=%s,c2=%s" % 
>         (json['hdr']['m'], \
> 	 json['hdr']['c'], \
> 	 json['hdr']['s'], \
>          json['hdr']['c2'])
>     thistest = Test(REQUEST_NO, testid)
>     log(str(json), logfile)
>     httprequest = thistest.wrap(HTTPRequest())
>     httpresp = httprequest.POST(service, str(json))
>     log(httpresp.getText(), logfile)
>
>     REQUEST_NO += 1
>     return httpresp.getText()
>
>
> def assert_resp(json_str, tocheck):
>     if json_str.find(tocheck) == -1:
> 	return 0
>     return 1
>
> #
> # run a request, and an assertion on the response too
> # returns success==1/failure==0
> #
> def assert_request(json, check, service=HOST+SERVICE):
>     json_resp = run_request(json, service)
>     status = assert_resp(json_resp, check)
>     if not status:
> 	log("Request FAILED", logfile)
> 	log("Request FAILED", stdout)
>     else:
> 	log("Request succeeded", stdout)
>     return status
>
> #
> # __call__
> #
> def run_test():
>     run_request(mk_request(m='start'))
>     assert_request(mk_request(m='buy', \
>         p='0000000000003', \
> 	p2='000000003'), "BUYBUYBUY")
>     assert_request(mk_request(m='pay', p='666', 
>         p2='000000003', \
>     	t='200'), "PAYPAYPAY")
>
> def TestRunner():
>     return run_test
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> grinder-use mailing list
> grinder-use@...
> https://lists.sourceforge.net/lists/listinfo/grinder-use
>   

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc., 
its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual or entity named in this message.
If you are not the intended recipient, and have received this message in error, please immediately return
this by email and then delete it.
Attachment (patch1808854.jar): application/x-java-archive, 12 KiB
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
grinder-use mailing list
grinder-use@...
https://lists.sourceforge.net/lists/listinfo/grinder-use
Ishan Oshadi Jayawardene | 7 Oct 2007 13:32

Re: Test statistics concurrent modification exception

Tried it

10 runs of 025 threads each
10 runs of 100 threads each
05 runs of 300 threads each

No errors from the agent :)

Thank you!

On the first round of using the console, it takes a long time for the 
agent start/reset/stop buttons to be enabled... But on subsequent runs 
there's no excessive delays.

My classpath is

c:\cp\patch1808854.jar;.;C:\jython2.2\jython.jar;C:\the_grinder\grinder-3.0-beta33\lib\grinder.jar 

Philip Aston wrote:
> I've opened bug 1808854 and made a speculative fix 
> (http://grinder.svn.sourceforge.net/viewvc/grinder?view=rev&revision=3526).
>
> Please try the attached patch and let me know whether it works for you. 
> Just add the jar file to your CLASSPATH before grinder.jar.
>
> Thanks,
>
> - Phil
>
>
> sys@... wrote:
>   
>> Hi,
>>
>> I'm getting ConcurrentModificationException on the statistics map for
>> large (> ~20) thread counts; at almost every run when the thread count
>> is 100.
>>
>> I'm testing on a single host, 1 grinder process, 1 run, 1 script
>> (below). Grinder version 3.0-beta33. Java version 1.6.0_02, Win32
>> (Windows XP SP2).
>>
>> What's the best way to fix this? :)
>>
>> Best regards,
>> /Oshadi
>>
>> Here's the stack (the "Request succeeded" messages are emitted by the
>> test script):
>>
>> 04.10.07 14:53:56 (thread 3 run 0 test 30): Request succeeded
>> 04.10.07 14:53:56 (thread 7 run 0 test 35): Request succeeded
>> Exception in thread "Timer-0" java.util.ConcurrentModificationException
>>         at java.util.TreeMap$PrivateEntryIterator.nextEntry(Unknown
>> Source)
>>         at java.util.TreeMap$EntryIterator.next(Unknown Source)
>>         at java.util.TreeMap$EntryIterator.next(Unknown Source)
>>         at
>> net.grinder.statistics.TestStatisticsMap$Iterator.next(TestStatisticsMap.java:390)
>>         at
>> net.grinder.statistics.TestStatisticsMap$ForEach.iterate(TestStatisticsMap.java:442)
>>         at
>> net.grinder.statistics.TestStatisticsMap.reset(TestStatisticsMap.java:151)
>>         at
>> net.grinder.engine.process.GrinderProcess$ReportToConsoleTimerTask.run(GrinderProcess.java:385)
>>         at java.util.TimerThread.mainLoop(Unknown Source)
>>         at java.util.TimerThread.run(Unknown Source)
>> 04.10.07 14:53:56 (thread 2 run 0 test 22): Request succeeded
>> 04.10.07 14:53:56 (process 425-6000-0): finished
>>
>>
>> And here's the script:
>>
>> from projectname import mk_request
>> from net.grinder.script.Grinder import grinder
>> from net.grinder.script import Test
>> from net.grinder.plugin.http import HTTPRequest
>> from net.grinder.common import GrinderException
>>
>> log = grinder.logger.output
>> stdout = grinder.logger.TERMINAL
>> logfile = grinder.logger.LOG
>> fngen = grinder.filenameFactory
>>
>> HOST = "http://localhost:8080"
>> SERVICE = "/path/to/servlet/in/TomCat"
>> REQUEST_NO = 1
>>
>> #
>> # Input: a python dictionary and perhaps a URL
>> # Output: The response from the server, a JSON structure as a string
>> #
>> def run_request(json, service=HOST+SERVICE):
>>     global REQUEST_NO
>>
>>     testid = "m=%s,c=%s,s=%s,c2=%s" % 
>>         (json['hdr']['m'], \
>> 	 json['hdr']['c'], \
>> 	 json['hdr']['s'], \
>>          json['hdr']['c2'])
>>     thistest = Test(REQUEST_NO, testid)
>>     log(str(json), logfile)
>>     httprequest = thistest.wrap(HTTPRequest())
>>     httpresp = httprequest.POST(service, str(json))
>>     log(httpresp.getText(), logfile)
>>
>>     REQUEST_NO += 1
>>     return httpresp.getText()
>>
>>
>> def assert_resp(json_str, tocheck):
>>     if json_str.find(tocheck) == -1:
>> 	return 0
>>     return 1
>>
>> #
>> # run a request, and an assertion on the response too
>> # returns success==1/failure==0
>> #
>> def assert_request(json, check, service=HOST+SERVICE):
>>     json_resp = run_request(json, service)
>>     status = assert_resp(json_resp, check)
>>     if not status:
>> 	log("Request FAILED", logfile)
>> 	log("Request FAILED", stdout)
>>     else:
>> 	log("Request succeeded", stdout)
>>     return status
>>
>> #
>> # __call__
>> #
>> def run_test():
>>     run_request(mk_request(m='start'))
>>     assert_request(mk_request(m='buy', \
>>         p='0000000000003', \
>> 	p2='000000003'), "BUYBUYBUY")
>>     assert_request(mk_request(m='pay', p='666', 
>>         p2='000000003', \
>>     	t='200'), "PAYPAYPAY")
>>
>> def TestRunner():
>>     return run_test
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc.
>> Still grepping through log files to find problems?  Stop.
>> Now Search log events and configuration files using AJAX and a browser.
>> Download your FREE copy of Splunk now >> http://get.splunk.com/
>> _______________________________________________
>> grinder-use mailing list
>> grinder-use@...
>> https://lists.sourceforge.net/lists/listinfo/grinder-use
>>   
>>     
>
>
> Notice:  This email message, together with any attachments, may contain information  of  BEA Systems, 
Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted 
and/or legally privileged, and is intended solely for the use of the individual or entity named in this
message. If you are not the intended recipient, and have received this message in error, please
immediately return this by email and then delete it.
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> ------------------------------------------------------------------------
>
> _______________________________________________
> grinder-use mailing list
> grinder-use@...
> https://lists.sourceforge.net/lists/listinfo/grinder-use
>   

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
Philip Aston | 7 Oct 2007 17:54

Re: Test statistics concurrent modification exception

Good stuff. The fix is in svn, and will be in the next beta.

Thanks for the bug report, and the testing.

- Phil

Ishan Oshadi Jayawardene wrote:
> Tried it
>
> 10 runs of 025 threads each
> 10 runs of 100 threads each
> 05 runs of 300 threads each
>
> No errors from the agent :)
>
> Thank you!
>
> On the first round of using the console, it takes a long time for the 
> agent start/reset/stop buttons to be enabled... But on subsequent runs 
> there's no excessive delays.
>
> My classpath is 
>
c:\cp\patch1808854.jar;.;C:\jython2.2\jython.jar;C:\the_grinder\grinder-3.0-beta33\lib\grinder.jar 
>
>
> Philip Aston wrote:
>   
>> I've opened bug 1808854 and made a speculative fix 
>> (http://grinder.svn.sourceforge.net/viewvc/grinder?view=rev&revision=3526).
>>
>> Please try the attached patch and let me know whether it works for you. 
>> Just add the jar file to your CLASSPATH before grinder.jar.
>>
>> Thanks,
>>
>> - Phil
>>
>>
>> sys@... wrote:
>>   
>>     
>>> Hi,
>>>
>>> I'm getting ConcurrentModificationException on the statistics map for
>>> large (> ~20) thread counts; at almost every run when the thread count
>>> is 100.
>>>
>>> I'm testing on a single host, 1 grinder process, 1 run, 1 script
>>> (below). Grinder version 3.0-beta33. Java version 1.6.0_02, Win32
>>> (Windows XP SP2).
>>>
>>> What's the best way to fix this? :)
>>>
>>> Best regards,
>>> /Oshadi
>>>
>>> Here's the stack (the "Request succeeded" messages are emitted by the
>>> test script):
>>>
>>> 04.10.07 14:53:56 (thread 3 run 0 test 30): Request succeeded
>>> 04.10.07 14:53:56 (thread 7 run 0 test 35): Request succeeded
>>> Exception in thread "Timer-0" java.util.ConcurrentModificationException
>>>         at java.util.TreeMap$PrivateEntryIterator.nextEntry(Unknown
>>> Source)
>>>         at java.util.TreeMap$EntryIterator.next(Unknown Source)
>>>         at java.util.TreeMap$EntryIterator.next(Unknown Source)
>>>         at
>>> net.grinder.statistics.TestStatisticsMap$Iterator.next(TestStatisticsMap.java:390)
>>>         at
>>> net.grinder.statistics.TestStatisticsMap$ForEach.iterate(TestStatisticsMap.java:442)
>>>         at
>>> net.grinder.statistics.TestStatisticsMap.reset(TestStatisticsMap.java:151)
>>>         at
>>> net.grinder.engine.process.GrinderProcess$ReportToConsoleTimerTask.run(GrinderProcess.java:385)
>>>         at java.util.TimerThread.mainLoop(Unknown Source)
>>>         at java.util.TimerThread.run(Unknown Source)
>>> 04.10.07 14:53:56 (thread 2 run 0 test 22): Request succeeded
>>> 04.10.07 14:53:56 (process 425-6000-0): finished
>>>
>>>
>>> And here's the script:
>>>
>>> from projectname import mk_request
>>> from net.grinder.script.Grinder import grinder
>>> from net.grinder.script import Test
>>> from net.grinder.plugin.http import HTTPRequest
>>> from net.grinder.common import GrinderException
>>>
>>> log = grinder.logger.output
>>> stdout = grinder.logger.TERMINAL
>>> logfile = grinder.logger.LOG
>>> fngen = grinder.filenameFactory
>>>
>>> HOST = "http://localhost:8080"
>>> SERVICE = "/path/to/servlet/in/TomCat"
>>> REQUEST_NO = 1
>>>
>>> #
>>> # Input: a python dictionary and perhaps a URL
>>> # Output: The response from the server, a JSON structure as a string
>>> #
>>> def run_request(json, service=HOST+SERVICE):
>>>     global REQUEST_NO
>>>
>>>     testid = "m=%s,c=%s,s=%s,c2=%s" % 
>>>         (json['hdr']['m'], \
>>> 	 json['hdr']['c'], \
>>> 	 json['hdr']['s'], \
>>>          json['hdr']['c2'])
>>>     thistest = Test(REQUEST_NO, testid)
>>>     log(str(json), logfile)
>>>     httprequest = thistest.wrap(HTTPRequest())
>>>     httpresp = httprequest.POST(service, str(json))
>>>     log(httpresp.getText(), logfile)
>>>
>>>     REQUEST_NO += 1
>>>     return httpresp.getText()
>>>
>>>
>>> def assert_resp(json_str, tocheck):
>>>     if json_str.find(tocheck) == -1:
>>> 	return 0
>>>     return 1
>>>
>>> #
>>> # run a request, and an assertion on the response too
>>> # returns success==1/failure==0
>>> #
>>> def assert_request(json, check, service=HOST+SERVICE):
>>>     json_resp = run_request(json, service)
>>>     status = assert_resp(json_resp, check)
>>>     if not status:
>>> 	log("Request FAILED", logfile)
>>> 	log("Request FAILED", stdout)
>>>     else:
>>> 	log("Request succeeded", stdout)
>>>     return status
>>>
>>> #
>>> # __call__
>>> #
>>> def run_test():
>>>     run_request(mk_request(m='start'))
>>>     assert_request(mk_request(m='buy', \
>>>         p='0000000000003', \
>>> 	p2='000000003'), "BUYBUYBUY")
>>>     assert_request(mk_request(m='pay', p='666', 
>>>         p2='000000003', \
>>>     	t='200'), "PAYPAYPAY")
>>>
>>> def TestRunner():
>>>     return run_test
>>>
>>>
>>> -------------------------------------------------------------------------
>>> This SF.net email is sponsored by: Splunk Inc.
>>> Still grepping through log files to find problems?  Stop.
>>> Now Search log events and configuration files using AJAX and a browser.
>>> Download your FREE copy of Splunk now >> http://get.splunk.com/
>>> _______________________________________________
>>> grinder-use mailing list
>>> grinder-use@...
>>> https://lists.sourceforge.net/lists/listinfo/grinder-use
>>>   
>>>     

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc., 
its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual or entity named in this message.
If you are not the intended recipient, and have received this message in error, please immediately return
this by email and then delete it.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

Gmane