node.js关闭连接时,Jmeter测试脚本不起作用? [英] Jmeter test script doesn't work when node.js close connection?

查看:92
本文介绍了node.js关闭连接时,Jmeter测试脚本不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的API上传,它用于接受来自客户端的上传文件.

I have a simple API upload, it is used to accept upload file from client.

var flg=true;
app.post('/test', function(req, res){
flg=!flg;
var returnJson='{';
if(flg){
    req.form.on('part', function (part) {
        if(part){
            part.resume();
        }
        returnJson=returnJson+',\"status\":\"0\"}';
        res.send(returnJson);
    });
}else{
            console.log('close');
    returnJson=returnJson+',\"status\":\"1\"}';
    res.header('Connection', 'close');
    res.send(413, returnJson);
}
 });

我想用Jmeter测试此API. "status":"0"表示成功. "status":"1"表示失败.我写这样的Jmeter脚本: http://i.imgur.com/vEUJKc8.jpg

I'd like to test this API with Jmeter. "status":"0" means success. "status":"1" means failure. I write Jmeter script like this: http://i.imgur.com/vEUJKc8.jpg

Jmeter仅显示响应包含状态":"0"的所有采样器.似乎Jmeter排除了来自else部分的故障采样器响应. http://imgur.com/bkFSpK2

Jmeter only displays all the samplers which response contains "status":"0". it seems Jmeter exclude failure sampler response which comes from else section. http://imgur.com/bkFSpK2

我如何在Jmeter中看到所有包含所有成功和失败采样器的采样器? 成功的Sampler结果是: 线程名称:API 1-1 样品开始时间:2013-12-18 11:46:08 PST 加载时间:7 延迟:6 以字节为单位的大小:178 标头大小(以字节为单位):163 正文大小(以字节为单位):15 样本数:1 错误计数:0 响应码:200 响应消息:确定

How can I see all samplers which includes all success and failure samplers in Jmeter? successful Sampler result is : Thread Name: API 1-1 Sample Start: 2013-12-18 11:46:08 PST Load time: 7 Latency: 6 Size in bytes: 178 Headers size in bytes: 163 Body size in bytes: 15 Sample Count: 1 Error Count: 0 Response code: 200 Response message: OK

响应头: HTTP/1.1 200 OK X-Powered-By:快递 内容类型:text/html;字符集= utf-8 内容长度:15 日期:2013年12月18日,星期三19:46:08 GMT 连接:保持活动状态

Response headers: HTTP/1.1 200 OK X-Powered-By: Express Content-Type: text/html; charset=utf-8 Content-Length: 15 Date: Wed, 18 Dec 2013 19:46:08 GMT Connection: keep-alive

HTTPSampleResult字段: ContentType:text/html;字符集= utf-8 数据编码:utf-8

HTTPSampleResult fields: ContentType: text/html; charset=utf-8 DataEncoding: utf-8

有什么建议吗?

推荐答案

我不喜欢这个节:

 ContentType: text/html;

正确的JSON ContentType将为application/json

Correct ContentType for JSON will be application/json

您可以尝试使用 HTTP标头管理器来设置Content-Type您的请求标头为application/json,看看会发生什么.

You can try using HTTP Header Manager to set Content-Type header of your request to be application/json and see what happens.

还有一个JSON 插件,它提供JSON路径提取器和JSON路径声明(选择下载列表中的设置了libs的其他内容".

Also there is a JSON plugin which provides JSON Path Extractor and JSON Path Assertion (Select "Extras with libs set" from the download list).

这篇关于node.js关闭连接时,Jmeter测试脚本不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