mirror of https://github.com/rancher/dartboard.git
edit script to continuously change configmaps
Signed-off-by: Silvio Moioli <silvio@moioli.net>
This commit is contained in:
parent
9d0f8ca838
commit
90a6725d82
|
|
@ -56,3 +56,12 @@ const testerSAN = tester["san"]
|
||||||
const testerPublicPort = tester["public_http_port"]
|
const testerPublicPort = tester["public_http_port"]
|
||||||
console.log(` Grafana UI: http://${testerSAN}:${testerPublicPort}/grafana/ (admin/${ADMIN_PASSWORD})`)
|
console.log(` Grafana UI: http://${testerSAN}:${testerPublicPort}/grafana/ (admin/${ADMIN_PASSWORD})`)
|
||||||
console.log()
|
console.log()
|
||||||
|
|
||||||
|
// Change config maps
|
||||||
|
for (const [name, downstream] of downstreams) {
|
||||||
|
k6_run(tester,
|
||||||
|
{ BASE_URL: `https://${downstream["private_name"]}:6443`, KUBECONFIG: downstream["kubeconfig"], CONTEXT: downstream["context"], CONFIG_MAP_COUNT: CONFIG_MAP_COUNT, VUS: 10, RATE: 200, DURATION: "1h"},
|
||||||
|
{commit: commit, cluster: name, test: "change_config_maps.mjs"},
|
||||||
|
"k6/change_config_maps.js", true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
import { sleep } from 'k6';
|
import { sleep } from 'k6';
|
||||||
import encoding from 'k6/encoding';
|
import { Counter } from 'k6/metrics';
|
||||||
import exec from 'k6/execution';
|
|
||||||
import * as k8s from './k8s.js'
|
import * as k8s from './k8s.js'
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
const namespace = "scalability-test-temp"
|
const namespace = "scalability-test"
|
||||||
const data = encoding.b64encode("a".repeat(1))
|
|
||||||
const vus = 5
|
|
||||||
const duration = '2h'
|
|
||||||
const rate = 1
|
|
||||||
|
|
||||||
// Option setting
|
// Option setting
|
||||||
const kubeconfig = k8s.kubeconfig(__ENV.KUBECONFIG, __ENV.CONTEXT)
|
const kubeconfig = k8s.kubeconfig(__ENV.KUBECONFIG, __ENV.CONTEXT)
|
||||||
const baseUrl = __ENV.BASE_URL
|
const baseUrl = __ENV.BASE_URL
|
||||||
|
const configMapCount = Number(__ENV.CONFIG_MAP_COUNT)
|
||||||
|
const vus = Number(__ENV.VUS)
|
||||||
|
const rate = Number(__ENV.RATE)
|
||||||
|
const duration = __ENV.DURATION
|
||||||
|
|
||||||
export const options = {
|
export const options = {
|
||||||
insecureSkipTLSVerify: true,
|
insecureSkipTLSVerify: true,
|
||||||
|
|
@ -23,10 +22,10 @@ export const options = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'count'],
|
setupTimeout: '8h',
|
||||||
|
|
||||||
scenarios: {
|
scenarios: {
|
||||||
create: {
|
change: {
|
||||||
executor: 'constant-vus',
|
executor: 'constant-vus',
|
||||||
exec: 'change',
|
exec: 'change',
|
||||||
vus: vus,
|
vus: vus,
|
||||||
|
|
@ -38,32 +37,23 @@ export const options = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Custom metrics
|
||||||
|
const resourceMetric = new Counter('changed_resources')
|
||||||
|
|
||||||
// Test functions, in order of execution
|
// 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() {
|
export function change() {
|
||||||
const name = `test-config-map-${exec.scenario.name}-${exec.scenario.iterationInTest}`
|
const name = `test-config-maps-${Math.floor(Math.random() * configMapCount)}`
|
||||||
const body = {
|
const body = {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": name,
|
"name": name,
|
||||||
"namespace": namespace
|
"namespace": namespace
|
||||||
},
|
},
|
||||||
"data": {"data": data}
|
"data": {"data": (Math.random() + 1).toString(36).substring(2)}
|
||||||
}
|
}
|
||||||
|
|
||||||
k8s.create(`${baseUrl}/api/v1/namespaces/${namespace}/configmaps`, body)
|
k8s.update(`${baseUrl}/api/v1/namespaces/${namespace}/configmaps/${name}`, body)
|
||||||
sleep(1.0/rate)
|
sleep(vus/rate)
|
||||||
k8s.del(`${baseUrl}/api/v1/namespaces/${namespace}/configmaps/${name}`)
|
|
||||||
|
resourceMetric.add(1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
k6/k8s.js
18
k6/k8s.js
|
|
@ -56,6 +56,24 @@ export function del(url){
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// updates an existing k8s resource
|
||||||
|
export function update(url, body){
|
||||||
|
const res = http.put(url, JSON.stringify(body));
|
||||||
|
|
||||||
|
check(res, {
|
||||||
|
'PUT returns status 200 or 409': (r) => r.status === 200 || r.status === 409,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (res.status === 409) {
|
||||||
|
// wait a bit and try again
|
||||||
|
sleep(Math.random())
|
||||||
|
|
||||||
|
return update(url, body)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
const continueRegex = /"continue":"([A-Za-z0-9]+)"/;
|
const continueRegex = /"continue":"([A-Za-z0-9]+)"/;
|
||||||
|
|
||||||
// lists k8s resources
|
// lists k8s resources
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue