edit script to continuously change configmaps

Signed-off-by: Silvio Moioli <silvio@moioli.net>
This commit is contained in:
Silvio Moioli 2023-06-08 12:06:01 +02:00
parent 9d0f8ca838
commit 90a6725d82
No known key found for this signature in database
3 changed files with 44 additions and 27 deletions

View File

@ -56,3 +56,12 @@ const testerSAN = tester["san"]
const testerPublicPort = tester["public_http_port"]
console.log(` Grafana UI: http://${testerSAN}:${testerPublicPort}/grafana/ (admin/${ADMIN_PASSWORD})`)
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
)
}

View File

@ -1,18 +1,17 @@
import { sleep } from 'k6';
import encoding from 'k6/encoding';
import exec from 'k6/execution';
import { Counter } from 'k6/metrics';
import * as k8s from './k8s.js'
// Parameters
const namespace = "scalability-test-temp"
const data = encoding.b64encode("a".repeat(1))
const vus = 5
const duration = '2h'
const rate = 1
const namespace = "scalability-test"
// Option setting
const kubeconfig = k8s.kubeconfig(__ENV.KUBECONFIG, __ENV.CONTEXT)
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 = {
insecureSkipTLSVerify: true,
@ -23,10 +22,10 @@ export const options = {
},
],
summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(95)', 'p(99)', 'count'],
setupTimeout: '8h',
scenarios: {
create: {
change: {
executor: 'constant-vus',
exec: 'change',
vus: vus,
@ -38,32 +37,23 @@ export const options = {
}
};
// Custom metrics
const resourceMetric = new Counter('changed_resources')
// 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 name = `test-config-maps-${Math.floor(Math.random() * configMapCount)}`
const body = {
"metadata": {
"name": name,
"namespace": namespace
},
"data": {"data": data}
"data": {"data": (Math.random() + 1).toString(36).substring(2)}
}
k8s.create(`${baseUrl}/api/v1/namespaces/${namespace}/configmaps`, body)
sleep(1.0/rate)
k8s.del(`${baseUrl}/api/v1/namespaces/${namespace}/configmaps/${name}`)
k8s.update(`${baseUrl}/api/v1/namespaces/${namespace}/configmaps/${name}`, body)
sleep(vus/rate)
resourceMetric.add(1)
}

View File

@ -56,6 +56,24 @@ export function del(url){
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]+)"/;
// lists k8s resources