mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[ftr] validate that suites are not in multiple ciGroups (#99398)
* [ftr] validate that suites are not in multiple ciGroups * remove unused import * include filename in error message * remove redundant ciGroup tags * fix more duplicate ciGroups Co-authored-by: spalger <spalger@users.noreply.github.com>
This commit is contained in:
parent
b46a90e8de
commit
61eb3f0685
17 changed files with 80 additions and 28 deletions
|
@ -13,6 +13,7 @@ import { REPO_ROOT } from '@kbn/utils';
|
|||
import { loadTestFiles } from './load_test_files';
|
||||
import { filterSuitesByTags } from './filter_suites_by_tags';
|
||||
import { MochaReporterProvider } from './reporter';
|
||||
import { validateCiGroupTags } from './validate_ci_group_tags';
|
||||
|
||||
/**
|
||||
* Instantiate mocha and load testfiles into it
|
||||
|
@ -45,6 +46,9 @@ export async function setupMocha(lifecycle, log, config, providers) {
|
|||
updateSnapshots: config.get('updateSnapshots'),
|
||||
});
|
||||
|
||||
// valiate that there aren't any tests in multiple ciGroups
|
||||
validateCiGroupTags(log, mocha);
|
||||
|
||||
// Each suite has a tag that is the path relative to the root of the repo
|
||||
// So we just need to take input paths, make them relative to the root, and use them as tags
|
||||
// Also, this is a separate filterSuitesByTags() call so that the test suites will be filtered first by
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* 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 { REPO_ROOT } from '@kbn/dev-utils';
|
||||
|
||||
/**
|
||||
* Traverse the suites configured and ensure that each suite has no more than one ciGroup assigned
|
||||
*
|
||||
* @param {ToolingLog} log
|
||||
* @param {Mocha} mocha
|
||||
*/
|
||||
export function validateCiGroupTags(log, mocha) {
|
||||
const tagCache = new Map();
|
||||
const getTags = (suite) => {
|
||||
const cached = tagCache.get(suite);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const allTags = [
|
||||
...new Set([...(suite.parent ? getTags(suite.parent) : []), ...(suite._tags ?? [])]),
|
||||
];
|
||||
tagCache.set(suite, allTags);
|
||||
return allTags;
|
||||
};
|
||||
|
||||
const getCiGroups = (suite) => {
|
||||
return getTags(suite).filter((t) => t.startsWith('ciGroup'));
|
||||
};
|
||||
|
||||
const getTitles = (suite) => {
|
||||
const all = suite.parent ? getTitles(suite.parent) : [];
|
||||
if (suite.title) {
|
||||
all.push(suite.title.trim());
|
||||
}
|
||||
return all;
|
||||
};
|
||||
|
||||
const suitesWithMultipleCiGroups = [];
|
||||
|
||||
const queue = [mocha.suite];
|
||||
while (queue.length) {
|
||||
const suite = queue.shift();
|
||||
if (getCiGroups(suite).length > 1) {
|
||||
suitesWithMultipleCiGroups.push(suite);
|
||||
} else {
|
||||
queue.push(...(suite.suites ?? []));
|
||||
}
|
||||
}
|
||||
|
||||
if (suitesWithMultipleCiGroups.length) {
|
||||
const list = suitesWithMultipleCiGroups
|
||||
.map((s) => {
|
||||
const groups = getCiGroups(s).join(', ');
|
||||
const title = getTitles(s).join(' > ') || '';
|
||||
const from = s.file ? ` (from: ${Path.relative(REPO_ROOT, s.file)})` : '';
|
||||
|
||||
return ` - ${groups}: ${title}${from}`;
|
||||
})
|
||||
.join('\n');
|
||||
|
||||
log.error(
|
||||
`${suitesWithMultipleCiGroups.length} suites found which are assigned to multiple ciGroups:\n${list}`
|
||||
);
|
||||
|
||||
throw new Error('some suites have mutliple ciGroup tags');
|
||||
}
|
||||
}
|
|
@ -9,8 +9,6 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('feature controls', function () {
|
||||
this.tags(['ciGroup8']);
|
||||
|
||||
loadTestFile(require.resolve('./api_keys_security'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('feature controls', function () {
|
||||
this.tags(['ciGroup8']);
|
||||
|
||||
loadTestFile(require.resolve('./ccr_security'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('feature controls', function () {
|
||||
this.tags(['ciGroup2']);
|
||||
|
||||
loadTestFile(require.resolve('./ilm_security'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('feature controls', function () {
|
||||
this.tags(['ciGroup2']);
|
||||
|
||||
loadTestFile(require.resolve('./index_management_security'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('feature controls', function () {
|
||||
this.tags(['ciGroup2']);
|
||||
|
||||
loadTestFile(require.resolve('./ingest_pipelines_security'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('feature controls', function () {
|
||||
this.tags(['ciGroup2']);
|
||||
|
||||
loadTestFile(require.resolve('./license_management_security'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('feature controls', function () {
|
||||
this.tags(['ciGroup2']);
|
||||
|
||||
loadTestFile(require.resolve('./remote_clusters_security'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('feature controls', function () {
|
||||
this.tags(['ciGroup2']);
|
||||
|
||||
loadTestFile(require.resolve('./transform_security'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
|
|||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('feature controls', function () {
|
||||
this.tags(['ciGroup2']);
|
||||
|
||||
loadTestFile(require.resolve('./upgrade_assistant_security'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ import { FtrProviderContext } from '../ftr_provider_context';
|
|||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('apps', function () {
|
||||
this.tags('ciGroup2');
|
||||
|
||||
loadTestFile(require.resolve('./ml'));
|
||||
loadTestFile(require.resolve('./transform'));
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
|
|||
const ml = getService('ml');
|
||||
|
||||
describe('machine learning basic license', function () {
|
||||
this.tags(['skipFirefox', 'mlqa']);
|
||||
this.tags(['ciGroup2', 'skipFirefox', 'mlqa']);
|
||||
|
||||
before(async () => {
|
||||
await ml.securityCommon.createMlRoles();
|
||||
|
|
|
@ -66,7 +66,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
];
|
||||
|
||||
describe('endpoint list', function () {
|
||||
this.tags('ciGroup7');
|
||||
const sleep = (ms = 100) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
describe('when initially navigating to page', () => {
|
||||
|
|
|
@ -13,8 +13,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
const testSubjects = getService('testSubjects');
|
||||
|
||||
describe('When in the Fleet application', function () {
|
||||
this.tags(['ciGroup7']);
|
||||
|
||||
describe('and on the Endpoint Integration details page', () => {
|
||||
beforeEach(async () => {
|
||||
await fleetIntegrations.navigateToIntegrationDetails(
|
||||
|
|
|
@ -22,8 +22,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
const policyTestResources = getService('policyTestResources');
|
||||
|
||||
describe('When on the Endpoint Policy Details Page', function () {
|
||||
this.tags(['ciGroup7']);
|
||||
|
||||
describe('with an invalid policy id', () => {
|
||||
it('should display an error', async () => {
|
||||
await pageObjects.policy.navigateToPolicyDetails('invalid-id');
|
||||
|
|
|
@ -13,8 +13,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const testSubjects = getService('testSubjects');
|
||||
|
||||
describe('When on the Trusted Apps list', function () {
|
||||
this.tags('ciGroup7');
|
||||
|
||||
before(async () => {
|
||||
await pageObjects.trustedApps.navigateToTrustedAppsList();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue