I’m running a test on my local it working properly, but when i tried to run it on my docker (docker run -i loadimpact/k6 run - <test.js) I’m getting an error saying they can’t find the remote module. Currently all the modules available on same folder.
how to tackle the current situation ?
If we move the modularize the code with different folders, then how can i tackle it ?
There is a fourm’s post where I explained how to run the k6’s in docker with mounting scripts
Let me try to help you!
Yes, considering the docker -run v is the right direction.
let’s say you have a directory that contains some files:
│ └── users.json
Here the config.json is k6’s config file. The users.json is just some data file that I will use in the tests. And the http_get.js is the test script.
If I run the command:
docker run --rm -v $(pwd):/scripts loadimpact/k6:latest run /scripts/http_get.js
It will mount the c…
If that doesn’t help could you please provide more details about the error that you have?
This is my tree structure
When i run a test (cat loginTest.js | docker run -i grafana/k6 run -) i’ll get a message like below
time=“2022-02-25T07:44:13Z” level=error msg="The moduleSpecifier “…/Pages/homePage.js” couldn’t be found on local disk. Make sure that you’ve specified the right path to the file.
docker run -i loadimpact/k6 run - <test.js
cat loginTest.js | docker run -i grafana/k6 run -
Is just “redirecting” the content of a single file to a k6.
Please try to mount the catalog with the scripts
as the docker volume, as I linked in the first answer. That way from the inside container you can get access to all files.
thanks for the quick response. I’m not a docker expert. Can you tell me based on the tree structure i shared. How to mount it and run the test
So I guess it can be something like:
docker run --rm -v <path to your src>:/scripts loadimpact/k6:latest run /scripts/Test/loginTest.js
So everything that is located in the
src will be located inside the container in the folder
how to pass the proxy details while running with docker. Normally we are passing like
http://localhost:4128”; k6 run
excellent documentation, so you can easily find the answers to such questions.
Just search for the section about environment variables.