mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[ftr] auto assign ciGroupDocker to suites with dockerServers (#99393)
Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
d5ebbac4f7
commit
21c54d38c3
6 changed files with 34 additions and 10 deletions
|
@ -12,7 +12,16 @@ import { createAssignmentProxy } from './assignment_proxy';
|
|||
import { wrapFunction } from './wrap_function';
|
||||
import { wrapRunnableArgs } from './wrap_runnable_args';
|
||||
|
||||
export function decorateMochaUi(lifecycle, context) {
|
||||
function split(arr, fn) {
|
||||
const a = [];
|
||||
const b = [];
|
||||
for (const i of arr) {
|
||||
(fn(i) ? a : b).push(i);
|
||||
}
|
||||
return [a, b];
|
||||
}
|
||||
|
||||
export function decorateMochaUi(log, lifecycle, context, { isDockerGroup }) {
|
||||
// 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
|
||||
|
@ -52,13 +61,23 @@ export function decorateMochaUi(lifecycle, context) {
|
|||
await lifecycle.beforeTestSuite.trigger(this);
|
||||
});
|
||||
|
||||
this.tags = (tags) => {
|
||||
this._tags = [].concat(this._tags || [], tags);
|
||||
};
|
||||
|
||||
const relativeFilePath = relative(REPO_ROOT, this.file);
|
||||
this.tags(relativeFilePath);
|
||||
this._tags = isDockerGroup ? ['ciGroupDocker', relativeFilePath] : [relativeFilePath];
|
||||
this.suiteTag = relativeFilePath; // The tag that uniquely targets this suite/file
|
||||
this.tags = (tags) => {
|
||||
const newTags = Array.isArray(tags) ? tags : [tags];
|
||||
const [tagsToAdd, tagsToIgnore] = split(newTags, (t) =>
|
||||
!isDockerGroup ? true : !t.startsWith('ciGroup')
|
||||
);
|
||||
|
||||
if (tagsToIgnore.length) {
|
||||
log.warning(
|
||||
`ignoring ciGroup tags because test is being run by a config using 'dockerServers', tags: ${tagsToIgnore}`
|
||||
);
|
||||
}
|
||||
|
||||
this._tags = [...this._tags, ...tagsToAdd];
|
||||
};
|
||||
|
||||
provider.call(this);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import { decorateSnapshotUi } from '../snapshots/decorate_snapshot_ui';
|
|||
*
|
||||
* @param {Mocha} mocha
|
||||
* @param {ToolingLog} log
|
||||
* @param {Config} config
|
||||
* @param {ProviderCollection} providers
|
||||
* @param {String} path
|
||||
* @return {undefined} - mutates mocha, no return value
|
||||
|
@ -24,12 +25,16 @@ import { decorateSnapshotUi } from '../snapshots/decorate_snapshot_ui';
|
|||
export const loadTestFiles = ({
|
||||
mocha,
|
||||
log,
|
||||
config,
|
||||
lifecycle,
|
||||
providers,
|
||||
paths,
|
||||
updateBaselines,
|
||||
updateSnapshots,
|
||||
}) => {
|
||||
const dockerServers = config.get('dockerServers');
|
||||
const isDockerGroup = dockerServers && Object.keys(dockerServers).length;
|
||||
|
||||
decorateSnapshotUi({ lifecycle, updateSnapshots, isCi: !!process.env.CI });
|
||||
|
||||
const innerLoadTestFile = (path) => {
|
||||
|
@ -55,7 +60,9 @@ export const loadTestFiles = ({
|
|||
loadTracer(provider, `testProvider[${path}]`, () => {
|
||||
// mocha.suite hocus-pocus comes from: https://git.io/vDnXO
|
||||
|
||||
const context = decorateMochaUi(lifecycle, global);
|
||||
const context = decorateMochaUi(log, lifecycle, global, {
|
||||
isDockerGroup,
|
||||
});
|
||||
mocha.suite.emit('pre-require', context, path, mocha);
|
||||
|
||||
const returnVal = provider({
|
||||
|
|
|
@ -39,6 +39,7 @@ export async function setupMocha(lifecycle, log, config, providers) {
|
|||
loadTestFiles({
|
||||
mocha,
|
||||
log,
|
||||
config,
|
||||
lifecycle,
|
||||
providers,
|
||||
paths: config.get('testFiles'),
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
export default function ({ loadTestFile }) {
|
||||
describe('Fleet Endpoints', function () {
|
||||
this.tags('ciGroupDocker');
|
||||
// EPM
|
||||
loadTestFile(require.resolve('./epm/index'));
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ export default function (providerContext: FtrProviderContext) {
|
|||
const { loadTestFile, getService } = providerContext;
|
||||
|
||||
describe('endpoint', function () {
|
||||
this.tags('ciGroupDocker');
|
||||
const ingestManager = getService('ingestManager');
|
||||
const log = getService('log');
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ export default function endpointAPIIntegrationTests(providerContext: FtrProvider
|
|||
describe('Endpoint plugin', function () {
|
||||
const ingestManager = getService('ingestManager');
|
||||
|
||||
this.tags('ciGroupDocker');
|
||||
const log = getService('log');
|
||||
|
||||
if (!isRegistryEnabled()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue