-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathchange_config_maps.js
70 lines (60 loc) · 1.76 KB
/
change_config_maps.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
import { sleep } from 'k6';
import encoding from 'k6/encoding';
import exec from 'k6/execution';
import * as k8s from './k8s.js'
// Parameters
const namespace = "scalability-test-temp"
const data = encoding.b64encode("a".repeat(1))
const duration = '2h'
const vus = __ENV.VUS || 5
// 2 requests per iteration, so iteration rate is half of request rate
const rate = (__ENV.RATE || 1) / 2
// Option setting
const kubeconfig = k8s.kubeconfig(__ENV.KUBECONFIG, __ENV.CONTEXT)
const baseUrl = __ENV.BASE_URL
export const options = {
insecureSkipTLSVerify: true,
tlsAuth: [
{
cert: kubeconfig["cert"],
key: kubeconfig["key"],
},
],
summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'count'],
scenarios: {
change: {
executor: 'constant-arrival-rate',
exec: 'change',
preAllocatedVUs: vus,
duration: duration,
rate: rate,
},
},
thresholds: {
checks: ['rate>0.99']
}
};
// Test functions, in order of execution
export function setup() {
// delete leftovers, if any
k8s.del(`${baseUrl}/api/v1/namespaces/${namespace}`)
// create empty namespace
const body = {
"metadata": {
"name": namespace,
},
}
k8s.create(`${baseUrl}/api/v1/namespaces`, body)
}
export function change() {
const name = `test-config-map-${exec.scenario.name}-${exec.scenario.iterationInTest}`
const body = {
"metadata": {
"name": name,
"namespace": namespace
},
"data": {"data": data}
}
k8s.create(`${baseUrl}/api/v1/namespaces/${namespace}/configmaps`, body, false)
k8s.del(`${baseUrl}/api/v1/namespaces/${namespace}/configmaps/${name}`)
}