-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[QA] [Code Coverage] Add Three Dot Compare Url (#70525)
- Loading branch information
1 parent
0b6674e
commit 12460b4
Showing
8 changed files
with
268 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ const env = { | |
ES_HOST: 'https://super:[email protected]:9243', | ||
NODE_ENV: 'integration_test', | ||
COVERAGE_INGESTION_KIBANA_ROOT: '/var/lib/jenkins/workspace/elastic+kibana+code-coverage/kibana', | ||
FETCHED_PREVIOUS: 'FAKE_PREVIOUS_SHA', | ||
}; | ||
|
||
describe('Ingesting coverage', () => { | ||
|
@@ -68,31 +69,64 @@ describe('Ingesting coverage', () => { | |
expect(folderStructure.test(actualUrl)).ok(); | ||
}); | ||
}); | ||
|
||
describe(`vcsInfo`, () => { | ||
let stdOutWithVcsInfo = ''; | ||
describe(`without a commit msg in the vcs info file`, () => { | ||
let vcsInfo; | ||
const args = [ | ||
'scripts/ingest_coverage.js', | ||
'--verbose', | ||
'--vcsInfoPath', | ||
'src/dev/code_coverage/ingest_coverage/integration_tests/mocks/VCS_INFO_missing_commit_msg.txt', | ||
'--path', | ||
]; | ||
|
||
beforeAll(async () => { | ||
const args = [ | ||
'scripts/ingest_coverage.js', | ||
'--verbose', | ||
'--vcsInfoPath', | ||
'src/dev/code_coverage/ingest_coverage/integration_tests/mocks/VCS_INFO_missing_commit_msg.txt', | ||
'--path', | ||
]; | ||
const opts = [...args, resolved]; | ||
const { stdout } = await execa(process.execPath, opts, { cwd: ROOT_DIR, env }); | ||
vcsInfo = stdout; | ||
stdOutWithVcsInfo = stdout; | ||
}); | ||
|
||
it(`should be an obj w/o a commit msg`, () => { | ||
const commitMsgRE = /"commitMsg"/; | ||
expect(commitMsgRE.test(vcsInfo)).to.not.be.ok(); | ||
expect(commitMsgRE.test(stdOutWithVcsInfo)).to.not.be.ok(); | ||
}); | ||
}); | ||
describe(`including previous sha`, () => { | ||
let stdOutWithPrevious = ''; | ||
beforeAll(async () => { | ||
const opts = [...verboseArgs, resolved]; | ||
const { stdout } = await execa(process.execPath, opts, { cwd: ROOT_DIR, env }); | ||
stdOutWithPrevious = stdout; | ||
}); | ||
|
||
it(`should have a vcsCompareUrl`, () => { | ||
const previousCompareUrlRe = /vcsCompareUrl.+\s*.*https.+compare\/FAKE_PREVIOUS_SHA\.\.\.f07b34f6206/; | ||
expect(previousCompareUrlRe.test(stdOutWithPrevious)).to.be.ok(); | ||
}); | ||
}); | ||
describe(`with a commit msg in the vcs info file`, () => { | ||
beforeAll(async () => { | ||
const args = [ | ||
'scripts/ingest_coverage.js', | ||
'--verbose', | ||
'--vcsInfoPath', | ||
'src/dev/code_coverage/ingest_coverage/integration_tests/mocks/VCS_INFO.txt', | ||
'--path', | ||
]; | ||
const opts = [...args, resolved]; | ||
const { stdout } = await execa(process.execPath, opts, { cwd: ROOT_DIR, env }); | ||
stdOutWithVcsInfo = stdout; | ||
}); | ||
|
||
it(`should be an obj w/ a commit msg`, () => { | ||
const commitMsgRE = /commitMsg/; | ||
expect(commitMsgRE.test(stdOutWithVcsInfo)).to.be.ok(); | ||
}); | ||
}); | ||
}); | ||
describe(`team assignment`, () => { | ||
let shouldNotHavePipelineOut = ''; | ||
let shouldIndeedHavePipelineOut = ''; | ||
|
||
const args = [ | ||
'scripts/ingest_coverage.js', | ||
'--verbose', | ||
|
@@ -101,26 +135,30 @@ describe('Ingesting coverage', () => { | |
'--path', | ||
]; | ||
|
||
it(`should not occur when going to the totals index`, async () => { | ||
const teamAssignRE = /"pipeline":/; | ||
const shouldNotHavePipelineOut = await prokJustTotalOrNot(true, args); | ||
const teamAssignRE = /pipeline:/; | ||
|
||
beforeAll(async () => { | ||
const summaryPath = 'jest-combined/coverage-summary-just-total.json'; | ||
const resolved = resolve(MOCKS_DIR, summaryPath); | ||
const opts = [...args, resolved]; | ||
const { stdout } = await execa(process.execPath, opts, { cwd: ROOT_DIR, env }); | ||
shouldNotHavePipelineOut = stdout; | ||
}); | ||
beforeAll(async () => { | ||
const summaryPath = 'jest-combined/coverage-summary-manual-mix.json'; | ||
const resolved = resolve(MOCKS_DIR, summaryPath); | ||
const opts = [...args, resolved]; | ||
const { stdout } = await execa(process.execPath, opts, { cwd: ROOT_DIR, env }); | ||
shouldIndeedHavePipelineOut = stdout; | ||
}); | ||
|
||
it(`should not occur when going to the totals index`, () => { | ||
const actual = teamAssignRE.test(shouldNotHavePipelineOut); | ||
expect(actual).to.not.be.ok(); | ||
}); | ||
it(`should indeed occur when going to the coverage index`, async () => { | ||
const shouldIndeedHavePipelineOut = await prokJustTotalOrNot(false, args); | ||
const onlyForTestingRe = /ingest-pipe=>team_assignment/; | ||
const actual = onlyForTestingRe.test(shouldIndeedHavePipelineOut); | ||
it(`should indeed occur when going to the coverage index`, () => { | ||
const actual = /ingest-pipe=>team_assignment/.test(shouldIndeedHavePipelineOut); | ||
expect(actual).to.be.ok(); | ||
}); | ||
}); | ||
}); | ||
async function prokJustTotalOrNot(isTotal, args) { | ||
const justTotalPath = 'jest-combined/coverage-summary-just-total.json'; | ||
const notJustTotalPath = 'jest-combined/coverage-summary-manual-mix.json'; | ||
|
||
const resolved = resolve(MOCKS_DIR, isTotal ? justTotalPath : notJustTotalPath); | ||
const opts = [...args, resolved]; | ||
const { stdout } = await execa(process.execPath, opts, { cwd: ROOT_DIR, env }); | ||
return stdout; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/* eslint new-cap: 0 */ | ||
/* eslint no-unused-vars: 0 */ | ||
|
||
/** | ||
* Just monad used for valid values | ||
*/ | ||
export function Just(x) { | ||
return { | ||
value: () => x, | ||
map: (f) => Maybe.of(f(x)), | ||
isJust: () => true, | ||
inspect: () => `Just(${x})`, | ||
}; | ||
} | ||
Just.of = function of(x) { | ||
return Just(x); | ||
}; | ||
export function just(x) { | ||
return Just.of(x); | ||
} | ||
|
||
/** | ||
* Maybe monad. | ||
* Maybe.fromNullable` lifts an `x` into either a `Just` | ||
* or a `Nothing` typeclass. | ||
*/ | ||
export function Maybe(x) { | ||
return { | ||
chain: (f) => f(x), | ||
map: (f) => Maybe(f(x)), | ||
inspect: () => `Maybe(${x})`, | ||
nothing: () => Nothing(), | ||
isNothing: () => false, | ||
isJust: () => false, | ||
}; | ||
} | ||
Maybe.of = function of(x) { | ||
return just(x); | ||
}; | ||
|
||
export function maybe(x) { | ||
return Maybe.of(x); | ||
} | ||
export function fromNullable(x) { | ||
return x !== null && x !== undefined && x !== false && x !== 'undefined' ? just(x) : nothing(); | ||
} | ||
|
||
/** | ||
* Nothing wraps undefined or null values and prevents errors | ||
* that otherwise occur when mapping unexpected undefined or null | ||
* values | ||
*/ | ||
export function Nothing() { | ||
return { | ||
value: () => { | ||
throw new TypeError(`Nothing algebraic data type returns...no value :)`); | ||
}, | ||
map: (f) => {}, | ||
isNothing: () => true, | ||
inspect: () => `[Nothing]`, | ||
}; | ||
} | ||
export function nothing() { | ||
return Nothing(); | ||
} |
Oops, something went wrong.