I am trying to run a k6 test using the grafana/k6 docker image. I am testing a gRPC service running locally. Here’s the command that I have tried:
docker run -i -v /Users/mandar.bhalerao/k6_test:/files -w /files grafana/k6 run --vus 10 --duration 30s - <script.js
The proto file exists in the k6_test
folder. I have volume-mounted the folder which also consists the script.js file. In my script.js, I am trying to connect to the local gRPC server, here are the relevant parts of the code:
const client = new Client();
client.load(null,'mmdb.proto');
if (exec.vu.iterationInScenario === 0) {
console.log('Attempting to connect to gRPC server...');
client.connect('host.docker.internal:7900', {});
console.log('Connection successful');
}
I am not able to connect to the server succesfully. I can only see the Attempting to connect to gRPC server...
logs for each VU. The test runs totally fine when executed without docker image from the terminal.
I have tried checking tcpdump when I run the test, the tcpdump does show packets transferred on localhost port 7900 where I am trying to connect. What am I missing here?
Note: I am using Mac OS
Here’s the output of running the test:
/\ Grafana /‾‾/
/\ / \ |\ __ / /
/ \/ \ | |/ / / ‾‾\
/ \ | ( | (‾) |
/ __________ \ |_|\_\ \_____/
execution: local
script: -
output: -
scenarios: (100.00%) 1 scenario, 10 max VUs, 1m0s max duration (incl. graceful stop):
* default: 10 looping VUs for 30s (gracefulStop: 30s)
time="2024-10-16T22:51:57Z" level=info msg="Attempting to connect to gRPC server..." source=console
time="2024-10-16T22:51:57Z" level=info msg="Attempting to connect to gRPC server..." source=console
time="2024-10-16T22:51:57Z" level=info msg="Attempting to connect to gRPC server..." source=console
time="2024-10-16T22:51:57Z" level=info msg="Attempting to connect to gRPC server..." source=console
time="2024-10-16T22:51:57Z" level=info msg="Attempting to connect to gRPC server..." source=console
time="2024-10-16T22:51:57Z" level=info msg="Attempting to connect to gRPC server..." source=console
time="2024-10-16T22:51:57Z" level=info msg="Attempting to connect to gRPC server..." source=console
time="2024-10-16T22:51:57Z" level=info msg="Attempting to connect to gRPC server..." source=console
time="2024-10-16T22:51:57Z" level=info msg="Attempting to connect to gRPC server..." source=console
time="2024-10-16T22:51:57Z" level=info msg="Attempting to connect to gRPC server..." source=console
running (0m01.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 3% ] 10 VUs 01.0s/30s
running (0m02.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 7% ] 10 VUs 02.0s/30s
running (0m03.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 10% ] 10 VUs 03.0s/30s
running (0m04.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 13% ] 10 VUs 04.0s/30s
running (0m05.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 17% ] 10 VUs 05.0s/30s
running (0m06.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 20% ] 10 VUs 06.0s/30s
running (0m07.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 23% ] 10 VUs 07.0s/30s
running (0m08.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 27% ] 10 VUs 08.0s/30s
running (0m09.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 30% ] 10 VUs 09.0s/30s
running (0m10.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 33% ] 10 VUs 10.0s/30s
running (0m11.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 37% ] 10 VUs 11.0s/30s
running (0m12.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 40% ] 10 VUs 12.0s/30s
running (0m13.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 43% ] 10 VUs 13.0s/30s
running (0m14.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 47% ] 10 VUs 14.0s/30s
running (0m15.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 50% ] 10 VUs 15.0s/30s
running (0m16.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 53% ] 10 VUs 16.0s/30s
running (0m17.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 57% ] 10 VUs 17.0s/30s
running (0m18.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 60% ] 10 VUs 18.0s/30s
running (0m19.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 63% ] 10 VUs 19.0s/30s
running (0m20.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 67% ] 10 VUs 20.0s/30s
running (0m21.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 70% ] 10 VUs 21.0s/30s
running (0m22.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 73% ] 10 VUs 22.0s/30s
running (0m23.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 77% ] 10 VUs 23.0s/30s
running (0m24.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 80% ] 10 VUs 24.0s/30s
running (0m25.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 83% ] 10 VUs 25.0s/30s
running (0m26.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 87% ] 10 VUs 26.0s/30s
running (0m27.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 90% ] 10 VUs 27.0s/30s
running (0m28.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 93% ] 10 VUs 28.0s/30s
running (0m29.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 97% ] 10 VUs 29.0s/30s
running (0m30.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default [ 100% ] 10 VUs 30.0s/30s
running (0m31.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m32.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m33.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m34.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m35.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m36.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m37.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m38.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m39.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m40.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m41.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m42.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m43.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m44.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m45.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m46.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m47.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m48.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m49.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m50.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m51.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m52.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m53.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m54.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m55.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m56.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m57.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m58.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (0m59.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
running (1m00.0s), 10/10 VUs, 0 complete and 0 interrupted iterations
default ↓ [ 100% ] 10 VUs 30s
time="2024-10-16T22:52:57Z" level=warning msg="No script iterations fully finished, consider making the test duration longer"
data_received...: 131 kB 2.2 kB/s
data_sent.......: 23 kB 388 B/s
vus.............: 10 min=10 max=10
vus_max.........: 10 min=10 max=10
running (1m00.0s), 00/10 VUs, 0 complete and 10 interrupted iterations
default ✓ [ 100% ] 10 VUs 30s