Skip to content

Commit

Permalink
[QA][Code Coverage] Coverage teams lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneseymour committed Sep 9, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9bc603e commit 9b64852
Showing 34 changed files with 15,061 additions and 198 deletions.
9 changes: 6 additions & 3 deletions .ci/Jenkinsfile_coverage
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ kibanaPipeline(timeoutMinutes: 240) {
workers.base(name: 'coverage-worker', size: 'l', ramDisk: false, bootstrapped: false) {
catchError {
kibanaCoverage.runTests()
kibanaTeamAssign.load('team_assignment', "### Upload Team Assignment JSON")
handleIngestion(TIME_STAMP)
}
handleFail()
@@ -30,7 +29,7 @@ def handleIngestion(timestamp) {
kibanaCoverage.collectVcsInfo("### Collect VCS Info")
kibanaCoverage.generateReports("### Merge coverage reports")
kibanaCoverage.uploadCombinedReports()
kibanaCoverage.ingest(env.JOB_NAME, BUILD_NUMBER, BUILD_URL, timestamp, previousSha, '### Ingest && Upload')
kibanaCoverage.ingest(env.JOB_NAME, BUILD_NUMBER, BUILD_URL, timestamp, previousSha, teamAssignmentsPath(), '### Ingest && Upload')
kibanaCoverage.uploadCoverageStaticSite(timestamp)
}

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

def handleFail() {
def buildStatus = buildUtils.getBuildStatus()
if(params.NOTIFY_ON_FAILURE && buildStatus != 'SUCCESS' && buildStatus != 'ABORTED' && buildStatus != 'UNSTABLE') {
if (params.NOTIFY_ON_FAILURE && buildStatus != 'SUCCESS' && buildStatus != 'ABORTED' && buildStatus != 'UNSTABLE') {
slackNotifications.sendFailedBuild(
channel: '#kibana-qa',
username: 'Kibana QA'
)
}
}

def teamAssignmentsPath() {
return 'src/dev/code_coverage/ingest_coverage/team_assignment/team_assignments.txt'
}

Original file line number Diff line number Diff line change
@@ -18,4 +18,4 @@
*/

require('../src/setup_node_env');
require('../src/dev/code_coverage/ingest_coverage/team_assignment').uploadTeamAssignmentJson();
require('../src/dev/code_coverage/ingest_coverage/team_assignment/').generateTeamAssignments();
16 changes: 15 additions & 1 deletion src/dev/code_coverage/ingest_coverage/__tests__/either.test.js
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ describe(`either datatype functions`, () => {
expect(sut.inspect()).to.be('Right(undefined)');
});
});
describe(`'fromNullable`, () => {
describe(`fromNullable`, () => {
it(`should continue processing if a truthy is calculated`, () => {
attempt({ detail: 'x' }).fold(
() => {},
@@ -64,4 +64,18 @@ describe(`either datatype functions`, () => {
attempt(false).fold(expectNull, () => {});
});
});
describe(`predicate fns`, () => {
it(`right.isRight() is true`, () => {
expect(Either.right('a').isRight()).to.be(true);
});
it(`right.isLeft() is false`, () => {
expect(Either.right('a').isLeft()).to.be(false);
});
it(`left.isLeft() is true`, () => {
expect(Either.left().isLeft()).to.be(true);
});
it(`left.isRight() is true`, () => {
expect(Either.left().isRight()).to.be(false);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import expect from '@kbn/expect';
import { enumeratePatterns } from '../team_assignment/enumerate_patterns';
import { resolve } from 'path';
import { ToolingLog } from '@kbn/dev-utils';

const ROOT = resolve(__dirname, '../../../../..');
const log = new ToolingLog({
level: 'info',
writeTo: process.stdout,
});

describe(`enumeratePatterns`, () => {
it(`should enumerate`, () => {
const res = enumeratePatterns(ROOT)(log)(patternsMap());
const actual = res[0][0];
expect(actual).to.eql(expected()[0][0]);
});
it(`should not throw an unhandled error on a file path that is a glob, that expands to nothing`, () => {
const absoluteRoot = '/Users/tre/development/projects/kibana';
expect(
enumeratePatterns(absoluteRoot)(log)(
new Map([
[
'src/legacy/core_plugins/kibana/public/home/*.ts',
{
coverageOwner: 'kibana-core-ui',
excludeFiles: [],
},
],
])
)
).to.eql('');
});
it(`should resolve x-pack/plugins/reporting/server/browsers/extract/unzip.js to kibana-reporting`, () => {
const actual = enumeratePatterns(ROOT)(log)(
new Map([
[
'x-pack/plugins/reporting',
{
coverageOwner: 'kibana-reporting',
excludeFiles: [],
},
],
])
);

expect(
actual[0].includes(
'x-pack/plugins/reporting/server/browsers/extract/unzip.js kibana-reporting'
)
).to.be(true);
});
});

function patternsMap() {
return new Map([
[
'src/dev/code_coverage',
{
coverageOwner: 'kibana-qa',
excludeFiles: [],
},
],
[
'vars/kibanaCoverage.groovy',
{
coverageOwner: 'kibana-qa',
excludeFiles: [],
},
],
[
'vars/kibanaTeamAssign.groovy',
{
coverageOwner: 'kibana-qa',
excludeFiles: [],
},
],
]);
}

function expected() {
return [
[
'src/dev/code_coverage/ingest_coverage/constants.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/either.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/index.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/ingest-coverage_wallaby.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/ingest.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/ingest_helpers.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/integration_tests/ingest_coverage.test.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/json_stream.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/matching.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/maybe.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/process.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/enumerate_patterns.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/enumeration_helpers.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/flush.ts kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/generate_assignments.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/generate_patterns.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/get_data.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/team_assignment/index.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/transforms.js kibana-qa',
'src/dev/code_coverage/ingest_coverage/utils.js kibana-qa',
'src/dev/code_coverage/nyc_config/nyc.functional.config.js kibana-qa',
'src/dev/code_coverage/nyc_config/nyc.jest.config.js kibana-qa',
],
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import expect from '@kbn/expect';
import { isExcluded, tryPath } from '../team_assignment/enumeration_helpers';

describe(`enumeration helper fns`, () => {
describe(`isExcluded`, () => {
it(`should exclude exclusions`, () => {
expect(
isExcluded('src/dev/code_coverage/nyc_config/nyc.jest.config.js', [
'src/dev/code_coverage/nyc_config',
])
).to.be(true);
});
});
describe(`tryPath`, () => {
describe(`w/o glob file paths`, () => {
it(`should return a right on an existing path`, () => {
const aPath = 'src/dev/code_coverage/ingest_coverage/ingest.js';
const actual = tryPath(aPath);
expect(actual.isRight()).to.be(true);
});
it(`should return a left on a non existing path`, () => {
const aPath = 'src/dev/code_coverage/ingest_coverage/does_not_exist.js';
const actual = tryPath(aPath);
expect(actual.isLeft()).to.be(true);
});
});
describe(`with glob file paths`, () => {
it(`should not error when the glob expands to nothing, but instead return a Left`, () => {
const aPath = 'src/legacy/core_plugins/kibana/public/home/*.ts';
const actual = tryPath(aPath);
expect(actual.isLeft()).to.be(true);
});
it(`should return a right on a glob that does indeed expand`, () => {
const aPath = 'src/dev/code_coverage/ingest_coverage/*.js';
const actual = tryPath(aPath);
expect(actual.isRight()).to.be(true);
});
});
});
});
Original file line number Diff line number Diff line change
@@ -18,13 +18,8 @@
*/

import expect from '@kbn/expect';
import { maybeTeamAssign, whichIndex } from '../ingest_helpers';
import {
TOTALS_INDEX,
RESEARCH_TOTALS_INDEX,
RESEARCH_COVERAGE_INDEX,
// COVERAGE_INDEX,
} from '../constants';
import { whichIndex } from '../ingest_helpers';
import { TOTALS_INDEX, RESEARCH_TOTALS_INDEX, RESEARCH_COVERAGE_INDEX } from '../constants';

describe(`Ingest Helper fns`, () => {
describe(`whichIndex`, () => {
@@ -56,20 +51,4 @@ describe(`Ingest Helper fns`, () => {
});
});
});
describe(`maybeTeamAssign`, () => {
describe(`against a coverage index`, () => {
it(`should have the pipeline prop`, () => {
const actual = maybeTeamAssign(true, { a: 'blah' });
expect(actual).to.have.property('pipeline');
});
});
describe(`against a totals index`, () => {
describe(`for "prod"`, () => {
it(`should not have the pipeline prop`, () => {
const actual = maybeTeamAssign(false, { b: 'blah' });
expect(actual).not.to.have.property('pipeline');
});
});
});
});
});

This file was deleted.

Loading

0 comments on commit 9b64852

Please sign in to comment.