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 11, 2020
1 parent 52d044c commit 6d0e246
Show file tree
Hide file tree
Showing 32 changed files with 761 additions and 206 deletions.
9 changes: 6 additions & 3 deletions .ci/Jenkinsfile_coverage
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
}

Expand All @@ -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
Expand Up @@ -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
Expand Up @@ -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(
() => {},
Expand All @@ -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
Expand Up @@ -17,21 +17,27 @@
* under the License.
*/

import { createFailError } from '@kbn/dev-utils';
import { ES_HOST } from '../constants';
import { pretty, green } from '../utils';
import expect from '@kbn/expect';
import { enumeratePatterns } from '../team_assignment/enumerate_patterns';
import { resolve } from 'path';
import { ToolingLog } from '@kbn/dev-utils';

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

const node = ES_HOST;
const client = new Client({ node });
describe(`enumeratePatterns`, () => {
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', ['kibana-reporting']]])
);

export const update = (id) => (log) => async (body) => {
try {
await client.ingest.putPipeline({ id, body });
log.verbose(`### Ingestion Pipeline ID: ${green(id)}`);
log.verbose(`### Payload Partial: \n${body.slice(0, 600)}...`);
} catch (e) {
throw createFailError(`${pretty(e.meta)}`);
}
};
expect(
actual[0].includes(
'x-pack/plugins/reporting/server/browsers/extract/unzip.js kibana-reporting'
)
).to.be(true);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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 { tryPath } from '../team_assignment/enumeration_helpers';

describe(`enumeration helper fns`, () => {
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
Expand Up @@ -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`, () => {
Expand Down Expand Up @@ -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 6d0e246

Please sign in to comment.