Groovy코드로 모든 HTTPRequest의 Response time을 레코딩 할 수 있나요?

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

Groovy코드로 모든 HTTPRequest의 Response time을 레코딩 할 수 있나요?

riojung
안녕하세요.

저희는 레코더 대신에 fiddler Exporting Tool을 개발해서 fiddler로 레코딩된 모든 session들을 export해서 groovy script를 생성했습니다.
Eclipse로 로컬 테스팅을 잘되는데, 막상 nGrinder로 올려서 테스트를 돌려보면 아무것도 레코딩이 안되고 테스트가 fail되더군요.

/**
 * This script was generated by FiddlerToGroovyExportExtension
 *
 * @author
 */
@RunWith(GrinderRunner)
class Scenario
{
        static def connectionDefaults = HTTPPluginControl.getConnectionDefaults();
        static def httpUtilities = HTTPPluginControl.getHTTPUtilities();
        static def logger = grinder.logger;
        public static HTTPRequest request;
        static def threadContext;

        public static GTest test1
        public static GTest test2
        public static GTest test3
        public static GTest test4
        public static GTest test5
        public static GTest test6
        public static GTest test7
        public static GTest test8
        public static GTest test9
        public static GTest test10
        public static GTest test11
        public static GTest test12
        public static GTest test13
        public static GTest test14
        public static GTest test15
        public static GTest test16
        public static GTest test17
        public static GTest test18
        public static GTest test19
        public static GTest test20
        public static GTest test21

        @BeforeProcess
        public static void beforeProcess() {
                grinder.logger.info('Initializing Process');
                HTTPPluginControl.getConnectionDefaults().timeout = 60000;
                request = new HTTPRequest();
               
                test1 = new GTest(1, 'request1');
                test2 = new GTest(2, 'request2');
                test3 = new GTest(3, 'request3');
                test4 = new GTest(4, 'request4');
                test5 = new GTest(5, 'request5');
                test6 = new GTest(6, 'request6');
                test7 = new GTest(7, 'request7');
                test8 = new GTest(8, 'request8');
                test9 = new GTest(9, 'request9');
                test10 = new GTest(10, 'request10');
                test11 = new GTest(11, 'request11');
                test12 = new GTest(12, 'request12');
                test13 = new GTest(13, 'request13');
                test14 = new GTest(14, 'request14');
                test15 = new GTest(15, 'request15');
                test16 = new GTest(16, 'request16');
                test17 = new GTest(17, 'request17');
                test18 = new GTest(18, 'request18');
                test19 = new GTest(19, 'request19');
                test20 = new GTest(20, 'request20');
                test21 = new GTest(21, 'request21');
                test22 = new GTest(22, 'request22');
        }

        @BeforeThread
        public static void beforeThread() {
                grinder.logger.info('Initializing Thread');
                grinder.statistics.delayReports = true;
               
                test1.record(this, "request1");
                test2.record(this, "request2");
                test3.record(this, "request3");
                test4.record(this, "request4");
                test5.record(this, "request5");
                test6.record(this, "request6");
                test7.record(this, "request7");
                test8.record(this, "request8");
                test9.record(this, "request9");
                test10.record(this, "request10");
                test11.record(this, "request11");
                test12.record(this, "request12");
                test13.record(this, "request13");
                test14.record(this, "request14");
                test15.record(this, "request15");
                test16.record(this, "request16");
                test17.record(this, "request17");
                test18.record(this, "request18");
                test19.record(this, "request19");
                test20.record(this, "request20");
                test21.record(this, "request21");
        }

        @AfterThread
        public static void afterThread() {
                grinder.logger.info('Cleaning up Thread');
        }

        @Test
        public void test()
        {
                // The below is automatically generated, you will have to update the script and enter dynamic values to
                // make the script work for multiple users. You may have to use extraction rules to obtain the dynamic values

               

                def response1 = request1(request,
                        [ new NVPair('Host', 'login.swimlane32a.xxxxx.staging'), new NVPair('Connection', 'keep-alive'), new NVPair('Content-Length', '110'), new NVPair('Accept', 'application/json, text/javascript, */*; q=0.01'), new NVPair('Origin', 'https://login.swimlane32a.xxxxxx.staging'), new NVPair('X-Requested-With', 'XMLHttpRequest'), new NVPair('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36'), new NVPair('Content-Type', 'application/x-www-form-urlencoded'), new NVPair('Referer', 'https://login.swimlane32a.replicon.staging/Default.aspx?companykey=perf0&msg=&code=&init='), new NVPair('Accept-Language', 'en-GB,en;q=0.8,en-US;q=0.6,ko;q=0.4'), ] as NVPair[],
                        "https://login.swimlane32a.replicon.staging/Login.ashx",
                        [ new NVPair('cid', 'perf0'), new NVPair('user', 'widgetio00001'), new NVPair('password', 'Password123'), new NVPair('remember', 'false'), new NVPair('galinkerurl', ''), new NVPair('initdata', ''), new NVPair('loginProvider', 'Replicon') ] as NVPair[]);

... def response21 = request21(request,
                        [ new NVPair('Host', 'login.swimlane32a.xxxxx.staging'), new NVPair('Connection', 'keep-alive'), new NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'), new NVPair('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36'), new NVPair('Referer', 'https://na2.swimlane32a.xxxxx.staging/perf0/my/timesheet/current'), new NVPair('Accept-Language', 'en-GB,en;q=0.8,en-US;q=0.6,ko;q=0.4'), ] as NVPair[],
                        "https://login.swimlane32a.xxxxx.staging/Default.aspx?companykey=perf0&msg=&code=&init=");


스크립트 상으로는 문제가 없어 보이는데...
혹시 이런식으로 테스트를 생성할때 제약사항이나 따라야하는 format이 있는지..
아니면 어떠한 setting을 변경시켜 주어야하는지 알고싶습니다.

언제나 감사합니다...ㅎ
Reply | Threaded
Open this post in threaded view
|

Re: Groovy코드로 모든 HTTPRequest의 Response time을 레코딩 할 수 있나요?

junoyoon
Administrator
ngrinder controller 에 나오는 로그를 올려주시기 바랍니다.

일단 보내주신 스크립트 상으로는 큰 문제가 없어 보이네요.
Reply | Threaded
Open this post in threaded view
|

Re: Groovy코드로 모든 HTTPRequest의 Response time을 레코딩 할 수 있나요?

riojung
This post was updated on .
스크립트와 agent and ngrinder log file를 올려놓았습니다.

https://dl.dropboxusercontent.com/u/18720259/nGrinderTest.zip

언제나 도움 감사합니다...ㅎ