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.
|
|
|
|
*/
|
|
|
|
|
2016-09-02 00:02:43 +02:00
|
|
|
import _, { keys } from 'lodash';
|
2016-11-16 01:11:03 +01:00
|
|
|
|
2017-06-06 19:11:59 +02:00
|
|
|
import { run } from '../utilities/visual_regression';
|
2016-06-10 06:36:09 +02:00
|
|
|
|
2014-02-11 00:09:04 +01:00
|
|
|
module.exports = function (grunt) {
|
2016-06-10 06:36:09 +02:00
|
|
|
grunt.registerTask(
|
2016-06-22 01:59:43 +02:00
|
|
|
'test:visualRegression:buildGallery',
|
2016-06-10 06:36:09 +02:00
|
|
|
'Compare screenshots and generate diff images.',
|
|
|
|
function () {
|
|
|
|
const done = this.async();
|
2017-06-06 19:11:59 +02:00
|
|
|
run(done);
|
2016-06-10 06:36:09 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2016-11-16 01:11:03 +01:00
|
|
|
grunt.registerTask('test:server', [
|
|
|
|
'checkPlugins',
|
2018-05-16 19:43:55 +02:00
|
|
|
'run:mocha',
|
2016-11-16 01:11:03 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask('test:browser', [
|
|
|
|
'checkPlugins',
|
2018-04-20 21:13:37 +02:00
|
|
|
'run:browserTestServer',
|
2016-11-16 01:11:03 +01:00
|
|
|
'karma:unit',
|
|
|
|
]);
|
|
|
|
|
2016-09-02 00:02:43 +02:00
|
|
|
grunt.registerTask('test:browser-ci', () => {
|
|
|
|
const ciShardTasks = keys(grunt.config.get('karma'))
|
|
|
|
.filter(key => key.startsWith('ciShard-'))
|
|
|
|
.map(key => `karma:${key}`);
|
|
|
|
|
|
|
|
grunt.log.ok(`Running UI tests in ${ciShardTasks.length} shards`);
|
|
|
|
|
|
|
|
grunt.task.run([
|
2018-04-20 21:13:37 +02:00
|
|
|
'run:browserTestServer',
|
2016-09-02 00:02:43 +02:00
|
|
|
...ciShardTasks
|
|
|
|
]);
|
|
|
|
});
|
2016-11-16 01:11:03 +01:00
|
|
|
|
2015-08-25 02:10:21 +02:00
|
|
|
grunt.registerTask('test:coverage', [ 'run:testCoverageServer', 'karma:coverage' ]);
|
2015-08-18 23:51:31 +02:00
|
|
|
|
|
|
|
grunt.registerTask('test:quick', [
|
|
|
|
'test:server',
|
2015-09-09 17:12:45 +02:00
|
|
|
'test:ui',
|
2017-04-06 03:24:01 +02:00
|
|
|
'test:jest',
|
2018-02-19 17:02:01 +01:00
|
|
|
'test:jest_integration',
|
2018-03-09 14:28:47 +01:00
|
|
|
'test:projects',
|
2015-11-20 18:58:58 +01:00
|
|
|
'test:browser',
|
|
|
|
'test:api'
|
2015-08-18 23:51:31 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask('test:dev', [
|
2016-11-16 01:11:03 +01:00
|
|
|
'checkPlugins',
|
2018-04-20 21:13:37 +02:00
|
|
|
'run:devBrowserTestServer',
|
2015-08-19 00:36:00 +02:00
|
|
|
'karma:dev'
|
2015-08-18 23:51:31 +02:00
|
|
|
]);
|
|
|
|
|
2015-12-22 15:24:23 +01:00
|
|
|
grunt.registerTask('test:ui', [
|
2016-11-16 01:11:03 +01:00
|
|
|
'checkPlugins',
|
2018-03-20 16:30:15 +01:00
|
|
|
'run:testEsServer',
|
2018-04-20 21:13:37 +02:00
|
|
|
'run:funcTestServer',
|
2017-05-18 03:53:45 +02:00
|
|
|
'functional_test_runner:functional',
|
2018-03-20 16:30:15 +01:00
|
|
|
'stop:testEsServer',
|
2018-04-20 21:13:37 +02:00
|
|
|
'stop:funcTestServer'
|
2015-09-02 21:07:20 +02:00
|
|
|
]);
|
|
|
|
|
2017-04-21 18:08:36 +02:00
|
|
|
grunt.registerTask('test:uiRelease', [
|
|
|
|
'checkPlugins',
|
2018-03-20 16:30:15 +01:00
|
|
|
'run:testEsServer',
|
2018-04-20 21:13:37 +02:00
|
|
|
'run:ossDistFuncTestServer',
|
2017-05-18 03:53:45 +02:00
|
|
|
'functional_test_runner:functional',
|
2018-03-20 16:30:15 +01:00
|
|
|
'stop:testEsServer',
|
2018-04-20 21:13:37 +02:00
|
|
|
'stop:ossDistFuncTestServer'
|
2017-04-21 18:08:36 +02:00
|
|
|
]);
|
|
|
|
|
2015-09-11 21:08:35 +02:00
|
|
|
grunt.registerTask('test:ui:server', [
|
2016-11-19 19:08:43 +01:00
|
|
|
'checkPlugins',
|
2018-03-20 16:30:15 +01:00
|
|
|
'run:testEsServer',
|
2018-04-20 21:13:37 +02:00
|
|
|
'run:devFuncTestServer:keepalive'
|
2015-09-11 21:08:35 +02:00
|
|
|
]);
|
|
|
|
|
2015-11-17 19:01:45 +01:00
|
|
|
grunt.registerTask('test:api', [
|
2018-03-20 16:30:15 +01:00
|
|
|
'run:testEsServer',
|
2015-11-17 19:01:45 +01:00
|
|
|
'run:apiTestServer',
|
2017-05-18 03:53:45 +02:00
|
|
|
'functional_test_runner:apiIntegration',
|
2018-03-20 16:30:15 +01:00
|
|
|
'stop:testEsServer',
|
2015-11-17 19:01:45 +01:00
|
|
|
'stop:apiTestServer'
|
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask('test:api:server', [
|
2018-03-20 16:30:15 +01:00
|
|
|
'run:testEsServer',
|
2017-06-02 23:26:58 +02:00
|
|
|
'run:devApiTestServer:keepalive'
|
2015-11-17 19:01:45 +01:00
|
|
|
]);
|
|
|
|
|
2017-05-18 03:53:45 +02:00
|
|
|
grunt.registerTask('test:api:runner', () => {
|
2017-07-06 09:02:35 +02:00
|
|
|
grunt.fail.fatal('test:api:runner has moved, use: `node scripts/functional_test_runner --config test/api_integration/config.js`');
|
2017-05-18 03:53:45 +02:00
|
|
|
});
|
2015-11-17 19:01:45 +01:00
|
|
|
|
2016-06-10 06:36:09 +02:00
|
|
|
grunt.registerTask('test', subTask => {
|
2015-08-18 23:51:31 +02:00
|
|
|
if (subTask) grunt.fail.fatal(`invalid task "test:${subTask}"`);
|
|
|
|
|
2015-07-28 02:13:45 +02:00
|
|
|
grunt.task.run(_.compact([
|
2017-11-14 18:11:59 +01:00
|
|
|
!grunt.option('quick') && 'run:eslint',
|
2018-05-22 23:00:02 +02:00
|
|
|
!grunt.option('quick') && 'run:tslint',
|
2018-05-24 20:38:42 +02:00
|
|
|
'run:checkFileCasing',
|
2016-05-02 18:55:55 +02:00
|
|
|
'licenses',
|
2018-02-12 22:40:47 +01:00
|
|
|
'test:quick',
|
|
|
|
'verifyTranslations',
|
2015-07-28 02:13:45 +02:00
|
|
|
]));
|
2014-09-20 00:41:25 +02:00
|
|
|
});
|
|
|
|
|
2015-08-18 23:51:31 +02:00
|
|
|
grunt.registerTask('quick-test', ['test:quick']); // historical alias
|
2018-03-09 14:28:47 +01:00
|
|
|
|
|
|
|
grunt.registerTask('test:projects', function () {
|
|
|
|
const done = this.async();
|
|
|
|
runProjectsTests().then(done, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
function runProjectsTests() {
|
|
|
|
const serverCmd = {
|
|
|
|
cmd: 'yarn',
|
2018-04-20 21:13:37 +02:00
|
|
|
args: ['kbn', 'run', 'test', '--exclude', 'kibana', '--oss', '--skip-kibana-extra'],
|
2018-03-09 14:28:47 +01:00
|
|
|
opts: { stdio: 'inherit' }
|
|
|
|
};
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
grunt.util.spawn(serverCmd, (error, result, code) => {
|
|
|
|
if (error || code !== 0) {
|
|
|
|
const error = new Error(`projects tests exited with code ${code}`);
|
|
|
|
grunt.fail.fatal(error);
|
|
|
|
reject(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
grunt.log.writeln(result);
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2014-02-24 23:14:31 +01:00
|
|
|
};
|