Skip to content

Commit c83c085

Browse files
Merge branch 'master' into chore/bump-styled-components-deps
2 parents 6a04ca4 + 42d21bc commit c83c085

File tree

115 files changed

+1398
-27399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1398
-27399
lines changed

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

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

2020
import expect from '@kbn/expect';
21-
import { ciRunUrl } from '../transforms';
21+
import { ciRunUrl, coveredFilePath, itemizeVcs } from '../transforms';
2222

2323
describe(`Transform fn`, () => {
2424
describe(`ciRunUrl`, () => {
@@ -31,4 +31,32 @@ describe(`Transform fn`, () => {
3131
expect(ciRunUrl({ a: 'a' })).not.to.have.property('ciRunUrl');
3232
});
3333
});
34+
describe(`coveredFilePath`, () => {
35+
it(`should remove the jenkins workspace path`, () => {
36+
const obj = {
37+
staticSiteUrl:
38+
'/var/lib/jenkins/workspace/elastic+kibana+code-coverage/kibana/x-pack/legacy/plugins/reporting/server/browsers/extract/unzip.js',
39+
COVERAGE_INGESTION_KIBANA_ROOT:
40+
'/var/lib/jenkins/workspace/elastic+kibana+code-coverage/kibana',
41+
};
42+
expect(coveredFilePath(obj)).to.have.property(
43+
'coveredFilePath',
44+
'x-pack/legacy/plugins/reporting/server/browsers/extract/unzip.js'
45+
);
46+
});
47+
});
48+
describe(`itemizeVcs`, () => {
49+
it(`should return a sha url`, () => {
50+
const vcsInfo = [
51+
'origin/ingest-code-coverage',
52+
'f07b34f6206',
53+
`Tre' Seymour`,
54+
`Lorem :) ipsum Tre' λ dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`,
55+
];
56+
expect(itemizeVcs(vcsInfo)({}).vcs).to.have.property(
57+
'vcsUrl',
58+
`https://github.com/elastic/kibana/commit/${vcsInfo[1]}`
59+
);
60+
});
61+
});
3462
});

src/dev/code_coverage/ingest_coverage/constants.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@
1717
* under the License.
1818
*/
1919

20-
export const STATIC_SITE_URL_PROP_NAME = 'staticSiteUrl';
2120
export const COVERAGE_INDEX = process.env.COVERAGE_INDEX || 'kibana_code_coverage';
2221
export const TOTALS_INDEX = process.env.TOTALS_INDEX || `kibana_total_code_coverage`;

src/dev/code_coverage/ingest_coverage/ingest.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
const { Client } = require('@elastic/elasticsearch');
2121
import { createFailError } from '@kbn/dev-utils';
2222
import chalk from 'chalk';
23-
import { green, always } from './utils';
23+
import { green, always, pretty } from './utils';
2424
import { fromNullable } from './either';
2525
import { COVERAGE_INDEX, TOTALS_INDEX } from './constants';
2626

@@ -98,6 +98,3 @@ function color(whichColor) {
9898
return chalk[whichColor].bgWhiteBright(x);
9999
};
100100
}
101-
function pretty(x) {
102-
return JSON.stringify(x, null, 2);
103-
}

src/dev/code_coverage/ingest_coverage/integration_tests/ingest_coverage.test.js

Lines changed: 29 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
* under the License.
1818
*/
1919

20-
import expect from '@kbn/expect';
2120
import { spawn } from 'child_process';
2221
import { resolve } from 'path';
2322
import { green, always } from '../utils';
2423

