只想问一下,如何阅读K6在websockets负载测试中生成的报告
这是我从这样编写的代码中得到的报告
import {
check,
fail,
sleep
} from "k6";
import {
Counter,
Rate
} from "k6/metrics";
import ws from "k6/ws";
let errorCount = new Counter("error_count");
//let errorRate = new Rate("error_rate");
export const options = {
thresholds: {
"error_rate": ["rate<0.2"]
} // error rate not more than 20 percent
};
export default function () {
var url = "wss://play.blabla.com";
console.log(url);
var params = {
headers: {
"accept-encoding": "gzip, deflate",
"accept-language": "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
}
};
let res;
res = ws.connect(url, params, function(socket) {
socket.on('open', function open() {
console.log('connected');
socket.setInterval(function timeout() {
socket.ping();
console.log("Pinging every 500 ms (setInterval test)");
}, 500);
});
socket.on('ping', function () {
console.log("PING!");
});
socket.on('pong', function () {
console.log("PONG!");
});
socket.on('close', function() {
console.log('disconnected');
});
socket.on('error', function(e) {
if (e.error() != "websocket: close sent") {
console.log('An unexpected error occured: ', e.error());
}
});
});
let checking = check(res, { "status is 101": r => r && r.status === 101 });
}
我不知道ws_sessions
达到了5603,但是checks
只说了815
有人可以解释吗?该报告的测试结果是好是坏。
非常感谢您的帮助!