k6 使用 docker,在 运行 上安装卷错误,"accepts 1 arg(s), received 2"
k6 using docker with mounted volume errors on run, with "accepts 1 arg(s), received 2"
我正在尝试 运行 在我的 CI 环境中进行性能测试,使用 k6 docker,一个简单的脚本文件就可以正常工作。但是,我想将我的测试分解为多个 JS 文件。为此,我需要在 Docker 上安装一个卷,以便我可以导入本地模块。
根据我的命令,卷似乎安装正确
docker run --env-file ./test/performance/env/perf.list -v \
`pwd`/test/performance:/perf -i loadimpact/k6 run - /perf/index.js
k6 似乎开始了,但立即出错
time="2018-01-17T13:04:17Z" level=error msg="accepts 1 arg(s), received 2"
在本地,我的文件系统看起来像
/toychicken
/test
/performance
/env
- perf.list
- index.js
- something.js
index.js 看起来像这样
import { check, sleep } from 'k6'
import http from 'k6/http'
import something from '/perf/something'
export default () => {
const r = http.get(`https://${__ENV.DOMAIN}`)
check(r, {
'status is 200': r => r.status === 200
})
sleep(2)
something()
}
您需要删除Docker命令中run
后面的“-”。 “-”指示 k6 从 stdin 读取,但在这种情况下,您希望从文件系统加载主 JS 文件。这就是为什么它抱怨它收到两个参数,一个是“-”,第二个是 index.js 的路径(错误消息肯定可以更具描述性)。
您还需要将 .js
添加到“/perf/something”导入中。
我正在尝试 运行 在我的 CI 环境中进行性能测试,使用 k6 docker,一个简单的脚本文件就可以正常工作。但是,我想将我的测试分解为多个 JS 文件。为此,我需要在 Docker 上安装一个卷,以便我可以导入本地模块。
根据我的命令,卷似乎安装正确
docker run --env-file ./test/performance/env/perf.list -v \
`pwd`/test/performance:/perf -i loadimpact/k6 run - /perf/index.js
k6 似乎开始了,但立即出错
time="2018-01-17T13:04:17Z" level=error msg="accepts 1 arg(s), received 2"
在本地,我的文件系统看起来像
/toychicken
/test
/performance
/env
- perf.list
- index.js
- something.js
index.js 看起来像这样
import { check, sleep } from 'k6'
import http from 'k6/http'
import something from '/perf/something'
export default () => {
const r = http.get(`https://${__ENV.DOMAIN}`)
check(r, {
'status is 200': r => r.status === 200
})
sleep(2)
something()
}
您需要删除Docker命令中run
后面的“-”。 “-”指示 k6 从 stdin 读取,但在这种情况下,您希望从文件系统加载主 JS 文件。这就是为什么它抱怨它收到两个参数,一个是“-”,第二个是 index.js 的路径(错误消息肯定可以更具描述性)。
您还需要将 .js
添加到“/perf/something”导入中。