From ab3261b84862323b4df739bff23a33ac1e182a2a Mon Sep 17 00:00:00 2001 From: Marshall Main Date: Thu, 19 Mar 2020 11:49:28 -0400 Subject: [PATCH 1/2] log random seed to console --- x-pack/plugins/endpoint/scripts/resolver_generator.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/endpoint/scripts/resolver_generator.ts b/x-pack/plugins/endpoint/scripts/resolver_generator.ts index 503999daec587..3d11ccaad005d 100644 --- a/x-pack/plugins/endpoint/scripts/resolver_generator.ts +++ b/x-pack/plugins/endpoint/scripts/resolver_generator.ts @@ -131,8 +131,13 @@ async function main() { process.exit(1); } } - - const generator = new EndpointDocGenerator(argv.seed); + let seed = argv.seed; + if (!seed) { + seed = Math.random().toString(); + // eslint-disable-next-line no-console + console.log('No seed supplied, using random seed: ' + seed); + } + const generator = new EndpointDocGenerator(seed); for (let i = 0; i < argv.numHosts; i++) { await client.index({ index: argv.metadataIndex, From 2634b153ea7aeab65f781acbfc2f4898cd4e763a Mon Sep 17 00:00:00 2001 From: Marshall Main Date: Thu, 19 Mar 2020 14:27:25 -0400 Subject: [PATCH 2/2] fix off by 1 error with children --- x-pack/plugins/endpoint/common/generate_data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/endpoint/common/generate_data.ts b/x-pack/plugins/endpoint/common/generate_data.ts index 2e1d6074d0c2f..5ff0d8e14e92a 100644 --- a/x-pack/plugins/endpoint/common/generate_data.ts +++ b/x-pack/plugins/endpoint/common/generate_data.ts @@ -325,7 +325,7 @@ export class EndpointDocGenerator { for (let i = 0; i < generations; i++) { const newParents: EndpointEvent[] = []; parents.forEach(element => { - const numChildren = this.randomN(maxChildrenPerNode); + const numChildren = this.randomN(maxChildrenPerNode + 1); for (let j = 0; j < numChildren; j++) { timestamp = timestamp + 1000; const child = this.generateEvent({