nGrinder 3.1 -> nGrinder 3.1.3 포팅 문의 드립니다.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

nGrinder 3.1 -> nGrinder 3.1.3 포팅 문의 드립니다.

jungjeongyun
This post was updated on .
소스
# -*- coding:utf-8 -*-

# A simple example using the HTTP plugin that shows the retrieval of a
# single page via HTTP.
#
# This script is auto generated by ngrinder.
#
# @author admin
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 org.slf4j import LoggerFactory
from ch.qos.logback.classic import Level
from ch.qos.logback.classic import Logger

from net.grinder.plugin.http import HTTPPluginControl  


control = HTTPPluginControl.getConnectionDefaults()
control.setTimeout(30000)

test1 = Test(2, "notice_request")
request1 = test1.wrap(HTTPRequest())

# control = HTTPPluginControl.getConnectionDefaults()
# if you want to follow the redirection, please modify the following option 1.
# contorl.setFollowRedirects(0)
# and add the import statement at the beginning
# from net.grinder.plugin.http import HTTPPluginControl
# if you want to increase the timeout, please modify the following option.
# control.setTimeout(3000)

class TestRunner:
        def __init__(self):
                logger = LoggerFactory.getLogger("worker");
                logger.setLevel(Level.ERROR);
        def __call__(self):
                grinder.statistics.delayReports=True
       
                result = request1.GET("http://192.168.51.51/MDSM/1060/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX1?seq=1")
        #
        # result is a HTTPClient.HTTPResult.
        # We get the message body using the getText() method.
        # if result.getText().find("HELLO WORLD") != -1 :
        #    grinder.statistics.forLastTest.success = 1
        # else :
        #     grinder.statistics.forLastTest.success = 0
           
        # if you want to print out log..
        # Don't use print keyword. This will make the output lost.
        # instead use following.
        # grinder.logger.info("Hello World")
                if result.statusCode == 200 and result.getText().find("ok") != -1:
                        grinder.statistics.forLastTest.success = 1
                else:
                        grinder.statistics.forLastTest.success = 0

--------------------------------------------------------------------------------------
스크립트 검증 결과

2013-05-21 15:02:00,125 INFO  The Grinder version 3.9.1
2013-05-21 15:02:00,128 INFO  Java(TM) SE Runtime Environment 1.6.0_38-b05: Java HotSpot(TM) 64-Bit Server VM (20.13-b02, mixed mode) on Linux amd64 3.2.0-29-generic
2013-05-21 15:02:00,131 INFO  time zone is KST (+0900)
2013-05-21 15:02:00,177 INFO  worker process 0
2013-05-21 15:02:00,250 INFO  instrumentation agents: byte code transforming instrumenter for Jython 2.5; byte code transforming instrumenter for Java
2013-05-21 15:02:02,087 INFO  registered plug-in net.grinder.plugin.http.HTTPPlugin
2013-05-21 15:02:02,139 INFO  running "notice_request.py" using Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:54:35)
[Java HotSpot(TM) 64-Bit Server VM (Sun Microsystems Inc.)]


2013-05-21 15:02:02,141 INFO  validation-0: starting threads
2013-05-21 15:02:02,188 INFO  validation-0: finished
----------------------------------------------------------------------------------------------------------------

3.1에서는 잘 돌아가던 소스인데 어떻게 수정해야 될지 막막하네요...
Reply | Threaded
Open this post in threaded view
|

Re: nGrinder 3.1 -> nGrinder 3.1.3 포팅 문의 드립니다.

junoyoon
Administrator
test1 = Test(2, "notice_request")
request1 = HTTPRequest()
test1.record(request1)

으로 바꿔 보세요.
Reply | Threaded
Open this post in threaded view
|

Re: nGrinder 3.1 -> nGrinder 3.1.3 포팅 문의 드립니다.

junoyoon
Administrator
In reply to this post by jungjeongyun
그러고 보니..

logger = LoggerFactory.getLogger("worker");
logger.setLevel(Level.ERROR);

이 부분이 있으시군요.
이렇게 설정하시면 에러 로그가 아니라면 메시지를 출력하지 않습니다.

즉 HTTP 호출하는 로그가 않나와서 호출이 않되는 것으로 오해하신 듯 한데요...
이것 위와 같이 설정하셨기 때문입니다.

logger.setLevel(Level.INFO);

와 같이 로그 레벨을 낮춰서 실행해 보세요.