【发布时间】:2017-11-17 11:56:03
【问题描述】:
我是第一次使用 k6,我已经设法在运行脚本时遇到错误:
"请求失败 [33merror[0m="获取 https:///: 已停止 0 次重定向后”
脚本 k6.js:
import http from "k6/http";
import { sleep } from "k6";
export let options = {
stages: [
{ duration: "30s", target: 20 },
{ duration: "1m30s", target: 10 },
{ duration: "20s", target: 0 },
]
};
export default function() {
let res = http.get("https://<our_page_URL>/");
check(res, {
"status code MUST be 200": (res) => res.status == 200,
}) || fail("status code was *not* 200");
sleep(1);
}
为什么会出现此错误,解决方法是什么?
【问题讨论】:
-
为什么你有
|| fail()检查,而不是设置options.throw到true? -
好问题。我在 k6 页面上找到了这个例子,对我来说似乎很有用,这就是为什么我用它来看看它是如何工作的。不幸的是,我不知道如何使用 options.throw,但会查看文档。
-
@Sander & jurijk 我认为这些文档是在 options.throw 存在之前编写的。感谢您指出这一点,我会看看我是否可以更新文档!