Re: The Grinder - What is 'Insert Command' in TCPProxy Console

Ravi Kumar Maddi <[email protected]> Wed, 30 Jul 2014 10:48:32 +0530
Newsgroups gmane.comp.java.grinder.user
Message-ID <CAP3RjavE=Cm3Qi2_zGC+KXde0CD=E11ro7zqJt5jcBtv0v7GuA@mail.gmail.com>
One more issue, need help please

I am now able to create script with TCPProxy Console, But the generated
code is not working,

I generated Jython Script script by using TCPProxy Console. I generated
script for just 4 pages(login page, home, and other two tabs in my home
page.). But I am trying to run that script with grinder agent, But it is
not working. I am getting only login page only. After all pages giving as
403 issue.

*My doubts are*
*1. Is there anything need to change in the generated code?*
*2. there is 'name' and 'pass' in the login page test script. what are
those two?, should I change to based on my login page?*



*I like the features providing by Grinder, I wish to become good tool for
load testing in near future. So, I am suggesting few things, I hope you
also like it.*
*1. Please provide practice demo online like W3School example, recently I
found one grails plugin EasyGrid and one more good suppot providing one is
Adobe Flex is providing samples and video sessions also. they are providing
demo their tools online. *
*It will makes easy to use your tools to users.*



Please find attached my grinder.properties and grinder.py files.

Please need help......

*Output is:*

