I am trying to learn k6
and I started with its official documents. I tried the sample code in run document with both docker image and command-line. In the docker version it works fine:
zeinab@ZiZi:~$ docker run -i loadimpact/k6 run - <k6_test.js
/\ |‾‾| /‾‾/ /‾/
/\ / \ | |_/ / / /
/ \/ \ | | / ‾‾\
/ \ | |‾\ \ | (_) |
/ __________ \ |__| \__\ \___/ .io
execution: local--------------------------------------------------] servertor
output: -
script: -
duration: -, iterations: 1
vus: 1, max: 1
time="2020-02-18T11:14:26Z" level=info msg=Running i=0 t=971.124809ms starting
...
time="2020-02-18T11:14:55Z" level=info msg=Running i=0 t=29.971104099s
time="2020-02-18T11:14:55Z" level=warning msg="Request Failed" error="Get http://test.loadimpact.com: proxyconnect tcp: dial tcp 192.168.14.109:1087: i/o timeout"
time="2020-02-18T11:14:56Z" level=info msg=Running i=0 t=30.971060995s
time="2020-02-18T11:14:56Z" level=info msg="Test finished" i=1 t=31.000143344s
data_received..............: 0 B 0 B/s
data_sent..................: 0 B 0 B/s
http_req_blocked...........: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_connecting........: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_duration..........: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_receiving.........: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_sending...........: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_tls_handshaking...: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_waiting...........: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_reqs..................: 1 0.032258/s
iteration_duration.........: avg=31s min=31s med=31s max=31s p(90)=31s p(95)=31s
iterations.................: 1 0.032258/s
vus........................: 1 min=1 max=1
vus_max....................: 1 min=1 max=1
But when running from command-line, I get:
zeinab@ZiZi:~$ sudo k6 run ./k6_test.js
/\ |‾‾| /‾‾/ /‾/
/\ / \ | |_/ / / /
/ \/ \ | | / ‾‾\
/ \ | |‾\ \ | (_) |
/ __________ \ |__| \__\ \___/ .io
ERRO[0000] open /home/zeinab/k6_test.js: permission denied
EDIT 1:
I get the same error when running with current user:
k6 run ./k6_test.js
EDIT 2:
I installed k6
using snap
:
zeinab@ZiZi:~$ snap install k6
k6 v0.23.1 from Null Box (nullboxorg) installed
Given the fact you use snap to install it, this means that the k6 from inside snap doesn't have access to your whole fs as well (just as docker doesn't).
I don't understand snap all that much but given that whoever builds k6 for snap hasn't updated it in the last year I would recommend just getting the binary and running it ;).
Original answer:
It is exactly what it says: your root
user can't open /home/zeinab/k6_test.js
because they don't have permissions. I would guess they either can't read your home directory (/home/zeinab
) or the file itself.
You don't really need to use sudo
so either remove it or fix the permissions for the script, although again running with root is not necessary and is bad practice either way :D
As a side note, the docker works because whatever shell (probably bash) you run is the one that reads the file and send it to stdin of the docker process. So even if docker
is alias for sudo docker
it will still work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With