I’m building my scripts into a docker image as part of our build pipeline. My dockerfile:
FROM loadimpact/k6:0.26.1
ENV SCRIPT card-payment.js
COPY ./test /test
WORKDIR /test
ENTRYPOINT [] # override the base image so we can run scripts inside the container
CMD ["sh", "-c", "k6 run $SCRIPT"]
When I run this via the docker command line it works as expected and I’m able to pass in the K6 environment variables:
docker run --rm -it -e K6_VUS=2 loadtests:latest
However, when I run the image in ECS with my environment variables set in the task definition, the K6 variables are ignored and my test is always run with 1 VU.
The probable reason as to why this is not working is that your last CMD argument will be treated as a single argument. I’d like to fancy a guess that this would work as you’d expect if you were to change:
@benfoster - I read your article " Running Load Tests From the Cloud With k6" in your website. Would you please share the snapshot of your task definition ( in Fargate) and please provide some suggestion how did you view your logs while running your task in ECS cluster?. Though I saw your task JSON file in your article, I couldn’t understand completely. It would be really helpful if you add few more steps in your article with snapshot and how did you run the test and visualize the logs/report.
Thank you so much for sharing your knowledge with others. Looking forward your answers.