-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-script.js
72 lines (64 loc) · 2.06 KB
/
simple-script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { base_url } from "./config.js";
import { sleep, group } from 'k6'
import { check } from 'k6';
import http from 'k6/http'
import { getCurrentStageIndex } from 'https://jslib.k6.io/k6-utils/1.3.0/index.js';
export const options = {
cloud: {
// The ID of the project to which the test is assigned in the k6 Cloud UI.
// By default tests are executed in default project.
projectID: "3719588",
// The name of the test in the k6 Cloud UI.
// Test runs with the same name will be grouped.
name: "SE K6 Testing",
// Define loadZone distribution
distribution: {
AWS_London: { loadZone: 'amazon:gb:london', percent: 100 }
}
},
thresholds: {
// http errors should be less than 1%
http_req_failed: ['rate<0.01'],
// 95% of requests should be below 600ms
http_req_duration: ['p(95)<600']},
scenarios: {
GetHomepage: {
// Constant VUs
executor: 'constant-vus',
gracefulStop: '30s',
duration: '1m',
vus: 1,
//Ramping VUs
// executor: 'ramping-vus',
// startVUs: 0,
// stages: [
// { target: 100, duration: '30s' },
// { target: 100, duration: '1m' },
// { target: 200, duration: '30s' },
// { target: 200, duration: '1m' },
// ],
// gracefulStop: '30s',
exec: 'GetHomepage',
},
},
}
export function GetHomepage() {
let response
group(`page_1 - ${base_url}`, function () {
// The ${base_url} variable has been set in config.js and imported
// This variable can be modified at run time by passing the -e HOSTNAME flag e.g k6 run -e HOSTNAME=domain.com simple-script.js
response = http.get(`https://${base_url}/`,
{
headers: {
'upgrade-insecure-requests': '1',
'sec-ch-ua': '"Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
},
})
})
// Adding check for 200 response code
check(response, {
'is status 200': (r) => r.status === 200,
});
}