2014-07-29 11:01:08,902 INFO  USER1-0 thread-0 [ run-193, test-101 ]:
http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:08,902 INFO  USER1-0 thread-0 [ run-193 ]: sleeping for
264 ms
2014-07-29 11:01:09,584 INFO  USER1-0 thread-0 [ run-193, test-201 ]:
http://mycompany.com/home?destination=node/103 -> 302 Found, 0 bytes
[Redirect, ensure the next URL is http://mycompany.com/home]
2014-07-29 11:01:09,584 INFO  USER1-0 thread-0 [ run-193 ]: sleeping for 27
ms
2014-07-29 11:01:09,844 INFO  USER1-0 thread-0 [ run-193, test-202 ]:
http://mycompany.com/home -> 301 Moved Permanently, 0 bytes [Redirect,
ensure the next URL is http://mycompany.com/]
2014-07-29 11:01:09,845 INFO  USER1-0 thread-0 [ run-193 ]: sleeping for 19
ms
2014-07-29 11:01:10,147 INFO  USER1-0 thread-0 [ run-193, test-203 ]:
http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:10,148 INFO  USER1-0 thread-0 [ run-193 ]: sleeping for
141 ms
2014-07-29 11:01:10,579 INFO  USER1-0 thread-0 [ run-193, test-301 ]:
http://mycompany.com/content/holidays-2014 -> 403 Forbidden, 18674 bytes
2014-07-29 11:01:10,579 INFO  USER1-0 thread-0 [ run-193 ]: sleeping for 48
ms
2014-07-29 11:01:10,652 INFO  USER1-0 thread-0 [ run-193, test-302 ]:
http://mycompany.com/sites/default/files/Untitled_3.png -> 200 OK, 130429
bytes
2014-07-29 11:01:10,996 INFO  USER1-0 thread-0 [ run-194, test-101 ]:
http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:10,997 INFO  USER1-0 thread-0 [ run-194 ]: sleeping for
263 ms
2014-07-29 11:01:11,686 INFO  USER1-0 thread-0 [ run-194, test-201 ]:
http://mycompany.com/home?destination=node/103 -> 302 Found, 0 bytes
[Redirect, ensure the next URL is http://mycompany.com/home]
2014-07-29 11:01:11,686 INFO  USER1-0 thread-0 [ run-194 ]: sleeping for 27
ms
2014-07-29 11:01:11,973 INFO  USER1-0 thread-0 [ run-194, test-202 ]:
http://mycompany.com/home -> 301 Moved Permanently, 0 bytes [Redirect,
ensure the next URL is http://mycompany.com/]
2014-07-29 11:01:11,973 INFO  USER1-0 thread-0 [ run-194 ]: sleeping for 17
ms
2014-07-29 11:01:12,229 INFO  USER1-0 thread-0 [ run-194, test-203 ]:
http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:12,229 INFO  USER1-0 thread-0 [ run-194 ]: sleeping for
141 ms
2014-07-29 11:01:12,681 INFO  USER1-0 thread-0 [ run-194, test-301 ]:
http://mycompany.com/content/holidays-2014 -> 403 Forbidden, 18674 bytes
2014-07-29 11:01:12,682 INFO  USER1-0 thread-0 [ run-194 ]: sleeping for 46
ms
2014-07-29 11:01:12,751 INFO  USER1-0 thread-0 [ run-194, test-302 ]:
http://mycompany.com/sites/default/files/Untitled_3.png -> 200 OK, 130429
bytes
2014-07-29 11:01:13,033 INFO  USER1-0 thread-0 [ run-195, test-101 ]:
http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:13,034 INFO  USER1-0 thread-0 [ run-195 ]: sleeping for
307 ms
2014-07-29 11:01:13,937 INFO  USER1-0 thread-0 [ run-195, test-201 ]:
http://mycompany.com/home?destination=node/103 -> 302 Found, 0 bytes
[Redirect, ensure the next URL is http://mycompany.com/home]
2014-07-29 11:01:13,938 INFO  USER1-0 thread-0 [ run-195 ]: sleeping for 27
ms
2014-07-29 11:01:14,223 INFO  USER1-0 thread-0 [ run-195, test-202 ]:
http://mycompany.com/home -> 301 Moved Permanently, 0 bytes [Redirect,
ensure the next URL is http://mycompany.com/]
2014-07-29 11:01:14,224 INFO  USER1-0 thread-0 [ run-195 ]: sleeping for 18
ms
2014-07-29 11:01:14,480 INFO  USER1-0 thread-0 [ run-195, test-203 ]:
http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:14,480 INFO  USER1-0 thread-0 [ run-195 ]: sleeping for
149 ms
2014-07-29 11:01:14,931 INFO  USER1-0 thread-0 [ run-195, test-301 ]:
http://mycompany.com/content/holidays-2014 -> 403 Forbidden, 18674 bytes
2014-07-29 11:01:14,932 INFO  USER1-0 thread-0 [ run-195 ]: sleeping for 49
ms
2014-07-29 11:01:15,003 INFO  USER1-0 thread-0 [ run-195, test-302 ]:
http://mycompany.com/sites/default/files/Untitled_3.png -> 200 OK, 130429
bytes
2014-07-29 11:01:15,277 INFO  USER1-0 thread-0 [ run-196, test-101 ]:
http://mycompany.com/ -> 403 Forbidden, 17617 bytes
2014-07-29 11:01:15,278 INFO  USER1-0 thread-0 [ run-196 ]: sleeping for
301 ms
2014-07-29 11:01:15,332 INFO  USER1-0 : communication shut down
2014-07-29 11:01:15,340 INFO  USER1-0 thread-0 [ run-196 ]: shut down
2014-07-29 11:01:15,341 INFO  USER1-0 thread-0: finished 196 runs
2014-07-29 11:01:15,341 INFO  USER1-0 : elapsed time is 404648 ms
2014-07-29 11:01:15,341 INFO  USER1-0 : Final statistics for this process:
2014-07-29 11:01:15,350 INFO  USER1-0 :
             Tests        Errors       Mean Test    Test Time    TPS
   Mean         Response     Response     Mean time to Mean time to Mean
time to
                                       Time (ms)    Standard
   response     bytes per    errors       resolve host establish    first
byte
                                                    Deviation
  length       second                                 connection

                                                    (ms)



(Test 100    197          0            286.38       35.05        0.49
  0.00         0.00         0            -            -            0.00)
      "Page 1"
Test 101     197          0            285.10       34.57        0.49
  17617.00     8576.71      197          0.10         2.25         265.98
     "GET /"
(Test 200    196          0            970.07       233.03       0.48
  0.00         0.00         0            -            -            0.00)
      "Page 2"
Test 201     196          0            453.68       223.42       0.48
  0.00         0.00         0            0.03         2.51         453.05
     "POST home"
Test 202     196          0            219.01       30.85        0.48
  0.00         0.00         0            0.02         2.26         218.58
     "GET home"
Test 203     196          0            250.14       22.02        0.48
  17617.00     8533.17      196          0.02         2.20         230.47
     "GET /"
(Test 300    196          0            379.49       33.35        0.48
  0.00         0.00         0            -            -            0.00)
      "Page 3"
Test 301     196          0            302.42       32.69        0.48
  18674.00     9045.16      196          0.01         2.20         283.80
     "GET holidays-2014"
Test 302     196          0            28.66        4.78         0.48
  130429.00    63176.10     0            0.01         2.19         6.21
     "GET Untitled_3.png"

Totals       1177         0            256.53       157.42       2.91
  30711.70     89331.14     589          0.03         2.27         243.03

             (589)        (0)



  Tests resulting in error only contribute to the Errors column.
  Statistics for individual tests can be found in the data file, including
  (possibly incomplete) statistics for erroneous tests. Composite tests
  are marked with () and not included in the totals.



On Fri, Jul 25, 2014 at 6:40 PM, Ravi Kumar Maddi <[email protected]>
wrote:

> Thank you very much, for your step by step procedure. I followed your
> steps every thing working fine now. Your steps make me clear all my doubts.
> And solved all my issues.
>
> I am right person or not I don't know, But I like to suggest one thing.
> Could you please put same simple form of using TCPProxy Consolel in Grinder
> Documentation also please.
>
> Because, I read Grinder Documentation one full day, but i am not able to
> understand what should i do after setting in Mozilla and start the TCPProxy
> Console.
>
> Any way, once again very very thankful to you my dear friend.
>
>
>
> On Thu, Jul 24, 2014 at 7:17 PM, alfinhaji . <[email protected]> wrote:
>
>> Have you reviewed the docs?
>>
>> http://grinder.sourceforge.net/g3/tcpproxy.html
>>
>> High level steps:
>>
>> 1.  Start TCP Proxy (details in the above doc), default port is 8001.
>> 2.  Configure browser to use the localhost:8001 port so HTTP traffic
>> generated by your browser goes through TCP Proxy
>> 3.  Run the steps in the browser for the testcase
>> 4.  Click STOP on the TCP Proxy dialog and the resulting grinder script
>> will be generated
>>
>> Above is a very high level overview but between that link and what Gabor
>> provided this should be everything you need.
>>
>> The "insert comment and press enter" feature allows you to inset comments
>> at various points in the script as you are performing the gestures in the
>> browser to assist with documenting the script.
>>
>> Alfin
>>
>>
>> On Thu, Jul 24, 2014 at 9:25 AM, Ravi Kumar Maddi <[email protected]>
>> wrote:
>>
>>> Thanks,  for your fast response, Please help me how to generate test
>>> script with TCPProxy console also please.
>>>
>>>
>>>
>>> On Thu, Jul 24, 2014 at 5:07 PM, Fulop, Gabor <[email protected]>
>>> wrote:
>>>
>>>>  java -classpath c:/grinder-3.11/lib/grinder.jar
>>>> -Dhttp.proxyHost=proxy24.servers.global.prv -Dhttp.proxyPort=8080
>>>> net.grinder.TCPProxy -console -http >~/testScript.py
>>>>
>>>>
>>>>
>>>> After start it displays the proxy port. Configure your client
>>>> (browser) with that proxy and do your test.
>>>>
>>>> When you are finished press the Stop button on TCPProxy console. It
>>>> flushes all of the script to testScript.py.
>>>>
>>>>
>>>>
>>>> *From:* Ravi Kumar Maddi [mailto:[email protected]]
>>>> *Sent:* 24 July 2014 12:22
>>>> *To:* grinder-use
>>>> *Subject:* [Grinder-use] The Grinder - What is 'Insert Command' in
>>>> TCPProxy Console
>>>>
>>>>
>>>>
>>>>
>>>> Grinder documentation saying lot of benefits of TCPProxy console. Like,
>>>> record the response, auto generate the Jython test scripts and a lot. I am
>>>> very happy for that.
>>>>
>>>>
>>>>
>>>> Sorry to say, but I am not able to find how to use TCPProxy Console.
>>>> Like, I see some thing 'Insert command and press enter' text box and
>>>> 'insert command' button. But I did not find any details, what should I
>>>> write in that text box.
>>>>
>>>> But Grinder Documentation showing very big(more than 20 pages) Jthon
>>>> scripts for all situations . But I am not able to find how it generated.
>>>>
>>>>
>>>>
>>>>      Please help me how to use it.
>>>>
>>>>
>>>>
>>>> The information contained in this e-mail and in any attachments is
>>>> intended only for the person or entity to which it is addressed and may
>>>> contain confidential and/or privileged material. Any review,
>>>> retransmission, dissemination or other use of, or taking of any action in
>>>> reliance upon, this information by persons or entities other than the
>>>> intended recipient is prohibited. This message has been scanned for known
>>>> computer viruses.
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Want fast and easy access to all the code in your enterprise? Index and
>>>> search up to 200,000 lines of code with a free copy of Black Duck
>>>> Code Sight - the same software that powers the world's largest code
>>>> search on Ohloh, the Black Duck Open Hub! Try it now.
>>>> http://p.sf.net/sfu/bds
>>>> _______________________________________________
>>>> grinder-use mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/grinder-use
>>>>
>>>>
>>>
>>>
>>> --
>>> Hi ,
>>>
>>>
>>> Thanks and regards,
>>> Ravikumar Maddi,
>>> [email protected],
>>> + 91 - 8884638999
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Want fast and easy access to all the code in your enterprise? Index and
>>> search up to 200,000 lines of code with a free copy of Black Duck
>>> Code Sight - the same software that powers the world's largest code
>>> search on Ohloh, the Black Duck Open Hub! Try it now.
>>> http://p.sf.net/sfu/bds
>>> _______________________________________________
>>> grinder-use mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/grinder-use
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Want fast and easy access to all the code in your enterprise? Index and
>> search up to 200,000 lines of code with a free copy of Black Duck
>> Code Sight - the same software that powers the world's largest code
>> search on Ohloh, the Black Duck Open Hub! Try it now.
>> http://p.sf.net/sfu/bds
>> _______________________________________________
>> grinder-use mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/grinder-use
>>
>>
>
>
> --
> Hi ,
>
>
> Thanks and regards,
> Ravikumar Maddi,
> [email protected],
> + 91 - 8884638999
>
>
>


-- 
Hi ,


Thanks and regards,
Ravikumar Maddi,
[email protected],
+ 91 - 8884638999

------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk

_______________________________________________
grinder-use mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/grinder-use
grinder.properties (application/octet-stream, 160 B) - not displayed
grinder.py (application/octet-stream, 5.9 KB)
# The Grinder 3.11
# HTTP script recorded by TCPProxy at 25 Jul, 2014 6:07:04 PM

from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from net.grinder.plugin.http import HTTPPluginControl, HTTPRequest
from HTTPClient import NVPair
connectionDefaults = HTTPPluginControl.getConnectionDefaults()
httpUtilities = HTTPPluginControl.getHTTPUtilities()

# To use a proxy server, uncomment the next line and set the host and port.
# connectionDefaults.setProxyServer("localhost", 8001)

def createRequest(test, url, headers=None):
    """Create an instrumented HTTPRequest."""
    request = HTTPRequest(url=url)
    if headers: request.headers=headers
    test.record(request, HTTPRequest.getHttpMethodFilter())
    return request

# These definitions at the top level of the file are evaluated once,
# when the worker process is started.

connectionDefaults.defaultHeaders = \
  [ NVPair('Accept-Encoding', 'gzip, deflate'),
    NVPair('Accept-Language', 'en-US,en;q=0.5'),
    NVPair('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0'), ]

headers0= \
  [ NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
    NVPair('Referer', 'http://mycompany.com/'), ]

url0 = 'http://mycompany.com:80'

request101 = createRequest(Test(101, 'GET /'), url0)

request201 = createRequest(Test(201, 'POST home'), url0, headers0)

request202 = createRequest(Test(202, 'GET home'), url0, headers0)

request203 = createRequest(Test(203, 'GET /'), url0, headers0)

request301 = createRequest(Test(301, 'GET about'), url0, headers0)

request401 = createRequest(Test(401, 'GET architecture-group'), url0)

request402 = createRequest(Test(402, 'GET Project Del.PNG'), url0)

request403 = createRequest(Test(403, 'GET 1.gif'), url0)


class TestRunner:
  """A TestRunner instance is created for each worker thread."""

  # A method for each recorded page.
  def page1(self):
    """GET / (request 101)."""
    result = request101.GET('/', None,
      ( NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
        NVPair('If-Modified-Since', 'Fri, 25 Jul 2014 11:48:08 +0000'),
        NVPair('If-None-Match', '\"1406288888\"'), ))
    self.token_form_build_id = \
      httpUtilities.valueFromHiddenInput('form_build_id') # 'form-jL1d4hHwiL-1rr34g20q_UNP64QdrOSC33v...'
    self.token_form_id = \
      httpUtilities.valueFromHiddenInput('form_id') # 'user_login_block'

    return result

  def page2(self):
    """POST home (requests 201-203)."""
    self.token_destination = \
      'node/103'
    
    # Expecting 302 'Found'
    result = request201.POST('/home' +
      '?destination=' +
      self.token_destination,
      ( NVPair('name', 'myuser'),
        NVPair('pass', 'mypassword'),
        NVPair('form_build_id', self.token_form_build_id),
        NVPair('form_id', self.token_form_id),
        NVPair('op', 'Log in'), ),
      ( NVPair('Content-Type', 'application/x-www-form-urlencoded'), ))

    grinder.sleep(61)
    
    # Expecting 301 'Moved Permanently'
    request202.GET('/home')

    grinder.sleep(20)
    request203.GET('/', None,
      ( NVPair('If-Modified-Since', 'Fri, 25 Jul 2014 12:35:04 +0000'),
        NVPair('If-None-Match', '\"1406291704\"'), ))

    return result

  def page3(self):
    """GET about (request 301)."""
    result = request301.GET('/content/about')
    # 2 different values for token_page_id found in response, using the first one.
    self.token_page_id = \
      httpUtilities.valueFromBodyURI('page_id') # '1155'
    self.token_form_build_id = \
      httpUtilities.valueFromHiddenInput('form_build_id') # 'form-lR-C1y-2HiOQm6WAC4tsqp_jra5l2yQ9KKR...'
    self.token_form_token = \
      httpUtilities.valueFromHiddenInput('form_token') # 'kogSWRmK-dBEE5AdCKul1rF5iNooQxicjFQaxfGL...'
    self.token_form_id = \
      httpUtilities.valueFromHiddenInput('form_id') # 'search_block_form'

    return result

  def page4(self):
    """GET architecture-group (requests 401-403)."""
    result = request401.GET('/content/architecture-group', None,
      ( NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
        NVPair('Referer', 'http://mycompany.com/content/about'), ))
    self.token_form_build_id = \
      httpUtilities.valueFromHiddenInput('form_build_id') # 'form-GnuBgklTmk0f7lre8pCi6Aqq30XQoXLLbl2...'

    grinder.sleep(44)
    request402.GET('/sites/default/files/Project Del.PNG', None,
      ( NVPair('Accept', 'image/png,image/*;q=0.8,*/*;q=0.5'),
        NVPair('Referer', 'http://mycompany.com/content/architecture-group'), ))

    grinder.sleep(194)
    request403.GET('/sites/all/themes/perspective/images/loaders/1.gif', None,
      ( NVPair('Accept', 'image/png,image/*;q=0.8,*/*;q=0.5'),
        NVPair('Referer', 'http://mycompany.com/sites/all/themes/perspective/css/themes/40.css?n8fsyg'), ))

    return result

  def writeToFile(self, text):
    filename = "pages/%s-nip_page-%d.html" % (grinder.processName, grinder.runNumber)
    pageFile = open(filename, "w")
    print >> pageFile, text
    file.close()
           

  def __call__(self):
    """Called for every run performed by the worker thread."""
    result = self.page1()      # GET / (request 101)
    self.writeToFile(result.text)

    grinder.sleep(30176)
    result = self.page2()      # POST home (requests 201-203)
    self.writeToFile(result.text)

    grinder.sleep(10965)
    result = self.page3()      # GET about (request 301)
    self.writeToFile(result.text)

    grinder.sleep(2440)
    result = self.page4()      # GET architecture-group (requests 401-403)
    self.writeToFile(result.text)

# Instrument page methods.
Test(100, 'Page 1').record(TestRunner.page1)
Test(200, 'Page 2').record(TestRunner.page2)
Test(300, 'Page 3').record(TestRunner.page3)
Test(400, 'Page 4').record(TestRunner.page4)