@@ -6,31 +6,36 @@ excerpt: 'Follow along to learn how to run a test, add virtual users, increase t
6
6
Follow along to learn how to:
7
7
1 . Run a test.
8
8
2 . Add virtual users.
9
- 3 . Increase the test duration.
9
+ 3 . Increase the test duration.
10
10
4 . Ramp the number of requests up and down as the test runs.
11
11
12
12
With these example snippets, you'll run the test with your machine's resources.
13
- But, if you have a k6 Cloud account, you can also use the ` k6 cloud ` command to outsource the test to k6 servers.
13
+ But, if you have a k6 Cloud account, you can also use the ` k6 cloud ` command to outsource the test to k6 servers.
14
14
15
15
<!-- preserving old anchor --->
16
16
## Run local tests {#running-local-tests}
17
17
18
18
To run a simple local script:
19
- 1 . Copy the following code, paste it into your favorite editor, and save it as ` script.js ` :
19
+ 1 . Create and initialize a new script by running the following command :
20
20
21
- <CodeGroup labels={[ "script.js" ] } lineNumbers={ [ true ] }>
21
+ <CodeGroup labels={[ "CLI", "Docker", "Docker in Win PowerShell" ] }>
22
22
23
- ``` javascript
24
- import http from ' k6/http ' ;
25
- import { sleep } from ' k6 ' ;
23
+ ``` bash
24
+ $ k6 new
25
+ ```
26
26
27
- export default function () {
28
- http .get (' https://test.k6.io' );
29
- sleep (1 );
30
- }
31
- ```
27
+ ` ` ` bash
28
+ $ docker run --rm -i -v $PWD :/app -w /app grafana/k6 new
29
+ ` ` `
32
30
33
- </CodeGroup >
31
+ ` ` ` bash
32
+ PS C:\> docker run --rm -i -v ${PWD} :/app -w /app grafana/k6 init
33
+ ` ` `
34
+
35
+ < /CodeGroup>
36
+
37
+ This command creates a new script file named ` script.js` in the current directory.
38
+ You can also specify a different file name as an argument to the ` k6 new` command, for example ` k6 new my-test.js` .
34
39
35
40
1. Run k6 with the following command:
36
41
@@ -196,17 +201,17 @@ You can run the same test in different modes with minimal changes.
196
201
197
202
< /Blockquote>
198
203
199
- k6 supports three execution modes to run a k6 test: local, distributed, and cloud.
204
+ k6 supports three execution modes to run a k6 test: local, distributed, and cloud.
200
205
201
- - ** Local** : the test execution happens entirely on a single machine, container, or CI server.
206
+ - ** Local** : the test execution happens entirely on a single machine, container, or CI server.
202
207
203
208
` ` ` bash
204
209
k6 run script.js
205
210
` ` `
206
211
207
- - ** Distributed** : the test execution is [ distributed across a Kubernetes cluster] ( /testing-guides/running-distributed-tests/ ) .
208
-
209
- <CodeGroup labels={[ "Running", "k6-resource.yaml"] } lineNumbers={[ true] }>
212
+ - ** Distributed** : the test execution is [distributed across a Kubernetes cluster](/testing-guides/running-distributed-tests/).
213
+
214
+ < CodeGroup labels={[" Running" , " k6-resource.yaml" ]} lineNumbers={[true]}>
210
215
211
216
` ` ` bash
212
217
kubectl apply -f /path/k6-resource.yaml
0 commit comments