2020-07-08 19:54:03 +02:00
/ *
* Copyright Elasticsearch B . V . and / or licensed to Elasticsearch B . V . under one
2021-02-04 03:12:39 +01:00
* or more contributor license agreements . Licensed under the Elastic License
* 2.0 ; you may not use this file except in compliance with the Elastic License
* 2.0 .
2020-07-08 19:54:03 +02:00
* /
import { resolve } from 'path' ;
2020-12-04 22:34:03 +01:00
import consumeState from './consume_state' ;
2020-10-01 22:35:36 +02:00
import { ToolingLog , REPO _ROOT } from '@kbn/dev-utils' ;
2020-07-08 19:54:03 +02:00
import chalk from 'chalk' ;
import { esTestConfig , kbnTestConfig } from '@kbn/test' ;
2020-11-11 00:14:26 +01:00
import { TriggersActionsPageProvider } from '../../functional_with_es_ssl/page_objects/triggers_actions_ui_page' ;
2021-06-08 23:37:42 +02:00
import { services } from '../services' ;
2020-07-08 19:54:03 +02:00
const log = new ToolingLog ( {
level : 'info' ,
writeTo : process . stdout ,
} ) ;
2020-10-03 00:07:14 +02:00
const INTEGRATION _TEST _ROOT = process . env . WORKSPACE || resolve ( REPO _ROOT , '../integration-test' ) ;
const stateFilePath = resolve ( INTEGRATION _TEST _ROOT , 'qa/envvars.sh' ) ;
2020-07-17 23:42:56 +02:00
2020-11-11 00:14:26 +01:00
const testsFolder = '../apps' ;
2020-07-17 23:42:56 +02:00
const prepend = ( testFile ) => require . resolve ( ` ${ testsFolder } / ${ testFile } ` ) ;
2020-07-08 19:54:03 +02:00
export default async ( { readConfigFile } ) => {
2020-11-11 00:14:26 +01:00
const xpackFunctionalConfig = await readConfigFile ( require . resolve ( '../../functional/config' ) ) ;
2020-12-04 22:34:03 +01:00
const externalConf = consumeState ( resolve ( _ _dirname , stateFilePath ) ) ;
2020-10-01 22:35:36 +02:00
process . env . stack _functional _integration = true ;
2020-11-11 00:14:26 +01:00
logAll ( log ) ;
2020-07-08 19:54:03 +02:00
const settings = {
2020-11-11 00:14:26 +01:00
... xpackFunctionalConfig . getAll ( ) ,
2021-06-08 23:37:42 +02:00
services ,
2020-11-11 00:14:26 +01:00
pageObjects : {
triggersActionsUI : TriggersActionsPageProvider ,
... xpackFunctionalConfig . get ( 'pageObjects' ) ,
} ,
apps : {
... xpackFunctionalConfig . get ( 'apps' ) ,
triggersConnectors : {
pathname : '/app/management/insightsAndAlerting/triggersActions/connectors' ,
} ,
} ,
2020-07-08 19:54:03 +02:00
junit : {
2020-12-04 22:34:03 +01:00
reportName : ` Stack Functional Integration Tests - ${ externalConf . VM } ` ,
2020-11-11 00:14:26 +01:00
} ,
servers : servers ( ) ,
kbnTestServer : {
... xpackFunctionalConfig . get ( 'kbnTestServer' ) ,
serverArgs : [ ... xpackFunctionalConfig . get ( 'kbnTestServer.serverArgs' ) ] ,
2020-07-08 19:54:03 +02:00
} ,
2020-12-04 22:34:03 +01:00
testFiles : tests ( externalConf . TESTS _LIST ) . map ( prepend ) . map ( logTest ) ,
2020-11-11 00:14:26 +01:00
// testFiles: ['alerts'].map(prepend).map(logTest),
2020-07-08 19:54:03 +02:00
// If we need to do things like disable animations, we can do it in configure_start_kibana.sh, in the provisioner...which lives in the integration-test private repo
uiSettings : { } ,
security : { disableTestUser : true } ,
2020-10-01 22:35:36 +02:00
// choose where screenshots should be saved
screenshots : {
2020-10-03 00:07:14 +02:00
directory : resolve ( INTEGRATION _TEST _ROOT , 'test/screenshots' ) ,
2020-10-01 22:35:36 +02:00
} ,
2020-07-08 19:54:03 +02:00
} ;
return settings ;
} ;
2020-12-04 22:34:03 +01:00
const split = ( splitter ) => ( x ) => x . split ( splitter ) ;
function tests ( externalTestsList ) {
return split ( ' ' ) ( externalTestsList ) ;
}
2020-07-08 19:54:03 +02:00
// Returns index 1 from the resulting array-like.
const splitRight = ( re ) => ( testPath ) => re . exec ( testPath ) [ 1 ] ;
function truncate ( testPath ) {
const dropKibanaPath = splitRight ( /^.+kibana[\\/](.*$)/gm ) ;
return dropKibanaPath ( testPath ) ;
}
function highLight ( testPath ) {
2020-10-01 22:35:36 +02:00
const dropTestsPath = splitRight ( /^.+apps[\\/](.*)[\\/]/gm ) ;
2020-07-08 19:54:03 +02:00
const cleaned = dropTestsPath ( testPath ) ;
const colored = chalk . greenBright . bold ( cleaned ) ;
return testPath . replace ( cleaned , colored ) ;
}
function logTest ( testPath ) {
2020-11-11 00:14:26 +01:00
log . info ( ` ### Testing: ' ${ highLight ( truncate ( testPath ) ) } ' ` ) ;
2020-07-08 19:54:03 +02:00
return testPath ;
}
2020-11-11 00:14:26 +01:00
function logAll ( log ) {
log . info ( ` REPO_ROOT = ${ REPO _ROOT } ` ) ;
log . info ( ` WORKSPACE in config file ${ process . env . WORKSPACE } ` ) ;
log . info ( ` INTEGRATION_TEST_ROOT = ${ INTEGRATION _TEST _ROOT } ` ) ;
log . info ( ` stateFilePath = ${ stateFilePath } ` ) ;
log . info ( ` servers data: ${ JSON . stringify ( servers ( ) , null , 2 ) } ` ) ;
}
function servers ( ) {
return {
kibana : kbnTestConfig . getUrlParts ( ) ,
elasticsearch : esTestConfig . getUrlParts ( ) ,
} ;
}