Error running xk6 tests in docker

My test script (switching_dashboards.test.js) lies in below folder structure

k6/tests/switching_dashboards.test.js

My test requires fetching some values from SQL and Mongo database which is why I am building custom xk6 binary with necessary extensions on my local mac and the test runs fine without any issues.

Now I am trying to run the same test on azure pipeline agent using docker. Following the official documentation, here is the command I am using.

docker run --rm -i -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" grafana/xk6 build --with github.com/grafana/xk6-sql@latest --with github.com/grafana/xk6-sql-driver-postgres --with github.com/GhMartingit/xk6-mongo run /xk6/k6/tests/switching_dashboards.test.js

But I get below error.

ERROR build error parsing options missing flag k6 version already set at run

Not sure what i am doing wrong. I would appreciate help on this.

Hi @nshah1, welcome to the communtity!

Can you link the exact part you are following?

To me it sems that you should not have the run ... part. You need to fist build the binary and then call it with run. But maybe I ma missing something, so please provide the documentation you are using.

Hi mstoykov,

My problem is resolved and yes you are correct. I first built the binary and then separately used the run command.

1 Like