Skip to content

Commit

Permalink
Merge branch 'master' into relevance-tuning-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Feb 1, 2021
2 parents ea2c50c + 3c0d30c commit afa1665
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 20 deletions.
13 changes: 11 additions & 2 deletions test/scripts/jenkins_build_load_testing.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/usr/bin/env bash

while getopts s: flag
do
case "${flag}" in
s) simulations=${OPTARG};;
esac
done
echo "Simulation classes: $simulations";

cd "$KIBANA_DIR"
source src/dev/ci_setup/setup_env.sh

Expand All @@ -25,6 +33,7 @@ echo " -> test setup"
source test/scripts/jenkins_test_setup_xpack.sh

echo " -> run gatling load testing"
export GATLING_SIMULATIONS="$simulations"
node scripts/functional_tests \
--kibana-install-dir "$KIBANA_INSTALL_DIR" \
--config test/load/config.ts
--kibana-install-dir "$KIBANA_INSTALL_DIR" \
--config test/load/config.ts
24 changes: 24 additions & 0 deletions x-pack/plugins/grokdebugger/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"common/**/*",
"public/**/*",
"server/**/*",
"../../typings/**/*",
],
"references": [
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../../../src/plugins/dev_tools/tsconfig.json"},
{ "path": "../../../src/plugins/home/tsconfig.json"},
{ "path": "../../../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../../../src/plugins/es_ui_shared/tsconfig.json" },
{ "path": "../licensing/tsconfig.json" }
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/
/* eslint-disable no-console */
import yargs from 'yargs';
import fs from 'fs';
import { Client, ClientOptions } from '@elastic/elasticsearch';
import { ResponseError } from '@elastic/elasticsearch/lib/errors';
import { KbnClient, ToolingLog } from '@kbn/dev-utils';
import { KbnClient, ToolingLog, CA_CERT_PATH } from '@kbn/dev-utils';
import { AxiosResponse } from 'axios';
import { indexHostsAndAlerts } from '../../common/endpoint/index_data';
import { ANCESTRY_LIMIT, EndpointDocGenerator } from '../../common/endpoint/generate_data';
Expand Down Expand Up @@ -202,15 +203,41 @@ async function main() {
type: 'boolean',
default: false,
},
ssl: {
alias: 'ssl',
describe: 'Use https for elasticsearch and kbn clients',
type: 'boolean',
default: false,
},
}).argv;
let ca: Buffer;
let kbnClient: KbnClientWithApiKeySupport;
let clientOptions: ClientOptions;

const kbnClient = new KbnClientWithApiKeySupport({
log: new ToolingLog({
level: 'info',
writeTo: process.stdout,
}),
url: argv.kibana,
});
if (argv.ssl) {
ca = fs.readFileSync(CA_CERT_PATH);
const url = argv.kibana.replace('http:', 'https:');
const node = argv.node.replace('http:', 'https:');
kbnClient = new KbnClientWithApiKeySupport({
log: new ToolingLog({
level: 'info',
writeTo: process.stdout,
}),
url,
certificateAuthorities: [ca],
});
clientOptions = { node, ssl: { ca: [ca] } };
} else {
kbnClient = new KbnClientWithApiKeySupport({
log: new ToolingLog({
level: 'info',
writeTo: process.stdout,
}),
url: argv.kibana,
});
clientOptions = { node: argv.node };
}
const client = new Client(clientOptions);

