mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[scalability testing] extend FTR config with optional scalability configuration (#132047)
* [scalability testing] extend FTR config * update schema with defaults for testData
This commit is contained in:
parent
e3c47ecc46
commit
80427ea1ba
3 changed files with 92 additions and 1 deletions
|
@ -14,6 +14,7 @@ import type { CustomHelpers } from 'joi';
|
|||
// valid pattern for ID
|
||||
// enforced camel-case identifiers for consistency
|
||||
const ID_PATTERN = /^[a-zA-Z0-9_]+$/;
|
||||
const SCALABILITY_DURATION_PATTERN = /^[1-9]\d{0,}[m|s]$/;
|
||||
// it will search both --inspect and --inspect-brk
|
||||
const INSPECTING = !!process.execArgv.find((arg) => arg.includes('--inspect'));
|
||||
|
||||
|
@ -264,6 +265,67 @@ export const schema = Joi.object()
|
|||
})
|
||||
.default(),
|
||||
|
||||
/**
|
||||
* Optional settings to list test data archives, that will be loaded during the 'beforeTests'
|
||||
* lifecycle phase and unloaded during the 'cleanup' lifecycle phase.
|
||||
*/
|
||||
testData: Joi.object()
|
||||
.keys({
|
||||
kbnArchives: Joi.array().items(Joi.string()).default([]),
|
||||
esArchives: Joi.array().items(Joi.string()).default([]),
|
||||
})
|
||||
.default(),
|
||||
|
||||
/**
|
||||
* Optional settings to enable scalability testing for single user performance journey.
|
||||
* If defined, 'scalabilitySetup' must include 'warmup' and 'test' stages,
|
||||
* 'maxDuration', e.g. '10m' to limit execution time to 10 minutes.
|
||||
* Each stage must include 'action', 'duration' and 'maxUsersCount'.
|
||||
* In addition, 'rampConcurrentUsers' requires 'minUsersCount' to ramp users from
|
||||
* min to max within provided time duration.
|
||||
*/
|
||||
scalabilitySetup: Joi.object()
|
||||
.keys({
|
||||
warmup: Joi.object()
|
||||
.keys({
|
||||
stages: Joi.array().items(
|
||||
Joi.object().keys({
|
||||
action: Joi.string()
|
||||
.valid('constantConcurrentUsers', 'rampConcurrentUsers')
|
||||
.required(),
|
||||
duration: Joi.string().pattern(SCALABILITY_DURATION_PATTERN).required(),
|
||||
minUsersCount: Joi.number().when('action', {
|
||||
is: 'rampConcurrentUsers',
|
||||
then: Joi.number().required().less(Joi.ref('maxUsersCount')),
|
||||
otherwise: Joi.forbidden(),
|
||||
}),
|
||||
maxUsersCount: Joi.number().required().greater(0),
|
||||
})
|
||||
),
|
||||
})
|
||||
.required(),
|
||||
test: Joi.object()
|
||||
.keys({
|
||||
stages: Joi.array().items(
|
||||
Joi.object().keys({
|
||||
action: Joi.string()
|
||||
.valid('constantConcurrentUsers', 'rampConcurrentUsers')
|
||||
.required(),
|
||||
duration: Joi.string().pattern(SCALABILITY_DURATION_PATTERN).required(),
|
||||
minUsersCount: Joi.number().when('action', {
|
||||
is: 'rampConcurrentUsers',
|
||||
then: Joi.number().required().less(Joi.ref('maxUsersCount')),
|
||||
otherwise: Joi.forbidden(),
|
||||
}),
|
||||
maxUsersCount: Joi.number().required().greater(0),
|
||||
})
|
||||
),
|
||||
})
|
||||
.required(),
|
||||
maxDuration: Joi.string().pattern(SCALABILITY_DURATION_PATTERN).required(),
|
||||
})
|
||||
.optional(),
|
||||
|
||||
// settings for the kibanaServer.uiSettings module
|
||||
uiSettings: Joi.object()
|
||||
.keys({
|
||||
|
|
|
@ -13,10 +13,11 @@ import * as KibanaServer from './kibana_server';
|
|||
export function EsArchiverProvider({ getService }: FtrProviderContext): EsArchiver {
|
||||
const config = getService('config');
|
||||
const client = getService('es');
|
||||
|
||||
const lifecycle = getService('lifecycle');
|
||||
const log = getService('log');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
const retry = getService('retry');
|
||||
const esArchives = config.get('testData.esArchives');
|
||||
|
||||
const esArchiver = new EsArchiver({
|
||||
client,
|
||||
|
@ -31,5 +32,19 @@ export function EsArchiverProvider({ getService }: FtrProviderContext): EsArchiv
|
|||
defaults: config.get('uiSettings.defaults'),
|
||||
});
|
||||
|
||||
if (esArchives) {
|
||||
lifecycle.beforeTests.add(async () => {
|
||||
for (const archive of esArchives) {
|
||||
await esArchiver.load(archive);
|
||||
}
|
||||
});
|
||||
|
||||
lifecycle.cleanup.add(async () => {
|
||||
for (const archive of esArchives) {
|
||||
await esArchiver.unload(archive);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return esArchiver;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ export function KibanaServerProvider({ getService }: FtrProviderContext): KbnCli
|
|||
const lifecycle = getService('lifecycle');
|
||||
const url = Url.format(config.get('servers.kibana'));
|
||||
const defaults = config.get('uiSettings.defaults');
|
||||
const kbnArchives = config.get('testData.kbnArchives');
|
||||
const kbn = new KbnClient({
|
||||
log,
|
||||
url,
|
||||
|
@ -30,5 +31,18 @@ export function KibanaServerProvider({ getService }: FtrProviderContext): KbnCli
|
|||
});
|
||||
}
|
||||
|
||||
if (kbnArchives) {
|
||||
lifecycle.beforeTests.add(async () => {
|
||||
for (const archive of kbnArchives) {
|
||||
await kbn.importExport.load(archive);
|
||||
}
|
||||
});
|
||||
lifecycle.cleanup.add(async () => {
|
||||
for (const archive of kbnArchives) {
|
||||
await kbn.importExport.unload(archive);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return kbn;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue