Skip to content

Commit

Permalink
CI Reporter for saved objects field count
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed Jul 2, 2020
1 parent a0e2630 commit e09c77b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ kibanaPipeline(timeoutMinutes: 155, checkPrChanges: true, setCommitStatus: true)
'xpack-ciGroup9': kibanaPipeline.xpackCiGroupProcess(9),
'xpack-ciGroup10': kibanaPipeline.xpackCiGroupProcess(10),
'xpack-accessibility': kibanaPipeline.functionalTestProcess('xpack-accessibility', './test/scripts/jenkins_xpack_accessibility.sh'),
'xpack-savedObjectsFieldMetrics': kibanaPipeline.functionalTestProcess('xpack-savedObjectsFieldMetrics', './test/scripts/jenkins_xpack_saved_objects_field_metrics.sh'),
// 'xpack-pageLoadMetrics': kibanaPipeline.functionalTestProcess('xpack-pageLoadMetrics', './test/scripts/jenkins_xpack_page_load_metrics.sh'),
'xpack-securitySolutionCypress': { processNumber ->
whenChanged(['x-pack/plugins/security_solution/', 'x-pack/test/security_solution_cypress/']) {
Expand Down
9 changes: 9 additions & 0 deletions test/scripts/jenkins_xpack_saved_objects_field_metrics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

source test/scripts/jenkins_test_setup_xpack.sh

checks-reporter-with-killswitch "Capture Kibana Saved Objects field count metrics" \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$installDir" \
--config test/saved_objects_field_count/config.ts;
34 changes: 34 additions & 0 deletions x-pack/test/saved_objects_field_count/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { resolve } from 'path';

import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
import { testRunner } from './runner';

export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const kibanaCommonTestsConfig = await readConfigFile(
require.resolve('../../../test/common/config.js')
);
const xpackFunctionalTestsConfig = await readConfigFile(
require.resolve('../functional/config.js')
);

return {
...kibanaCommonTestsConfig.getAll(),

testRunner,

esTestCluster: {
...xpackFunctionalTestsConfig.get('esTestCluster'),
serverArgs: [...xpackFunctionalTestsConfig.get('esTestCluster.serverArgs')],
},

kbnTestServer: {
...xpackFunctionalTestsConfig.get('kbnTestServer'),
},
};
}
27 changes: 27 additions & 0 deletions x-pack/test/saved_objects_field_count/runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { CiStatsReporter } from '@kbn/dev-utils';
// @ts-ignore not TS yet
import getUrl from '../../../src/test_utils/get_url';

import { FtrProviderContext } from './../functional/ftr_provider_context';

export async function testRunner({ getService }: FtrProviderContext) {
const log = getService('log');
const config = getService('config');
const es = getService('es');

const reporter = CiStatsReporter.fromEnv(log);

const { body: fields } = await es.fieldCaps({
index: '.kibana',
fields: '*',
});
const fieldCount = Object.keys(fields).length;
log.debug('Saved Objects field count');
await reporter.metrics({ group: 'Saved Objects field count', id: 'total', value: fieldCount });
}

0 comments on commit e09c77b

Please sign in to comment.