25-
import { STATIC_SITE_URL_PROP_NAME, COVERAGE_INDEX } from '../constants';
26-
2724
const ROOT_DIR = resolve(__dirname, '../../../../..');
2825
const MOCKS_DIR = resolve(__dirname, './mocks');
2926
const staticSiteUrlRegexes = {
@@ -40,110 +37,43 @@ const env = {
4037
NODE_ENV: 'integration_test',
4138
COVERAGE_INGESTION_KIBANA_ROOT: '/var/lib/jenkins/workspace/elastic+kibana+code-coverage/kibana',
4239
};
43-
const includesSiteUrlPredicate = x => x.includes(STATIC_SITE_URL_PROP_NAME);
40+
const includesSiteUrlPredicate = x => x.includes('staticSiteUrl');
4441
const siteUrlLines = specificLinesOnly(includesSiteUrlPredicate);
4542
const splitByNewLine = x => x.split('\n');
4643
const siteUrlsSplitByNewLine = siteUrlLines(splitByNewLine);
4744
const siteUrlsSplitByNewLineWithoutBlanks = siteUrlsSplitByNewLine(notBlankLines);
48-
49-
describe('Ingesting Coverage to Cluster', () => {
50-
const verboseArgs = [
51-
'scripts/ingest_coverage.js',
52-
'--verbose',
53-
'--vcsInfoPath',
54-
'src/dev/code_coverage/ingest_coverage/integration_tests/mocks/VCS_INFO.txt',
55-
'--path',
56-
];
57-
58-
const noTotalsPath = 'jest-combined/coverage-summary-NO-total.json';
45+
const verboseArgs = [
46+
'scripts/ingest_coverage.js',
47+
'--verbose',
48+
'--vcsInfoPath',
49+
'src/dev/code_coverage/ingest_coverage/integration_tests/mocks/VCS_INFO.txt',
50+
'--path',
51+
];
52+
53+
describe('Ingesting coverage', () => {
5954
const bothIndexesPath = 'jest-combined/coverage-summary-manual-mix.json';
6055

61-
describe('with NODE_ENV set to "integration_test"', () => {
62-
describe(`and debug || verbose turned on`, () => {
63-
describe(`to the [${COVERAGE_INDEX}] index`, () => {
64-
const mutableCoverageIndexChunks = [];
65-
66-
beforeAll(done => {
67-
const ingestAndMutateAsync = ingestAndMutate(done);
68-
const ingestAndMutateAsyncWithPath = ingestAndMutateAsync(noTotalsPath);
69-
const verboseIngestAndMutateAsyncWithPath = ingestAndMutateAsyncWithPath(verboseArgs);
70-
verboseIngestAndMutateAsyncWithPath(mutableCoverageIndexChunks);
71-
});
72-
73-
it(
74-
'should result in every posted item having a site url that meets all regex assertions',
75-
always(
76-
siteUrlsSplitByNewLineWithoutBlanks(mutableCoverageIndexChunks).forEach(
77-
expectAllRegexesToPass({
78-
...staticSiteUrlRegexes,
79-
endsInDotJsDotHtml: /.js.html$/,
80-
})
81-
)
82-
)
83-
);
84-
});
85-
describe(`to both indexes in the same push`, () => {
86-
const mutableBothIndexesChunks = [];
87-
88-
beforeAll(done => {
89-
const ingestAndMutateAsync = ingestAndMutate(done);
90-
const ingestAndMutateAsyncWithPath = ingestAndMutateAsync(bothIndexesPath);
91-
const verboseIngestAndMutateAsyncWithPath = ingestAndMutateAsyncWithPath(verboseArgs);
92-
verboseIngestAndMutateAsyncWithPath(mutableBothIndexesChunks);
93-
});
56+
describe(`to the coverage index`, () => {
57+
const mutableCoverageIndexChunks = [];
9458

95-
it(
96-
'should result in every posted item having a site url that meets all regex assertions',
97-
always(
98-
siteUrlsSplitByNewLineWithoutBlanks(mutableBothIndexesChunks).forEach(
99-
expectAllRegexesToPass(staticSiteUrlRegexes)
100-
)
101-
)
102-
);
103-
104-
it('should result in the "just logging" message being present in the log', () => {
105-
expect(mutableBothIndexesChunks.some(x => x.includes('Just Logging'))).to.be(true);
106-
});
107-
it('should result in the "actually sending" message NOT being present in the log', () => {
108-
expect(mutableBothIndexesChunks.every(x => !x.includes('Actually sending...'))).to.be(
109-
true
110-
);
111-
});
112-
describe(`with provided vcs info file`, () => {
113-
const filterZero = xs => included => xs.filter(x => x.includes(included))[0];
114-
const filteredWith = filterZero(mutableBothIndexesChunks);
115-
it('should have a vcs block', () => {
116-
const vcs = 'vcs';
117-
const portion = filteredWith(vcs);
118-
expect(portion).to.contain(vcs);
119-
});
120-
it(`should have a branch`, () => {
121-
const branch = `"branch":`;
122-
const portion = filteredWith(branch);
123-
expect(portion).to.contain(branch);
124-
expect(portion).to.contain(`"origin/ingest-code-coverage"`);
125-
});
126-
it(`should have a sha`, () => {
127-
const sha = `"sha":`;
128-
const portion = filteredWith(sha);
129-
expect(portion).to.contain(sha);
130-
expect(portion).to.contain(`"f07b34f6206"`);
131-
});
132-
it(`should have an author`, () => {
133-
const author = `"author":`;
134-
const portion = filteredWith(author);
135-
expect(portion).to.contain(author);
136-
expect(portion).to.contain(`"Tre' Seymour"`);
137-
});
138-
it(`should have a commit msg, truncated`, () => {
139-
const commitMsg = `"commitMsg":`;
140-
const portion = filteredWith(commitMsg);
141-
expect(portion).to.contain(commitMsg);
142-
expect(portion).to.contain(`"Lorem :) ipsum Tre' λ dolor sit amet, consectetur ..."`);
143-
});
144-
});
145-
});
59+
beforeAll(done => {
60+
const ingestAndMutateAsync = ingestAndMutate(done);
61+
const ingestAndMutateAsyncWithPath = ingestAndMutateAsync(bothIndexesPath);
62+
const verboseIngestAndMutateAsyncWithPath = ingestAndMutateAsyncWithPath(verboseArgs);
63+
verboseIngestAndMutateAsyncWithPath(mutableCoverageIndexChunks);
14664
});
65+
66+
it(
67+
'should result in every posted item having a site url that meets all regex assertions',
68+
always(
69+
siteUrlsSplitByNewLineWithoutBlanks(mutableCoverageIndexChunks).forEach(
70+
expectAllRegexesToPass({
71+
...staticSiteUrlRegexes,
72+
endsInDotJsDotHtml: /.js.html$/,
73+
})
74+
)
75+
)
76+
);
14777
});
14878
});
14979

0 commit comments

Comments
 (0)