I am using a AWS Lambda and NodeJS to do performance testing of some REST APS’s using K6. The lambda handler is triggered via an Event. so, I am invoking the K6 script from the handler.
Now, it is running fine from the local. However, when I try to run it via the Gitlab pipeline, it says “/bin/sh: k6: command not found”
Hi @Matt thanks for responding. The Docker file has no issues. Since i am using NodeJS “package.json”, hence K6 is being installed as a part of that in the pipeline (can confirm via logs).
But, I’m sure that someone who has more experience with containers or nodeJS will be able to figure it out. At least we’ve eliminated the easiest solution!
Could you share the pipeline definition (.gitlab-ci.yml) and the execution logs? If you can send a bit more instructions to reproduce what you are doing, we’ll might be able to help. If the handler runs in a container/VM that has k6 installed, maybe it’s the binary missing from the PATH, as Matt mentioned. However, it’s probably best to try and reproduce your example to see what is going on, and more information will help.
Hmmm. I don’t want to make any assumptions about your use case, but have you tried just installing k6 as a standard binary? That might be an easier approach. You could still use the docker version in your GitLab pipeline.
Unless I’m really incorrect, k6 can’t be a dependency for a node project. k6 scripts run in the k6 binary, which is written in Go. So they can’t run in a node environment. I’d thought that your node pipeline was maybe calling k6 processes, but now I think it’s maybe trying to use k6 directly in node. If I’m off here, please let me know what incorrect assumptions I’ve made!
I’m not sure what that npm package is. It looks like it’s a “dummy package for autocomplete”.
I see what you mean, but how does it work within the Pipeline? Since I can’t use dockerfile to install K6 from the image, I need to install “k6” as package.json only.
Also, how can I install k6 as a dev dependency of a Node.js project ??
I’d just model your pipeline off of this configuration:
loadtest-local:
image:
name: loadimpact/k6:latest
entrypoint: ['']
stage: loadtest-local
script:
- echo "executing local k6 in k6 container..."
- k6 run ./loadtests/performance-test.js
As you’ll see, the pipeline itself calls k6 run. I guess you could store your scripts in the repo of the pipeline, and put all the configuration for your tests in the scripts, or through environment variables.
I need to install “k6” as package.json only.
Also, how can I install k6 as a dev dependency of a Node.js project ??
I don’t think that would work at all. k6 is really a Go application, you need to have the k6 binary.
But, I still think that you can install k6 in your container with your node application.
Are you trying to do something like this?
And, can you post the full (sanitized) pipeline? My guess is that the VM that runs node could also run k6. The only thing you couldn’t do is run k6 scripts in Node, since they use different JS engines.