Local and On-premise execution
Running load tests from your laptop or an on-premise machine is one of the ways you can use k6.
Executing a local test
To execute a test where the traffic is generated from the local machine you execute the
run k6 command. So say you have a test in a file called
script.js, you’d then trigger a local test by executing the following in your terminal:
k6 run script.js
Streaming results to Insights
By default when running a local test, k6 will output a summary of the results to the terminal. The results are not persisted by default. If you want to store the results, graphically analyze them, share them with your team mates and trend the performance of your system over time, you can opt to send your test results to Load Impact Insights.
You do this by first making sure you’re logged in to your Load Impact account:
k6 login cloud (for more authentication options, see here)
For Single-Sign On (SSO) users logging in with
k6 login cloudwon't work as it requires a Load Impact account email and password. You'll instead need to get your API authentication token from the app and supply that explicitly:
k6 login cloud --token YOUR_API_AUTH_TOKEN.
If you're running k6 in a Docker container you'll need to make sure that the k6 config file where the Load Impact API authentication information (an API authentication token) will be stored to is persisted via a Docker volume to the host machine using the
-c/--config PATH/TO/CONFIG_FILECLI flag, e.g.
docker run -i -v /path/on-host:/path/in-container/ loadimpact/k6 login cloud -c /path/in-container/config.json.
and then adding the
-o cloud CLI flag:
k6 run -o cloud script.js
You should now see something like this in your terminal:
Note the URL in the
output: cloud (https://app.loadimpact.com/k6/runs/12696). That URLs is where you go to see the test results as they come streaming in from the test execution.
See also: Cloud execution