How to run tests importing other files on k6-operator

I’m using this tutorial to test on a distributed environment, but I’m having issues running tests files that import other test files.
Is it possible running a test that imports another test file, if so, how can I do that?
I’m using this command to upload the main file: kubectl create configmap scenarios-test --from-file scenarios.js but I do not know how to create the related file that I import inside scenarios.js

Hi @jesselemos

Welcome to the forum! You can create a configmap with several data entries like this:

kubectl create configmap scenarios-test --from-file test.js --from-file utils.js

If there are too many files to specify manually, kubectl allows specifying a folder there too:

kubectl create configmap scenarios-test --from-file=./test

Alternatively, you can create an archive with k6:

k6 archive test.js

Which will create an archive.tar in your current folder. Then you can put that archive into configmap:

kubectl create configmap scenarios-test --from-file=archive.tar

And specify it in your yaml for K6 deployment:

  parallelism: 1
      name: "crocodile-stress-test"
      file: "archive.tar" # <-- change here

It’s actually in my TODO list to add this info about tests with multiple files to k6-operator's README right now and I hope to put it up there in coming days so your question is right on time :smile: Please share if something doesn’t work!

1 Like

Hi @olha,

thanks a lot for your quick and detailed answer.

The archive option worked really well for me.


1 Like