2018-05-29 05:06:30 +02:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2018-04-20 21:13:37 +02:00
|
|
|
import { resolve } from 'path';
|
2018-11-20 23:02:06 +01:00
|
|
|
import { getFunctionalTestGroupRunConfigs } from '../function_test_groups';
|
2017-05-04 22:27:18 +02:00
|
|
|
|
2018-11-10 03:01:48 +01:00
|
|
|
const { version } = require('../../package.json');
|
|
|
|
const KIBANA_INSTALL_DIR = `./build/oss/kibana-${version}-SNAPSHOT-${process.platform}-x86_64`;
|
2017-10-03 03:51:58 +02:00
|
|
|
|
2014-08-26 02:55:32 +02:00
|
|
|
module.exports = function (grunt) {
|
2015-08-01 23:46:53 +02:00
|
|
|
|
2018-04-20 21:13:37 +02:00
|
|
|
function createKbnServerTask({ runBuild, flags = [] }) {
|
|
|
|
return {
|
|
|
|
options: {
|
|
|
|
wait: false,
|
|
|
|
ready: /Server running/,
|
|
|
|
quiet: false,
|
|
|
|
failOnError: false
|
|
|
|
},
|
|
|
|
cmd: runBuild
|
|
|
|
? `./build/${runBuild}/bin/kibana`
|
|
|
|
: process.execPath,
|
|
|
|
args: [
|
|
|
|
...runBuild ? [] : [require.resolve('../../scripts/kibana'), '--oss'],
|
|
|
|
|
|
|
|
'--env.name=development',
|
|
|
|
'--logging.json=false',
|
|
|
|
|
|
|
|
...flags,
|
|
|
|
|
|
|
|
// allow the user to override/inject flags by defining cli args starting with `--kbnServer.`
|
|
|
|
...grunt.option.flags().reduce(function (flags, flag) {
|
|
|
|
if (flag.startsWith('--kbnServer.')) {
|
|
|
|
flags.push(`--${flag.slice(12)}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
}, [])
|
|
|
|
]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const browserTestServerFlags = [
|
2016-02-12 17:35:01 +01:00
|
|
|
'--plugins.initialize=false',
|
|
|
|
'--optimize.bundleFilter=tests',
|
2018-04-20 21:13:37 +02:00
|
|
|
'--server.port=5610',
|
2016-02-12 17:35:01 +01:00
|
|
|
];
|
|
|
|
|
2018-09-07 01:31:47 +02:00
|
|
|
const esFrom = process.env.TEST_ES_FROM || 'source';
|
2015-07-16 07:15:56 +02:00
|
|
|
return {
|
2018-04-20 21:13:37 +02:00
|
|
|
// used by the test and jenkins:unit tasks
|
|
|
|
// runs the eslint script to check for linting errors
|
2017-11-14 18:11:59 +01:00
|
|
|
eslint: {
|
|
|
|
cmd: process.execPath,
|
|
|
|
args: [
|
|
|
|
require.resolve('../../scripts/eslint'),
|
|
|
|
'--no-cache'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2018-05-24 20:38:42 +02:00
|
|
|
// used by the test tasks
|
|
|
|
// runs the check_file_casing script to ensure filenames use correct casing
|
|
|
|
checkFileCasing: {
|
|
|
|
cmd: process.execPath,
|
|
|
|
args: [
|
|
|
|
require.resolve('../../scripts/check_file_casing'),
|
|
|
|
'--quiet' // only log errors, not warnings
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2018-05-22 23:00:02 +02:00
|
|
|
// used by the test and jenkins:unit tasks
|
|
|
|
// runs the tslint script to check for Typescript linting errors
|
|
|
|
tslint: {
|
|
|
|
cmd: process.execPath,
|
|
|
|
args: [
|
|
|
|
require.resolve('../../scripts/tslint')
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2018-08-10 02:19:24 +02:00
|
|
|
// used by the test and jenkins:unit tasks
|
|
|
|
// runs the tslint script to check for Typescript linting errors
|
|
|
|
typeCheck: {
|
|
|
|
cmd: process.execPath,
|
|
|
|
args: [
|
|
|
|
require.resolve('../../scripts/type_check')
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2018-08-29 10:55:34 +02:00
|
|
|
// used by the test and jenkins:unit tasks
|
|
|
|
// runs the i18n_check script to check i18n engine usage
|
|
|
|
i18nCheck: {
|
|
|
|
cmd: process.execPath,
|
|
|
|
args: [
|
|
|
|
require.resolve('../../scripts/i18n_check'),
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2018-05-16 19:43:55 +02:00
|
|
|
// used by the test:server task
|
|
|
|
// runs all node.js/server mocha tests
|
|
|
|
mocha: {
|
|
|
|
cmd: process.execPath,
|
|
|
|
args: [
|
|
|
|
require.resolve('../../scripts/mocha')
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2018-04-20 21:13:37 +02:00
|
|
|
// used by the test:browser task
|
|
|
|
// runs the kibana server to serve the browser test bundle
|
|
|
|
browserTestServer: createKbnServerTask({
|
|
|
|
flags: [
|
|
|
|
...browserTestServerFlags,
|
2015-08-25 02:10:21 +02:00
|
|
|
]
|
2018-04-20 21:13:37 +02:00
|
|
|
}),
|
2018-10-04 18:10:20 +02:00
|
|
|
browserSCSS: createKbnServerTask({
|
|
|
|
flags: [
|
|
|
|
...browserTestServerFlags,
|
|
|
|
'--optimize',
|
|
|
|
'--optimize.enabled=false'
|
|
|
|
]
|
|
|
|
}),
|
2015-08-25 02:10:21 +02:00
|
|
|
|
2018-04-20 21:13:37 +02:00
|
|
|
// used by the test:coverage task
|
2018-06-27 05:17:41 +02:00
|
|
|
// runs the kibana server to serve the instrumented version of the browser test bundle
|
2018-04-20 21:13:37 +02:00
|
|
|
browserTestCoverageServer: createKbnServerTask({
|
|
|
|
flags: [
|
|
|
|
...browserTestServerFlags,
|
|
|
|
'--tests_bundle.instrument=true',
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
|
|
|
|
// used by the test:dev task
|
|
|
|
// runs the kibana server to serve the browser test bundle, but listens for changes
|
|
|
|
// to the public/browser code and rebuilds the test bundle on changes
|
|
|
|
devBrowserTestServer: createKbnServerTask({
|
|
|
|
flags: [
|
|
|
|
...browserTestServerFlags,
|
2015-08-18 22:32:44 +02:00
|
|
|
'--dev',
|
|
|
|
'--no-watch',
|
2016-01-22 00:52:25 +01:00
|
|
|
'--no-base-path',
|
2018-01-09 08:46:16 +01:00
|
|
|
'--optimize.watchPort=5611',
|
|
|
|
'--optimize.watchPrebuild=true',
|
2017-10-04 22:33:41 +02:00
|
|
|
'--optimize.bundleDir=' + resolve(__dirname, '../../optimize/testdev'),
|
2015-08-18 22:32:44 +02:00
|
|
|
]
|
2018-04-20 21:13:37 +02:00
|
|
|
}),
|
2018-03-20 16:30:15 +01:00
|
|
|
|
2018-04-04 18:12:44 +02:00
|
|
|
verifyNotice: {
|
|
|
|
options: {
|
|
|
|
wait: true,
|
|
|
|
},
|
|
|
|
cmd: process.execPath,
|
|
|
|
args: [
|
|
|
|
'scripts/notice',
|
|
|
|
'--validate'
|
|
|
|
]
|
2018-06-27 01:08:40 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
apiIntegrationTests: {
|
|
|
|
cmd: process.execPath,
|
|
|
|
args: [
|
|
|
|
'scripts/functional_tests',
|
|
|
|
'--config', 'test/api_integration/config.js',
|
2018-09-07 01:31:47 +02:00
|
|
|
'--esFrom', esFrom,
|
2018-06-27 01:08:40 +02:00
|
|
|
'--bail',
|
|
|
|
'--debug',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
2018-08-17 08:36:15 +02:00
|
|
|
serverIntegrationTests: {
|
|
|
|
cmd: process.execPath,
|
|
|
|
args: [
|
|
|
|
'scripts/functional_tests',
|
|
|
|
'--config', 'test/server_integration/http/ssl/config.js',
|
|
|
|
'--config', 'test/server_integration/http/ssl_redirect/config.js',
|
2018-09-07 01:31:47 +02:00
|
|
|
'--esFrom', esFrom,
|
2018-08-17 08:36:15 +02:00
|
|
|
'--bail',
|
|
|
|
'--debug',
|
2018-11-10 03:01:48 +01:00
|
|
|
'--kibana-install-dir', KIBANA_INSTALL_DIR,
|
2018-08-17 08:36:15 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
2018-08-20 21:48:38 +02:00
|
|
|
pluginFunctionalTestsRelease: {
|
2018-07-28 16:41:57 +02:00
|
|
|
cmd: process.execPath,
|
|
|
|
args: [
|
|
|
|
'scripts/functional_tests',
|
2018-08-20 21:48:38 +02:00
|
|
|
'--config', 'test/plugin_functional/config.js',
|
2018-09-07 01:31:47 +02:00
|
|
|
'--esFrom', esFrom,
|
2018-07-28 16:41:57 +02:00
|
|
|
'--bail',
|
|
|
|
'--debug',
|
2018-11-10 03:01:48 +01:00
|
|
|
'--kibana-install-dir', KIBANA_INSTALL_DIR,
|
2018-08-20 21:48:38 +02:00
|
|
|
'--',
|
|
|
|
'--server.maxPayloadBytes=1648576',
|
2018-07-28 16:41:57 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
2018-06-27 01:08:40 +02:00
|
|
|
functionalTests: {
|
|
|
|
cmd: process.execPath,
|
|
|
|
args: [
|
|
|
|
'scripts/functional_tests',
|
|
|
|
'--config', 'test/functional/config.js',
|
2018-09-07 01:31:47 +02:00
|
|
|
'--esFrom', esFrom,
|
2018-06-27 01:08:40 +02:00
|
|
|
'--bail',
|
|
|
|
'--debug',
|
|
|
|
'--',
|
2018-08-17 08:36:15 +02:00
|
|
|
'--server.maxPayloadBytes=1648576', //default is 1048576
|
2018-06-27 01:08:40 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
2018-11-20 23:02:06 +01:00
|
|
|
...getFunctionalTestGroupRunConfigs({
|
|
|
|
esFrom,
|
|
|
|
kibanaInstallDir: KIBANA_INSTALL_DIR
|
|
|
|
})
|
2014-08-26 02:55:32 +02:00
|
|
|
};
|
|
|
|
};
|