Skip to content

Commit 636f4d3

Browse files
committed
[QA][Code Coverage] Coverage teams lookup
1 parent 52d044c commit 636f4d3

32 files changed

+768
-205
lines changed

.ci/Jenkinsfile_coverage

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ kibanaPipeline(timeoutMinutes: 240) {
1313
workers.base(name: 'coverage-worker', size: 'l', ramDisk: false, bootstrapped: false) {
1414
catchError {
1515
kibanaCoverage.runTests()
16-
kibanaTeamAssign.load('team_assignment', "### Upload Team Assignment JSON")
1716
handleIngestion(TIME_STAMP)
1817
}
1918
handleFail()
@@ -30,7 +29,7 @@ def handleIngestion(timestamp) {
3029
kibanaCoverage.collectVcsInfo("### Collect VCS Info")
3130
kibanaCoverage.generateReports("### Merge coverage reports")
3231
kibanaCoverage.uploadCombinedReports()
33-
kibanaCoverage.ingest(env.JOB_NAME, BUILD_NUMBER, BUILD_URL, timestamp, previousSha, '### Ingest && Upload')
32+
kibanaCoverage.ingest(env.JOB_NAME, BUILD_NUMBER, BUILD_URL, timestamp, previousSha, teamAssignmentsPath(), '### Ingest && Upload')
3433
kibanaCoverage.uploadCoverageStaticSite(timestamp)
3534
}
3635

@@ -42,11 +41,15 @@ def handlePreviousSha() {
4241

4342
def handleFail() {
4443
def buildStatus = buildUtils.getBuildStatus()
45-
if(params.NOTIFY_ON_FAILURE && buildStatus != 'SUCCESS' && buildStatus != 'ABORTED' && buildStatus != 'UNSTABLE') {
44+
if (params.NOTIFY_ON_FAILURE && buildStatus != 'SUCCESS' && buildStatus != 'ABORTED' && buildStatus != 'UNSTABLE') {
4645
slackNotifications.sendFailedBuild(
4746
channel: '#kibana-qa',
4847
username: 'Kibana QA'
4948
)
5049
}
5150
}
5251

52+
def teamAssignmentsPath() {
53+
return 'src/dev/code_coverage/ingest_coverage/team_assignment/team_assignments.txt'
54+
}
55+

scripts/load_team_assignment.js renamed to scripts/generate_team_assignments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
*/
1919

2020
require('../src/setup_node_env');
21-
require('../src/dev/code_coverage/ingest_coverage/team_assignment').uploadTeamAssignmentJson();
21+
require('../src/dev/code_coverage/ingest_coverage/team_assignment/').generateTeamAssignments();

src/dev/code_coverage/ingest_coverage/__tests__/either.test.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe(`either datatype functions`, () => {
5353
expect(sut.inspect()).to.be('Right(undefined)');
5454
});
5555
});
56-
describe(`'fromNullable`, () => {
56+
describe(`fromNullable`, () => {
5757
it(`should continue processing if a truthy is calculated`, () => {
5858
attempt({ detail: 'x' }).fold(
5959
() => {},
@@ -64,4 +64,18 @@ describe(`either datatype functions`, () => {
6464
attempt(false).fold(expectNull, () => {});
6565
});
6666
});
67+
describe(`predicate fns`, () => {
68+
it(`right.isRight() is true`, () => {
69+
expect(Either.right('a').isRight()).to.be(true);
70+
});
71+
it(`right.isLeft() is false`, () => {
72+
expect(Either.right('a').isLeft()).to.be(false);
73+
});
74+
it(`left.isLeft() is true`, () => {
75+
expect(Either.left().isLeft()).to.be(true);
76+
});
77+
it(`left.isRight() is true`, () => {
78+
expect(Either.left().isRight()).to.be(false);
79+
});
80+
});
6781
});
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import expect from '@kbn/expect';
21+
import { enumeratePatterns } from '../team_assignment/enumerate_patterns';
22+
import { resolve } from 'path';
23+
import { ToolingLog } from '@kbn/dev-utils';
24+
25+
const ROOT = resolve(__dirname, '../../../../..');
26+
const log = new ToolingLog({
27+
level: 'info',
28+
writeTo: process.stdout,
29+
});
30+
31+
describe(`enumeratePatterns`, () => {
32+
it(`should not throw an unhandled error on a file path that is a glob, that expands to nothing`, () => {
33+
const absoluteRoot = '/Users/tre/development/projects/kibana';
34+
expect(
35+
enumeratePatterns(absoluteRoot)(log)(
36+
new Map([['src/legacy/core_plugins/kibana/public/home/*.ts', ['kibana-core-ui']]])
37+
)
38+
).to.eql('');
39+
});
40+
it(`should resolve x-pack/plugins/reporting/server/browsers/extract/unzip.js to kibana-reporting`, () => {
41+
const actual = enumeratePatterns(ROOT)(log)(
42+
new Map([['x-pack/plugins/reporting', ['kibana-reporting']]])
43+
);
44+
45+
expect(
46+
actual[0].includes(
47+
'x-pack/plugins/reporting/server/browsers/extract/unzip.js kibana-reporting'
48+
)
49+
).to.be(true);
50+
});
51+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import expect from '@kbn/expect';
21+
import { tryPath } from '../team_assignment/enumeration_helpers';
22+
23+
describe(`enumeration helper fns`, () => {
24+
describe(`tryPath`, () => {
25+
describe(`w/o glob file paths`, () => {
26+
it(`should return a right on an existing path`, () => {
27+
const aPath = 'src/dev/code_coverage/ingest_coverage/ingest.js';
28+
const actual = tryPath(aPath);
29+
expect(actual.isRight()).to.be(true);
30+
});
31+
it(`should return a left on a non existing path`, () => {
32+
const aPath = 'src/dev/code_coverage/ingest_coverage/does_not_exist.js';
33+
const actual = tryPath(aPath);
34+
expect(actual.isLeft()).to.be(true);
35+
});
36+
});
37+
describe(`with glob file paths`, () => {
38+
it(`should not error when the glob expands to nothing, but instead return a Left`, () => {
39+
const aPath = 'src/legacy/core_plugins/kibana/public/home/*.ts';
40+
const actual = tryPath(aPath);
41+
expect(actual.isLeft()).to.be(true);
42+
});
43+
it(`should return a right on a glob that does indeed expand`, () => {
44+
const aPath = 'src/dev/code_coverage/ingest_coverage/*.js';
45+
const actual = tryPath(aPath);
46+
expect(actual.isRight()).to.be(true);
47+
});
48+
});
49+
});
50+
});

src/dev/code_coverage/ingest_coverage/__tests__/ingest_helpers.test.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@
1818
*/
1919

2020
import expect from '@kbn/expect';
21-
import { maybeTeamAssign, whichIndex } from '../ingest_helpers';
22-
import {
23-
TOTALS_INDEX,
24-
RESEARCH_TOTALS_INDEX,
25-
RESEARCH_COVERAGE_INDEX,
26-
// COVERAGE_INDEX,
27-
} from '../constants';
21+
import { whichIndex } from '../ingest_helpers';
22+
import { TOTALS_INDEX, RESEARCH_TOTALS_INDEX, RESEARCH_COVERAGE_INDEX } from '../constants';
2823

2924
describe(`Ingest Helper fns`, () => {
3025
describe(`whichIndex`, () => {
@@ -56,20 +51,4 @@ describe(`Ingest Helper fns`, () => {
5651
});
5752
});
5853
});
59-
describe(`maybeTeamAssign`, () => {
60-
describe(`against a coverage index`, () => {
61-
it(`should have the pipeline prop`, () => {
62-
const actual = maybeTeamAssign(true, { a: 'blah' });
63-
expect(actual).to.have.property('pipeline');
64-
});
65-
});
66-
describe(`against a totals index`, () => {
67-
describe(`for "prod"`, () => {
68-
it(`should not have the pipeline prop`, () => {
69-
const actual = maybeTeamAssign(false, { b: 'blah' });
70-
expect(actual).not.to.have.property('pipeline');
71-
});
72-
});
73-
});
74-
});
7554
});

src/dev/code_coverage/ingest_coverage/__tests__/mocks/team_assign_mock.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)