mirror of https://github.com/rancher/dartboard.git
Merge pull request #93 from moio/api_benchmark_pause
This commit is contained in:
commit
c09c1e11a1
|
|
@ -1,9 +1,9 @@
|
|||
import { check, fail } from 'k6';
|
||||
import { check, fail, sleep } from 'k6';
|
||||
import http from 'k6/http';
|
||||
|
||||
// Parameters
|
||||
const vus = __ENV.VUS || 1
|
||||
const perVuIterations = __ENV.PER_VU_ITERATIONS || 30
|
||||
const perVuIterations = parseInt(__ENV.PER_VU_ITERATIONS || 30)
|
||||
const baseUrl = __ENV.BASE_URL
|
||||
const username = __ENV.USERNAME
|
||||
const password = __ENV.PASSWORD
|
||||
|
|
@ -12,9 +12,10 @@ const cluster = __ENV.CLUSTER || "local"
|
|||
const resource = __ENV.RESOURCE || "management.cattle.io.setting"
|
||||
const api = __ENV.API || "steve"
|
||||
const paginationStyle = __ENV.PAGINATION_STYLE || "k8s"
|
||||
const pageSize = __ENV.PAGE_SIZE || 100
|
||||
const pageSize = parseInt(__ENV.PAGE_SIZE || 100)
|
||||
const firstPageOnly = __ENV.FIRST_PAGE_ONLY === "true"
|
||||
const urlSuffix = __ENV.URL_SUFFIX || ""
|
||||
const pauseSeconds = parseFloat(__ENV.PAUSE_SECONDS || 0.0)
|
||||
|
||||
// Option setting
|
||||
export const options = {
|
||||
|
|
@ -55,13 +56,18 @@ export function setup() {
|
|||
'logging in returns status 200': (r) => r.status === 200,
|
||||
})
|
||||
|
||||
pause()
|
||||
|
||||
return http.cookieJar().cookiesForURL(res.url)
|
||||
}
|
||||
|
||||
return {}
|
||||
}
|
||||
|
||||
|
||||
// Simulate a pause after a click - on average pauseSeconds, +/- a random quantity up to 50%
|
||||
function pause() {
|
||||
sleep(pauseSeconds + (Math.random() - 0.5) * 2 * pauseSeconds/2)
|
||||
}
|
||||
|
||||
export function list(cookies) {
|
||||
if (api === "steve") {
|
||||
|
|
@ -119,6 +125,8 @@ function listWithK8sStylePagination(url, cookies) {
|
|||
}
|
||||
throw e
|
||||
}
|
||||
|
||||
pause()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -153,6 +161,8 @@ function listWithSteveStylePagination(url, cookies) {
|
|||
}
|
||||
throw e
|
||||
}
|
||||
|
||||
pause()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -178,5 +188,7 @@ function listWithNormanStylePagination(url, cookies) {
|
|||
}
|
||||
throw e
|
||||
}
|
||||
|
||||
pause()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue