1717 * under the License.
1818 */
1919
20- import expect from '@kbn/expect' ;
2120import { spawn } from 'child_process' ;
2221import { resolve } from 'path' ;
2322import { green , always } from '../utils' ;
2423
25- import { STATIC_SITE_URL_PROP_NAME , COVERAGE_INDEX } from '../constants' ;
26-
2724const ROOT_DIR = resolve ( __dirname , '../../../../..' ) ;
2825const MOCKS_DIR = resolve ( __dirname , './mocks' ) ;
2926const 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' ) ;
4441const siteUrlLines = specificLinesOnly ( includesSiteUrlPredicate ) ;
4542const splitByNewLine = x => x . split ( '\n' ) ;
4643const siteUrlsSplitByNewLine = siteUrlLines ( splitByNewLine ) ;
4744const 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 : / .j s .h t m l $ / ,
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 : / .j s .h t m l $ / ,
73+ } )
74+ )
75+ )
76+ ) ;
14777 } ) ;
14878} ) ;
14979
0 commit comments