try {
await doIngestSetup(kbnClient);
Expand All @@ -219,9 +246,6 @@ async function main() {
process.exit(1);
}

const clientOptions: ClientOptions = { node: argv.node };
const client = new Client(clientOptions);

if (argv.delete) {
await deleteIndices(
[argv.eventIndex, argv.metadataIndex, argv.policyIndex, argv.alertIndex],
Expand Down
63 changes: 56 additions & 7 deletions x-pack/test/load/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,78 @@
import { withProcRunner } from '@kbn/dev-utils';
import { resolve } from 'path';
import { REPO_ROOT } from '@kbn/utils';
import Fs from 'fs';
import { createFlagError } from '@kbn/dev-utils';
import { FtrProviderContext } from './../functional/ftr_provider_context';

const baseSimulationPath = 'src/test/scala/org/kibanaLoadTest/simulation';
const simulationPackage = 'org.kibanaLoadTest.simulation';
const simulationFIleExtension = '.scala';
const gatlingProjectRootPath: string =
process.env.GATLING_PROJECT_PATH || resolve(REPO_ROOT, '../kibana-load-testing');
const simulationEntry: string = process.env.GATLING_SIMULATIONS || 'DemoJourney';

if (!Fs.existsSync(gatlingProjectRootPath)) {
throw createFlagError(
`Incorrect path to load testing project: '${gatlingProjectRootPath}'\n
Clone 'elastic/kibana-load-testing' and set path using 'GATLING_PROJECT_PATH' env var`
);
}

const dropEmptyLines = (s: string) => s.split(',').filter((i) => i.length > 0);
const simulationClasses = dropEmptyLines(simulationEntry);
const simulationsRootPath = resolve(gatlingProjectRootPath, baseSimulationPath);

simulationClasses.map((className) => {
const simulationClassPath = resolve(
simulationsRootPath,
className.replace('.', '/') + simulationFIleExtension
);
if (!Fs.existsSync(simulationClassPath)) {
throw createFlagError(`Simulation class is not found: '${simulationClassPath}'`);
}
});

/**
*
* GatlingTestRunner is used to run load simulation against local Kibana instance
*
* Use GATLING_SIMULATIONS to pass comma-separated class names
* Use GATLING_PROJECT_PATH to override path to 'kibana-load-testing' project
*/
export async function GatlingTestRunner({ getService }: FtrProviderContext) {
const log = getService('log');
const gatlingProjectRootPath = resolve(REPO_ROOT, '../kibana-load-testing');

await withProcRunner(log, async (procs) => {
await procs.run('gatling', {
await procs.run('mvn: clean compile', {
cmd: 'mvn',
args: [
'clean',
'-q',
'-Dmaven.wagon.http.retryHandler.count=3',
'-Dmaven.test.failure.ignore=true',
'compile',
'gatling:test',
'-q',
'-Dgatling.simulationClass=org.kibanaLoadTest.simulation.DemoJourney',
'clean',
'compile',
],
cwd: gatlingProjectRootPath,
env: {
...process.env,
},
wait: true,
});
for (const simulationClass of simulationClasses) {
await procs.run('gatling: test', {
cmd: 'mvn',
args: [
'gatling:test',
'-q',
`-Dgatling.simulationClass=${simulationPackage}.${simulationClass}`,
],
cwd: gatlingProjectRootPath,
env: {
...process.env,
},
wait: true,
});
}
});
}
1 change: 1 addition & 0 deletions x-pack/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
{ "path": "../plugins/global_search_bar/tsconfig.json" },
{ "path": "../plugins/ingest_pipelines/tsconfig.json" },
{ "path": "../plugins/license_management/tsconfig.json" },
{ "path": "../plugins/grokdebugger/tsconfig.json" },
{ "path": "../plugins/painless_lab/tsconfig.json" },
{ "path": "../plugins/watcher/tsconfig.json" }
]
Expand Down
2 changes: 2 additions & 0 deletions x-pack/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"plugins/license_management/**/*",
"plugins/painless_lab/**/*",
"plugins/watcher/**/*",
"plugins/grokdebugger/**/*",
"test/**/*"
],
"compilerOptions": {
Expand Down Expand Up @@ -119,6 +120,7 @@
{ "path": "./plugins/translations/tsconfig.json" },
{ "path": "./plugins/triggers_actions_ui/tsconfig.json"},
{ "path": "./plugins/stack_alerts/tsconfig.json"},
{ "path": "./plugins/grokdebugger/tsconfig.json" },
{ "path": "./plugins/ingest_pipelines/tsconfig.json"},
{ "path": "./plugins/license_management/tsconfig.json" },
{ "path": "./plugins/painless_lab/tsconfig.json" },
Expand Down
1 change: 1 addition & 0 deletions x-pack/tsconfig.refs.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
{ "path": "./plugins/cloud/tsconfig.json" },
{ "path": "./plugins/saved_objects_tagging/tsconfig.json" },
{ "path": "./plugins/global_search_bar/tsconfig.json" },
{ "path": "./plugins/grokdebugger/tsconfig.json" },
{ "path": "./plugins/ingest_pipelines/tsconfig.json" },
{ "path": "./plugins/license_management/tsconfig.json" },
{ "path": "./plugins/painless_lab/tsconfig.json" },
Expand Down

0 comments on commit afa1665

Please sign in to comment.