Skip to content

Commit

Permalink
[ftr] rework ciGroup validation to remove JOBS.yml and avoid duplicat…
Browse files Browse the repository at this point in the history
…ion (#109149)

Co-authored-by: spalger <[email protected]>
# Conflicts:
#	.ci/jobs.yml
#	test/scripts/jenkins_code_coverage.sh
  • Loading branch information
Spencer authored and spalger committed Aug 19, 2021
1 parent 3786ee3 commit 4da7d98
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 115 deletions.
29 changes: 29 additions & 0 deletions .ci/ci_groups.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
root:
- ciGroup1
- ciGroup2
- ciGroup3
- ciGroup4
- ciGroup5
- ciGroup6
- ciGroup7
- ciGroup8
- ciGroup9
- ciGroup10
- ciGroup11
- ciGroup12

xpack:
- ciGroup1
- ciGroup2
- ciGroup3
- ciGroup4
- ciGroup5
- ciGroup6
- ciGroup7
- ciGroup8
- ciGroup9
- ciGroup10
- ciGroup11
- ciGroup12
- ciGroup13
- ciGroupDocker
41 changes: 0 additions & 41 deletions .ci/jobs.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const defaultRelativeToConfigPath = (path: string) => {

export const schema = Joi.object()
.keys({
rootTags: Joi.array().items(Joi.string()),
testFiles: Joi.array().items(Joi.string()),
testRunner: Joi.func(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function split(arr, fn) {
return [a, b];
}

export function decorateMochaUi(log, lifecycle, context, { isDockerGroup }) {
export function decorateMochaUi(log, lifecycle, context, { isDockerGroup, rootTags }) {
// incremented at the start of each suite, decremented after
// so that in each non-suite call we can know if we are within
// a suite, or that when a suite is defined it is within a suite
Expand Down Expand Up @@ -62,7 +62,13 @@ export function decorateMochaUi(log, lifecycle, context, { isDockerGroup }) {
});

const relativeFilePath = relative(REPO_ROOT, this.file);
this._tags = isDockerGroup ? ['ciGroupDocker', relativeFilePath] : [relativeFilePath];
this._tags = [
...(isDockerGroup ? ['ciGroupDocker', relativeFilePath] : [relativeFilePath]),
// we attach the "root tags" to all the child suites of the root suite, so that if they
// need to be excluded they can be removed from the root suite without removing the entire
// root suite
...(this.parent.root ? [...(rootTags ?? [])] : []),
];
this.suiteTag = relativeFilePath; // The tag that uniquely targets this suite/file
this.tags = (tags) => {
const newTags = Array.isArray(tags) ? tags : [tags];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const loadTestFiles = ({

const context = decorateMochaUi(log, lifecycle, global, {
isDockerGroup,
rootTags: config.get('rootTags'),
});
mocha.suite.emit('pre-require', context, path, mocha);

Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-test/src/functional_tests/lib/run_ftr.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export async function assertNoneExcluded({ configPath, options }) {
throw new CliError(`
${stats.excludedTests.length} tests in the ${configPath} config
are excluded when filtering by the tags run on CI. Make sure that all suites are
tagged with one of the following tags, or extend the list of tags in test/scripts/jenkins_xpack.sh
tagged with one of the following tags:
tags: ${JSON.stringify(options.suiteTags)}
${JSON.stringify(options.suiteTags)}
- ${stats.excludedTests.join('\n - ')}
`);
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-test/src/functional_tests/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const makeSuccessMessage = (options) => {
* @property {string} options.esFrom Optionally run from source instead of snapshot
*/
export async function runTests(options) {
if (!process.env.KBN_NP_PLUGINS_BUILT) {
if (!process.env.KBN_NP_PLUGINS_BUILT && !options.assertNoneExcluded) {
const log = options.createLogger();
log.warning('❗️❗️❗️');
log.warning('❗️❗️❗️');
Expand Down
2 changes: 1 addition & 1 deletion scripts/ensure_all_tests_in_ci_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
*/

require('../src/setup_node_env');
require('../src/dev/run_ensure_all_tests_in_ci_group');
require('../src/dev/ensure_all_tests_in_ci_group').runEnsureAllTestsInCiGroupsCli();
52 changes: 52 additions & 0 deletions src/dev/ensure_all_tests_in_ci_group.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import Path from 'path';
import Fs from 'fs/promises';

import execa from 'execa';
import { safeLoad } from 'js-yaml';

import { run, REPO_ROOT } from '@kbn/dev-utils';
import { schema } from '@kbn/config-schema';

const RELATIVE_JOBS_YAML_PATH = '.ci/ci_groups.yml';
const JOBS_YAML_PATH = Path.resolve(REPO_ROOT, RELATIVE_JOBS_YAML_PATH);
const SCHEMA = schema.object({
root: schema.arrayOf(schema.string()),
xpack: schema.arrayOf(schema.string()),
});

export function runEnsureAllTestsInCiGroupsCli() {
run(async ({ log }) => {
const { root, xpack } = SCHEMA.validate(safeLoad(await Fs.readFile(JOBS_YAML_PATH, 'utf-8')));

log.info(
'validating root tests directory contains all "root" ciGroups from',
RELATIVE_JOBS_YAML_PATH
);
await execa(process.execPath, [
'scripts/functional_tests',
...root.map((tag) => `--include-tag=${tag}`),
'--include-tag=runOutsideOfCiGroups',
'--assert-none-excluded',
]);

log.info(
'validating x-pack/tests directory contains all "xpack" ciGroups from',
RELATIVE_JOBS_YAML_PATH
);
await execa(process.execPath, [
'x-pack/scripts/functional_tests',
...xpack.map((tag) => `--include-tag=${tag}`),
'--assert-none-excluded',
]);

log.success('all tests are in a valid ciGroup');
});
}
50 changes: 0 additions & 50 deletions src/dev/run_ensure_all_tests_in_ci_group.js

This file was deleted.

1 change: 1 addition & 0 deletions test/api_integration/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default async function ({ readConfigFile }) {
const functionalConfig = await readConfigFile(require.resolve('../functional/config'));

return {
rootTags: ['runOutsideOfCiGroups'],
testFiles: [require.resolve('./apis')],
services,
servers: commonConfig.get('servers'),
Expand Down
1 change: 1 addition & 0 deletions test/examples/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default async function ({ readConfigFile }) {
);

return {
rootTags: ['runOutsideOfCiGroups'],
testFiles: [
require.resolve('./embeddables'),
require.resolve('./bfetch_explorer'),
Expand Down
1 change: 1 addition & 0 deletions test/interpreter_functional/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
);

return {
rootTags: ['runOutsideOfCiGroups'],
testFiles: [require.resolve('./test_suites/run_pipeline')],
services: functionalConfig.get('services'),
pageObjects: functionalConfig.get('pageObjects'),
Expand Down
1 change: 1 addition & 0 deletions test/plugin_functional/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
);

return {
rootTags: ['runOutsideOfCiGroups'],
testFiles: [
require.resolve('./test_suites/usage_collection'),
require.resolve('./test_suites/telemetry'),
Expand Down
19 changes: 1 addition & 18 deletions test/scripts/jenkins_build_kibana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,7 @@ fi
export KBN_NP_PLUGINS_BUILT=true

echo " -> Ensuring all functional tests are in a ciGroup"
node scripts/ensure_all_tests_in_ci_group;

echo " -> Ensuring all x-pack functional tests are in a ciGroup"
node x-pack/scripts/functional_tests --assert-none-excluded \
--include-tag ciGroup1 \
--include-tag ciGroup2 \
--include-tag ciGroup3 \
--include-tag ciGroup4 \
--include-tag ciGroup5 \
--include-tag ciGroup6 \
--include-tag ciGroup7 \
--include-tag ciGroup8 \
--include-tag ciGroup9 \
--include-tag ciGroup10 \
--include-tag ciGroup11 \
--include-tag ciGroup12 \
--include-tag ciGroup13 \
--include-tag ciGroupDocker
node scripts/ensure_all_tests_in_ci_group

echo " -> building and extracting default Kibana distributable for use in functional tests"
node scripts/build --debug
Expand Down

0 comments on commit 4da7d98

Please sign in to comment.