Skip to content

Commit

Permalink
[scalability testing] extend FTR config with optional scalability con…
Browse files Browse the repository at this point in the history
…figuration (elastic#132047)

* [scalability testing] extend FTR config

* update schema with defaults for testData
  • Loading branch information
dmlemeshko authored and Esteban Beltran committed May 12, 2022
1 parent 2b86a82 commit 177b9cc
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
62 changes: 62 additions & 0 deletions packages/kbn-test/src/functional_test_runner/lib/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down Expand Up @@ -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({
Expand Down
17 changes: 16 additions & 1 deletion test/common/services/es_archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
14 changes: 14 additions & 0 deletions test/common/services/kibana_server/kibana_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}

0 comments on commit 177b9cc

Please sign in to comment.