脚本里有多个test,但是ngrinder的测试报告的TPS,平均响应时间都只有total一条线指标

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

脚本里有多个test,但是ngrinder的测试报告的TPS,平均响应时间都只有total一条线指标

Emilie

场景:
我的脚本里有两个test,并且实例化了两个test,每个test里面是一个接口请求。
        public static GTest test
        public static GTest GetCity
        public static GTest GetReRoutesByCity
        public static HTTPRequest request
// public static HTTPRequest request2
        public static NVPair[] headers = []
        public static NVPair[] params = []
        public static Cookie[] cookies = []

        @BeforeProcess
        public static void beforeProcess() {
                HTTPPluginControl.getConnectionDefaults().timeout = 6000
                GetCity = new GTest(1, "GetCity")
                GetReRoutesByCity = new GTest(2, "GetReRoutesByCity")
                request = new HTTPRequest()
// request2 = new HTTPRequest()
                grinder.logger.info("before process.");
        }

        @BeforeThread
        public void beforeThread() {
// GetCity.record(request)
// GetReRoutesByCity.record(request2)
                GetCity.record(this, "GetCity")
                GetReRoutesByCity.record(this, "GetReRoutesByCity")
                grinder.statistics.delayReports=true;
                grinder.logger.info("before thread.");
        }
        @Before
        public void before() {
                List<NVPair> headerList = new ArrayList<NVPair>()
                headerList.add(new NVPair("Content-Type", "application/x-www-form-urlencoded"))
                headerList.add(new NVPair("Connection", "keep-alive"))
                headers = headerList.toArray()

                request.setHeaders(headers)
                cookies.each { CookieModule.addCookie(it, HTTPPluginControl.getThreadHTTPClientContext()) }
                grinder.logger.info("before thread. init headers and cookies");
        }
@RunRate(50)
        @Test
        public void GetCity(){
                List<NVPair> paramList = new ArrayList<NVPair>()
                paramList.add(new NVPair("_","1582768877"))
                HTTPResponse result = request.GET("",params)
                grinder.logger.info(JSONObject.parseObject(result.text).getString("Code"))
                if (result.statusCode !=200) {
                        grinder.logger.warn("Warning. The response may not be correct. The response code was {}.", result.statusCode);
                } else {
                        assertThat(JSONObject.parseObject(result.text).getString("Code"), is("0"));
                }
        }

        @RunRate(50)
        @Test
        public void GetReRoutesByCity(){
                List<NVPair> paramList = new ArrayList<NVPair>()
                paramList.add(new NVPair("CityCode","SHA"))
                paramList.add(new NVPair("Lang","zh-cn"))
                paramList.add(new NVPair("_","1582774357821"))
                HTTPResponse result = request.GET("",params)
                grinder.logger.info(JSONObject.parseObject(result.text).getString("Code"))
                if (result.statusCode !=200) {
                        grinder.logger.warn("Warning. The response may not be correct. The response code was {}.", result.statusCode);
                } else {
                        assertThat(JSONObject.parseObject(result.text).getString("Code"), is("0"));
                }
        }
结果:
ngrinder运行后,报告里面只有一条total的指标
期望:
可以看到每个test对应接口的指标线

请问怎么处理?网上的方法都试过了,报告总是只有一个total指标线,求指教,万分感谢
Reply | Threaded
Open this post in threaded view
|

Re: 脚本里有多个test,但是ngrinder的测试报告的TPS,平均响应时间都只有total一条线指标

zero
测试运行的配置页面,点击"显示高级配置",设置采样间隔大于等于3,再运行试试
Reply | Threaded
Open this post in threaded view
|

Re: 脚本里有多个test,但是ngrinder的测试报告的TPS,平均响应时间都只有total一条线指标

Emilie
wow~可以了 感谢感谢。
ps:这个采样间隔是什么意思?