Use unified Steve API benchmark script

Signed-off-by: Silvio Moioli <silvio@moioli.net>
This commit is contained in:
Silvio Moioli 2023-09-20 15:17:54 +02:00
parent 3038900ee0
commit cd79b8a88b
No known key found for this signature in database
3 changed files with 7 additions and 184 deletions

View File

@ -44,21 +44,21 @@ for (const tag of ["v2.7.5", "improved"]) {
)
}
for (const test of ["load_steve_k8s_pagination", "load_steve_new_pagination"]) {
for (const paginationStyle of ["k8s", "steve"]) {
for (const clusterId of ["local", downstreamClusterId]) {
// warmup
k6_run(tester,
{ BASE_URL: `https://${upstream["private_name"]}:443`, USERNAME: "admin", PASSWORD: ADMIN_PASSWORD, VUS: 1, PER_VU_ITERATIONS: 5, CLUSTER: clusterId, CONFIG_MAP_COUNT: count },
{commit: commit, cluster: clusterId, test: `${test}.js`, ConfigMaps: count},
`k6/${test}.js`
{ BASE_URL: `https://${upstream["private_name"]}:443`, USERNAME: "admin", PASSWORD: ADMIN_PASSWORD, VUS: 1, PER_VU_ITERATIONS: 5, CLUSTER: clusterId, RESOURCE: "configmap", PAGINATION_STYLE: paginationStyle },
{commit: commit, cluster: clusterId, test: `steve_paginated_api_benchmark.js`, ConfigMaps: count},
`k6/steve_paginated_api_benchmark.js`
)
// test + record
k6_run(tester,
{ BASE_URL: `https://${upstream["private_name"]}:443`, USERNAME: "admin", PASSWORD: ADMIN_PASSWORD, VUS: 10, PER_VU_ITERATIONS: 30, CLUSTER: clusterId, CONFIG_MAP_COUNT: count },
{commit: commit, cluster: clusterId, test: `${test}.js`, ConfigMaps: count},
`k6/${test}.js`, true
{ BASE_URL: `https://${upstream["private_name"]}:443`, USERNAME: "admin", PASSWORD: ADMIN_PASSWORD, VUS: 10, PER_VU_ITERATIONS: 30, CLUSTER: clusterId, RESOURCE: "configmap", PAGINATION_STYLE: paginationStyle },
{commit: commit, cluster: clusterId, test: `steve_paginated_api_benchmark.js`, ConfigMaps: count},
`k6/steve_paginated_api_benchmark.js`, true
)
}
}

View File

@ -1,89 +0,0 @@
import { check, fail } from 'k6';
import http from 'k6/http';
import { Gauge } from 'k6/metrics';
// Parameters
const vus = __ENV.VUS
const perVuIterations = __ENV.PER_VU_ITERATIONS
const baseUrl = __ENV.BASE_URL
const username = __ENV.USERNAME
const password = __ENV.PASSWORD
const cluster = __ENV.CLUSTER
// Option setting
export const options = {
insecureSkipTLSVerify: true,
scenarios: {
list : {
executor: 'per-vu-iterations',
exec: 'list',
vus: vus,
iterations: perVuIterations,
maxDuration: '24h',
}
},
thresholds: {
checks: ['rate>0.99']
}
}
// Custom metrics
const variableMetric = new Gauge('test_variable')
// Test functions, in order of execution
export function setup() {
// log in
const res = http.post(`${baseUrl}/v3-public/localProviders/local?action=login`, JSON.stringify({
"description": "UI session",
"responseType": "cookie",
"username": username,
"password": password
}))
check(res, {
'/v3-public/localProviders/local?action=login returns status 200': (r) => r.status === 200,
})
return http.cookieJar().cookiesForURL(res.url)
}
export function list(cookies) {
const url = cluster === "local"?
`${baseUrl}/v1/configmaps` :
`${baseUrl}/k8s/clusters/${cluster}/v1/configmaps`
let revision = null
let continueToken = null
while (true) {
const fullUrl = url + "?limit=100" +
(revision != null ? "&revision=" + revision : "") +
(continueToken != null ? "&continue=" + continueToken : "")
const res = http.get(fullUrl, {cookies: cookies})
check(res, {
'/v1/configmaps returns status 200': (r) => r.status === 200,
})
try {
const body = JSON.parse(res.body)
if (body === undefined || body.continue === undefined) {
break
}
if (revision == null) {
revision = body.revision
}
continueToken = body.continue
}
catch (e){
if (e instanceof SyntaxError) {
fail("Response body does not parse as JSON: " + res.body)
}
throw e
}
}
variableMetric.add(Number(__ENV.CONFIG_MAP_COUNT))
}

View File

@ -1,88 +0,0 @@
import { check, fail } from 'k6';
import http from 'k6/http';
import { Gauge } from 'k6/metrics';
// Parameters
const vus = __ENV.VUS
const perVuIterations = __ENV.PER_VU_ITERATIONS
const baseUrl = __ENV.BASE_URL
const username = __ENV.USERNAME
const password = __ENV.PASSWORD
const cluster = __ENV.CLUSTER
// Option setting
export const options = {
insecureSkipTLSVerify: true,
scenarios: {
list : {
executor: 'per-vu-iterations',
exec: 'list',
vus: vus,
iterations: perVuIterations,
maxDuration: '24h',
}
},
thresholds: {
checks: ['rate>0.99']
}
}
// Custom metrics
const variableMetric = new Gauge('test_variable')
// Test functions, in order of execution
export function setup() {
// log in
const res = http.post(`${baseUrl}/v3-public/localProviders/local?action=login`, JSON.stringify({
"description": "UI session",
"responseType": "cookie",
"username": username,
"password": password
}))
check(res, {
'/v3-public/localProviders/local?action=login returns status 200': (r) => r.status === 200,
})
return http.cookieJar().cookiesForURL(res.url)
}
export function list(cookies) {
const url = cluster === "local"?
`${baseUrl}/v1/configmaps` :
`${baseUrl}/k8s/clusters/${cluster}/v1/configmaps`
let i = 1
let revision = null
while (true) {
const fullUrl = url + "?pagesize=100&page=" + i +
(revision != null ? "&revision=" + revision : "")
const res = http.get(fullUrl, {cookies: cookies})
check(res, {
'/v1/configmaps returns status 200': (r) => r.status === 200,
})
try {
const body = JSON.parse(res.body)
if (body === undefined || body.data === undefined || body.data.length === 0) {
break
}
if (revision == null) {
revision = body.revision
}
i = i + 1
}
catch (e){
if (e instanceof SyntaxError) {
fail("Response body does not parse as JSON: " + res.body)
}
throw e
}
}
variableMetric.add(Number(__ENV.CONFIG_MAP_COUNT))
}