Summary of Changes:
- moved es install/start/stop logic into a seperate script - `grunt test` now runs the integration tests once for each version of ES we support - grunt can now install and run elasticearch (using grunt-run, pure js solution coming later) - included seperate es.sh script specifically for starting or stopping elasticsearch - url aliases, api, yaml_suite/index.js, and yaml_tests.json, are all now duplicated for 0_90 support - the client now accepts an apiVersion argument (undocumented) which defaults to 'master' but can be '0.90' - The yaml test runner will now check the name of the ES instance it is connecting to, preventing accidental wiping of ES
This commit is contained in:
95
scripts/generate/aliases.js
Normal file
95
scripts/generate/aliases.js
Normal file
@ -0,0 +1,95 @@
|
||||
module.exports = {
|
||||
'cluster.nodeHotThreads': [
|
||||
'/_cluster/nodes/hotthreads',
|
||||
'/_cluster/nodes/hot_threads',
|
||||
'/_nodes/hot_threads',
|
||||
'/_cluster/nodes/{node_id}/hotthreads',
|
||||
'/_cluster/nodes/{node_id}/hot_threads',
|
||||
'/_nodes/{node_id}/hot_threads'
|
||||
],
|
||||
'cluster.nodeInfo': [
|
||||
'/_cluster/nodes',
|
||||
'/_nodes/settings',
|
||||
'/_nodes/os',
|
||||
'/_nodes/process',
|
||||
'/_nodes/jvm',
|
||||
'/_nodes/thread_pool',
|
||||
'/_nodes/network',
|
||||
'/_nodes/transport',
|
||||
'/_nodes/http',
|
||||
'/_nodes/plugin',
|
||||
'/_cluster/nodes/{node_id}',
|
||||
'/_nodes/{node_id}/settings',
|
||||
'/_nodes/{node_id}/os',
|
||||
'/_nodes/{node_id}/process',
|
||||
'/_nodes/{node_id}/jvm',
|
||||
'/_nodes/{node_id}/thread_pool',
|
||||
'/_nodes/{node_id}/network',
|
||||
'/_nodes/{node_id}/transport',
|
||||
'/_nodes/{node_id}/http',
|
||||
'/_nodes/{node_id}/plugin'
|
||||
],
|
||||
'cluster.nodeShutdown': [
|
||||
'/_cluster/nodes/_shutdown'
|
||||
],
|
||||
'cluster.nodeStats': [
|
||||
'/_cluster/nodes/stats',
|
||||
'/_nodes/stats/{metric_family}',
|
||||
'/_nodes/stats/indices/{metric}/{fields}',
|
||||
'/_cluster/nodes/{node_id}/stats',
|
||||
'/_nodes/{node_id}/stats/{metric_family}',
|
||||
'/_nodes/{node_id}/stats/indices/{metric}/{fields}'
|
||||
],
|
||||
'get': [
|
||||
'/{index}/{type}/{id}/_source'
|
||||
],
|
||||
'indices.deleteMapping': [
|
||||
'/{index}/{type}',
|
||||
'/{index}/_mapping/{type}',
|
||||
'/{index}/{type}/_mappings',
|
||||
'/{index}/_mappings/{type}'
|
||||
],
|
||||
'indices.putWarmer': [
|
||||
// '/_warmer/{name}',
|
||||
// '/{index}/_warmer/{name}',
|
||||
// '/{index}/{type}/_warmer/{name}',
|
||||
'/_warmers/{name}',
|
||||
'/{index}/_warmers/{name}',
|
||||
'/{index}/{type}/_warmers/{name}'
|
||||
],
|
||||
'indices.deleteWarmer': [
|
||||
// '/{index}/_warmer/{name}',
|
||||
'/{index}/_warmer',
|
||||
'/{index}/_warmers',
|
||||
'/{index}/_warmers/{name}'
|
||||
],
|
||||
'indices.deleteAlias': [
|
||||
// '/{index}/_alias/{name}',
|
||||
'/{index}/_aliases/{name}'
|
||||
],
|
||||
'indices.putAlias': [
|
||||
// '/{index}/_alias/{name}',
|
||||
// '/_alias/{name}',
|
||||
'/{index}/_aliases/{name}',
|
||||
'/_aliases/{name}'
|
||||
],
|
||||
'indices.putMapping': [
|
||||
// '/{index}/_mapping/{type}',
|
||||
// '/_mapping/{type}',
|
||||
'/{index}/{type}/_mapping',
|
||||
'/{index}/{type}/_mappings',
|
||||
'/{index}/_mappings/{type}',
|
||||
'/_mappings/{type}'
|
||||
],
|
||||
'indices.stats': [
|
||||
'_stats/{metric_family}',
|
||||
'/_stats/indexing',
|
||||
'/_stats/indexing/{indexing_types}',
|
||||
'/_stats/search/{search_groups}',
|
||||
'/_stats/fielddata/{fields}',
|
||||
'/{index}/_stats/{metric_family}',
|
||||
'/{index}/_stats/indexing',
|
||||
'/{index}/_stats/search/{search_groups}',
|
||||
'/{index}/_stats/fielddata/{fields}'
|
||||
]
|
||||
};
|
||||
63
scripts/generate/aliases_0_90.js
Normal file
63
scripts/generate/aliases_0_90.js
Normal file
@ -0,0 +1,63 @@
|
||||
module.exports = {
|
||||
'cluster.nodeHotThreads': [
|
||||
'/_cluster/nodes/hotthreads',
|
||||
'/_cluster/nodes/hot_threads',
|
||||
'/_nodes/hot_threads',
|
||||
'/_cluster/nodes/{node_id}/hotthreads',
|
||||
'/_cluster/nodes/{node_id}/hot_threads',
|
||||
'/_nodes/{node_id}/hot_threads'
|
||||
],
|
||||
'cluster.nodeInfo': [
|
||||
'/_cluster/nodes',
|
||||
'/_nodes/settings',
|
||||
'/_nodes/os',
|
||||
'/_nodes/process',
|
||||
'/_nodes/jvm',
|
||||
'/_nodes/thread_pool',
|
||||
'/_nodes/network',
|
||||
'/_nodes/transport',
|
||||
'/_nodes/http',
|
||||
'/_nodes/plugin',
|
||||
'/_cluster/nodes/{node_id}',
|
||||
'/_nodes/{node_id}/settings',
|
||||
'/_nodes/{node_id}/os',
|
||||
'/_nodes/{node_id}/process',
|
||||
'/_nodes/{node_id}/jvm',
|
||||
'/_nodes/{node_id}/thread_pool',
|
||||
'/_nodes/{node_id}/network',
|
||||
'/_nodes/{node_id}/transport',
|
||||
'/_nodes/{node_id}/http',
|
||||
'/_nodes/{node_id}/plugin'
|
||||
],
|
||||
'cluster.nodeShutdown': [
|
||||
'/_cluster/nodes/_shutdown'
|
||||
],
|
||||
'cluster.nodeStats': [
|
||||
'/_cluster/nodes/stats',
|
||||
'/_nodes/stats/{metric_family}',
|
||||
'/_nodes/stats/indices/{metric}/{fields}',
|
||||
'/_cluster/nodes/{node_id}/stats',
|
||||
'/_nodes/{node_id}/stats/{metric_family}',
|
||||
'/_nodes/{node_id}/stats/indices/{metric}/{fields}'
|
||||
],
|
||||
'get': [
|
||||
'/{index}/{type}/{id}/_source'
|
||||
],
|
||||
'indices.deleteMapping': [
|
||||
'/{index}/{type}/_mapping'
|
||||
],
|
||||
'indices.stats': [
|
||||
'_stats/{metric_family}',
|
||||
'/_stats/indexing',
|
||||
'/_stats/indexing/{indexing_types}',
|
||||
'/_stats/search/{search_groups}',
|
||||
'/_stats/fielddata/{fields}',
|
||||
'/{index}/_stats/{metric_family}',
|
||||
'/{index}/_stats/indexing',
|
||||
'/{index}/_stats/search/{search_groups}',
|
||||
'/{index}/_stats/fielddata/{fields}'
|
||||
],
|
||||
'search': [
|
||||
'/_search'
|
||||
]
|
||||
};
|
||||
@ -1,5 +1,7 @@
|
||||
var cp = require('child_process');
|
||||
var async = require('async');
|
||||
var estream = require('event-stream');
|
||||
var chalk = require('chalk');
|
||||
var argv = require('optimist')
|
||||
.options({
|
||||
force: {
|
||||
@ -39,56 +41,72 @@ if (!argv.force && process.env.FORCE || process.env.FORCE_GEN) {
|
||||
argv.force = argv.f = process.env.FORCE || process.env.FORCE_GEN;
|
||||
}
|
||||
|
||||
var branch = argv.es_branch;
|
||||
// branch can be prefixed with = or suffixed with _nightly
|
||||
if (branch.indexOf) {
|
||||
['='].forEach(function removePrefix(pref) {
|
||||
if (branch.indexOf(pref) === 0) {
|
||||
branch = branch.substring(pref.length);
|
||||
}
|
||||
});
|
||||
function spawn(cmd, args) {
|
||||
console.log(chalk.white.bold('$ ' + cmd + ' ' + args.join(' ')));
|
||||
|
||||
['_nightly'].forEach(function removeSuffix(suf) {
|
||||
if (branch.indexOf(suf) === branch.length - suf.length) {
|
||||
branch = branch.substr(0, branch.length - suf.length);
|
||||
}
|
||||
});
|
||||
var proc = cp.spawn(cmd, args, { stdio: 'pipe'});
|
||||
var out = estream.split();
|
||||
|
||||
if (argv.verbose) {
|
||||
proc.stdout.pipe(out);
|
||||
} else {
|
||||
proc.stdout.resume();
|
||||
}
|
||||
|
||||
proc.stderr.pipe(out);
|
||||
|
||||
out
|
||||
.pipe(estream.mapSync(function indent(line) {
|
||||
return ' ' + line + '\n';
|
||||
}))
|
||||
.pipe(process.stdout);
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
||||
var stdio = [
|
||||
'ignore',
|
||||
argv.verbose ? process.stdout : 'ignore',
|
||||
process.stderr
|
||||
];
|
||||
function generateBranch(branch, i, done) {
|
||||
async.series([
|
||||
function (done) {
|
||||
if (i === 0) {
|
||||
spawn('git', ['submodule', 'update', '--init'])
|
||||
.on('exit', function (status) {
|
||||
done(status ? new Error('Unable to init submodules.') : void 0);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
done();
|
||||
},
|
||||
function (done) {
|
||||
spawn('git', ['submodule', 'foreach', [
|
||||
'git fetch origin master', 'git reset --hard', 'git clean -fdx', 'git checkout origin/' + branch
|
||||
].join(' && ')])
|
||||
.on('exit', function (status) {
|
||||
done(status ? new Error('Unable to checkout ' + branch) : void 0);
|
||||
});
|
||||
},
|
||||
function (done) {
|
||||
var tasks = [];
|
||||
|
||||
if (argv.api) {
|
||||
tasks.push(
|
||||
async.apply(require('./js_api'), branch)
|
||||
);
|
||||
}
|
||||
if (argv.tests) {
|
||||
tasks.push(
|
||||
async.apply(require('./yaml_tests'), branch)
|
||||
);
|
||||
}
|
||||
|
||||
async.parallel(tasks, done);
|
||||
}
|
||||
], done);
|
||||
}
|
||||
|
||||
async.series([
|
||||
function (done) {
|
||||
cp.spawn('git', ['submodule', 'update', '--init'], {
|
||||
stdio: stdio
|
||||
}).on('exit', function (status) {
|
||||
done(status ? new Error('Unable to init submodules.') : void 0);
|
||||
});
|
||||
},
|
||||
function (done) {
|
||||
// checkout branch and clean it
|
||||
cp.spawn('git', ['submodule', 'foreach', 'git fetch origin master && git checkout origin/' + branch + ' && git clean -f'], {
|
||||
stdio: stdio
|
||||
}).on('exit', function (status) {
|
||||
done(status ? new Error('Unable to checkout ' + branch) : void 0);
|
||||
});
|
||||
},
|
||||
function (done) {
|
||||
var tasks = [];
|
||||
|
||||
if (argv.api) {
|
||||
tasks.push(require('./js_api'));
|
||||
}
|
||||
if (argv.tests) {
|
||||
tasks.push(require('./yaml_tests'));
|
||||
}
|
||||
|
||||
async.parallel(tasks, done);
|
||||
}
|
||||
async.apply(generateBranch, 'master', 0),
|
||||
async.apply(generateBranch, '0.90', 1)
|
||||
], function (err) {
|
||||
if (err) {
|
||||
throw err;
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
var aliases; // defined at the bottom of this file.
|
||||
|
||||
module.exports = function (done) {
|
||||
module.exports = function (branch, done) {
|
||||
/**
|
||||
* Read the API actions form the rest-api-spec repo.
|
||||
* @type {[type]}
|
||||
@ -17,6 +15,9 @@ module.exports = function (done) {
|
||||
var apiSpec; // populated by parseSpecFiles
|
||||
var docVars; // slightly modified clone of apiSpec for the docs
|
||||
|
||||
var branchSuffix = branch === 'master' ? '' : '_' + _.snakeCase(branch);
|
||||
var aliases = require('./aliases' + branchSuffix);
|
||||
|
||||
// generate the API
|
||||
async.series([
|
||||
readSpecFiles,
|
||||
@ -28,9 +29,11 @@ module.exports = function (done) {
|
||||
], done);
|
||||
|
||||
function readSpecFiles(done) {
|
||||
var apiDir = '../../src/elasticsearch/rest-api-spec/api/';
|
||||
var apiDir = require('path').join(__dirname, '../../src/elasticsearch/rest-api-spec/api/');
|
||||
files = fs.readdirSync(apiDir).map(function (filename) {
|
||||
return require(apiDir + filename);
|
||||
var module = require(apiDir + filename);
|
||||
delete require.cache[apiDir + filename];
|
||||
return module;
|
||||
});
|
||||
done();
|
||||
}
|
||||
@ -68,9 +71,10 @@ module.exports = function (done) {
|
||||
}
|
||||
|
||||
function writeApiFile(done) {
|
||||
var outputPath = require('path').join(__dirname, '../../src/lib/api.js');
|
||||
console.log('writing', apiSpec.actions.length, 'api actions to', outputPath);
|
||||
fs.writeFile(outputPath, templates.apiFile(apiSpec), done);
|
||||
var outputPath = require('path').join(__dirname, '../../src/lib/api' + branchSuffix + '.js');
|
||||
fs.writeFileSync(outputPath, templates.apiFile(apiSpec));
|
||||
console.log('wrote', apiSpec.actions.length, 'api actions to', outputPath);
|
||||
done();
|
||||
}
|
||||
|
||||
function ensureDocsDir(done) {
|
||||
@ -102,7 +106,7 @@ module.exports = function (done) {
|
||||
|
||||
function writeMethodDocs(done) {
|
||||
fs.writeFile(
|
||||
'../../docs/api_methods.asciidoc',
|
||||
'../../docs/api_methods' + branchSuffix + '.asciidoc',
|
||||
templates.apiMethods(docVars),
|
||||
done
|
||||
);
|
||||
@ -186,7 +190,7 @@ module.exports = function (done) {
|
||||
});
|
||||
|
||||
if (urlSignatures.length !== _.unique(urlSignatures).length) {
|
||||
throw new Error('Multiple URLS with the same signature detected for ' + spec.name);
|
||||
throw new Error('Multiple URLS with the same signature detected for ' + spec.name + '\n' + _.pluck(urls, 'fmt').join('\n') + '\n');
|
||||
}
|
||||
|
||||
if (urls.length > 1) {
|
||||
@ -290,68 +294,3 @@ module.exports = function (done) {
|
||||
}
|
||||
};
|
||||
|
||||
aliases = {
|
||||
'cluster.nodeHotThreads': [
|
||||
'/_cluster/nodes/hotthreads',
|
||||
'/_cluster/nodes/hot_threads',
|
||||
'/_nodes/hot_threads',
|
||||
'/_cluster/nodes/{node_id}/hotthreads',
|
||||
'/_cluster/nodes/{node_id}/hot_threads',
|
||||
'/_nodes/{node_id}/hot_threads'
|
||||
],
|
||||
'cluster.nodeInfo': [
|
||||
'/_cluster/nodes',
|
||||
'/_nodes/settings',
|
||||
'/_nodes/os',
|
||||
'/_nodes/process',
|
||||
'/_nodes/jvm',
|
||||
'/_nodes/thread_pool',
|
||||
'/_nodes/network',
|
||||
'/_nodes/transport',
|
||||
'/_nodes/http',
|
||||
'/_nodes/plugin',
|
||||
'/_cluster/nodes/{node_id}',
|
||||
'/_nodes/{node_id}/settings',
|
||||
'/_nodes/{node_id}/os',
|
||||
'/_nodes/{node_id}/process',
|
||||
'/_nodes/{node_id}/jvm',
|
||||
'/_nodes/{node_id}/thread_pool',
|
||||
'/_nodes/{node_id}/network',
|
||||
'/_nodes/{node_id}/transport',
|
||||
'/_nodes/{node_id}/http',
|
||||
'/_nodes/{node_id}/plugin'
|
||||
],
|
||||
'cluster.nodeShutdown': [
|
||||
'/_cluster/nodes/_shutdown'
|
||||
],
|
||||
'cluster.nodeStats': [
|
||||
'/_cluster/nodes/stats',
|
||||
'/_nodes/stats/{metric_family}',
|
||||
'/_nodes/stats/indices/{metric}/{fields}',
|
||||
'/_cluster/nodes/{node_id}/stats',
|
||||
'/_nodes/{node_id}/stats/{metric_family}',
|
||||
'/_nodes/{node_id}/stats/indices/{metric}/{fields}'
|
||||
],
|
||||
'get': [
|
||||
'/{index}/{type}/{id}/_source'
|
||||
],
|
||||
'indices.deleteMapping': [
|
||||
'/{index}/{type}/_mapping'
|
||||
],
|
||||
'indices.deleteWarmer': [
|
||||
'/{index}/_warmer',
|
||||
'/{index}/_warmers',
|
||||
'/{index}/_warmers/{name}'
|
||||
],
|
||||
'indices.stats': [
|
||||
'_stats/{metric_family}',
|
||||
'/_stats/indexing',
|
||||
'/_stats/indexing/{indexing_types}',
|
||||
'/_stats/search/{search_groups}',
|
||||
'/_stats/fielddata/{fields}',
|
||||
'/{index}/_stats/{metric_family}',
|
||||
'/{index}/_stats/indexing',
|
||||
'/{index}/_stats/search/{search_groups}',
|
||||
'/{index}/_stats/fielddata/{fields}'
|
||||
]
|
||||
};
|
||||
@ -1,14 +1,16 @@
|
||||
module.exports = function (done) {
|
||||
|
||||
module.exports = function (branch, done) {
|
||||
/**
|
||||
* Creates a JSON version of the YAML test suite that can be simply bundled for use in the browser.
|
||||
*/
|
||||
var jsYaml = require('js-yaml');
|
||||
var fs = require('relative-fs').relativeTo(__dirname);
|
||||
var async = require('async');
|
||||
var _ = require('../../src/lib/utils');
|
||||
var path = require('path');
|
||||
var tests = {}; // populated in readYamlTests
|
||||
|
||||
var branchSuffix = branch === 'master' ? '' : '_' + _.snakeCase(branch);
|
||||
|
||||
// generate the yaml tests
|
||||
async.series([
|
||||
readYamlTests,
|
||||
@ -38,7 +40,7 @@ module.exports = function (done) {
|
||||
}
|
||||
|
||||
function writeYamlTests(done) {
|
||||
var testFile = require('path').resolve(__dirname, '../../test/integration/yaml_suite/yaml_tests.json');
|
||||
var testFile = require('path').resolve(__dirname, '../../test/integration/yaml_suite/yaml_tests' + branchSuffix + '.json');
|
||||
fs.writeFileSync(testFile, JSON.stringify(tests, null, ' '), 'utf8');
|
||||
console.log('wrote YAML tests as JSON to', testFile);
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user