Skip to content

Commit

Permalink
Revert "[ci/flaky] support triggering a with config via the env (#121215
Browse files Browse the repository at this point in the history
)"

This reverts commit 3f321d1.
  • Loading branch information
jbudz committed Dec 16, 2021
1 parent faf5ae2 commit d6dba9e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 118 deletions.
34 changes: 0 additions & 34 deletions .buildkite/pipelines/flaky_tests/groups.json

This file was deleted.

31 changes: 17 additions & 14 deletions .buildkite/pipelines/flaky_tests/pipeline.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
const groups = /** @type {Array<{key: string, name: string, ciGroups: number }>} */(
require('./groups.json').groups
)

const stepInput = (key, nameOfSuite) => {
return {
key: `ftsr-suite/${key}`,
Expand All @@ -11,31 +7,38 @@ const stepInput = (key, nameOfSuite) => {
};
};

const OSS_CI_GROUPS = 12;
const XPACK_CI_GROUPS = 27;

const inputs = [
{
key: 'ftsr-override-count',
text: 'Override for all suites',
default: '0',
default: 0,
required: true,
},
];

for (const group of groups) {
if (!group.ciGroups) {
inputs.push(stepInput(group.key, group.name))
} else {
for (let i = 1; i <= group.ciGroups; i++) {
inputs.push(stepInput(`${group.key}/${i}`, `${group.name} ${i}`))
}
}
for (let i = 1; i <= OSS_CI_GROUPS; i++) {
inputs.push(stepInput(`oss/cigroup/${i}`, `OSS CI Group ${i}`));
}

inputs.push(stepInput(`oss/firefox`, 'OSS Firefox'));
inputs.push(stepInput(`oss/accessibility`, 'OSS Accessibility'));

for (let i = 1; i <= XPACK_CI_GROUPS; i++) {
inputs.push(stepInput(`xpack/cigroup/${i}`, `Default CI Group ${i}`));
}

inputs.push(stepInput(`xpack/cigroup/Docker`, 'Default CI Group Docker'));
inputs.push(stepInput(`xpack/firefox`, 'Default Firefox'));
inputs.push(stepInput(`xpack/accessibility`, 'Default Accessibility'));

const pipeline = {
steps: [
{
input: 'Number of Runs - Click Me',
fields: inputs,
if: `build.env('KIBANA_FLAKY_TEST_RUNNER_CONFIG') == null`
},
{
wait: '~',
Expand Down
92 changes: 22 additions & 70 deletions .buildkite/pipelines/flaky_tests/runner.js
Original file line number Diff line number Diff line change
@@ -1,85 +1,37 @@
const { execSync } = require('child_process');

const concurrency = 25;
const defaultCount = concurrency * 2;
const initialJobs = 3;

function getTestSuitesFromMetadata() {
const keys = execSync('buildkite-agent meta-data keys')
.toString()
.split('\n')
.filter((k) => k.startsWith('ftsr-suite/'));

const overrideCount = execSync(`buildkite-agent meta-data get 'ftsr-override-count'`).toString().trim();

const testSuites = [];
for (const key of keys) {
if (!key) {
continue;
}
const keys = execSync('buildkite-agent meta-data keys')
.toString()
.split('\n')
.filter((k) => k.startsWith('ftsr-suite/'));

const value =
overrideCount || execSync(`buildkite-agent meta-data get '${key}'`).toString().trim();
const overrideCount = parseInt(
execSync(`buildkite-agent meta-data get 'ftsr-override-count'`).toString().trim()
);

const count = value === '' ? defaultCount : parseInt(value);
totalJobs += count;

testSuites.push({
key: key.replace('ftsr-suite/', ''),
count: count,
});
}

return testSuites
}
const concurrency = 25;
const initialJobs = 3;

function getTestSuitesFromJson(json) {
const fail = (errorMsg) => {
console.error('+++ Invalid test config provided')
console.error(`${errorMsg}: ${json}`);
process.exit(1);
}
let totalJobs = initialJobs;

let parsed;
try {
parsed = JSON.parse(json)
} catch (error) {
fail(`JSON test config did not parse correctly`)
const testSuites = [];
for (const key of keys) {
if (!key) {
continue;
}

if (!Array.isArray(parsed)) {
fail(`JSON test config must be an array`)
}
const value =
overrideCount || execSync(`buildkite-agent meta-data get '${key}'`).toString().trim();

/** @type {Array<{ key: string, count: number }>} */
const testSuites = []
for (const item of parsed) {
if (typeof item !== 'object' || item === null) {
fail(`testSuites must be objects`)
}
const key = item.key
if (typeof key !== 'string') {
fail(`testSuite.key must be a string`)
}
const count = item.count;
if (typeof count !== 'number') {
fail(`testSuite.count must be a number`)
}
testSuites.push({
key,
count,
})
}
const count = value === '' ? defaultCount : parseInt(value);
totalJobs += count;

return testSuites
testSuites.push({
key: key.replace('ftsr-suite/', ''),
count: count,
});
}

const testSuites = process.env.KIBANA_FLAKY_TEST_RUNNER_CONFIG
? getTestSuitesFromJson(process.env.KIBANA_FLAKY_TEST_RUNNER_CONFIG)
: getTestSuitesFromMetadata();

let totalJobs = testSuites.reduce((acc, t) => acc + t.count, initialJobs);

if (totalJobs > 500) {
console.error('+++ Too many tests');
console.error(
Expand Down

0 comments on commit d6dba9e

Please sign in to comment.