Added API generation and Yaml testing for 1.x and 1.0 branches of elasticsearch.
This commit is contained in:
@ -16,9 +16,9 @@ function spawn(cmd, args, opts, cb) {
|
||||
|
||||
if (opts.cwd) {
|
||||
conf.cwd = opts.cwd;
|
||||
subdir = path.relative(root, opts.cwd) + ' ';
|
||||
subdir = path.relative(root, opts.cwd);
|
||||
}
|
||||
console.log(chalk.white.bold((subdir || '') + '$ ') + cmd + ' ' + args.join(' '));
|
||||
console.log(chalk.white.bold((subdir ? subdir + ' ' : '') + '$ ') + cmd + ' ' + args.join(' '));
|
||||
|
||||
var proc = cp.spawn(cmd, args, opts);
|
||||
var out = estream.split();
|
||||
|
||||
@ -25,8 +25,15 @@ var argv = require('optimist')
|
||||
var path = require('path');
|
||||
var root = require('find-root')(__dirname);
|
||||
var fromRoot = path.join.bind(path, root);
|
||||
var _ = require(fromRoot('src/lib/utils'));
|
||||
var utils = require(fromRoot('grunt/utils'));
|
||||
var esUrl = 'https://github.com/elasticsearch/elasticsearch.git';
|
||||
var branches;
|
||||
|
||||
if (process.env.ES_GIT_BRANCH) {
|
||||
branches = [process.env.ES_GIT_BRANCH.split('/').slice(1).join('/')];
|
||||
} else {
|
||||
branches = utils.branches;
|
||||
}
|
||||
|
||||
if (process.env.npm_config_argv) {
|
||||
// when called by NPM
|
||||
@ -43,8 +50,7 @@ function isDirectory(dir) {
|
||||
}
|
||||
|
||||
function storeDir(branch) {
|
||||
var suffix = branch === 'master' ? '' : '_' + _.snakeCase(branch);
|
||||
return fromRoot('src/elasticsearch' + suffix);
|
||||
return fromRoot('src/elasticsearch' + utils.branchSuffix(branch));
|
||||
}
|
||||
|
||||
function spawnStep(cmd, args, cwd) {
|
||||
@ -98,7 +104,7 @@ function generateStep(branch) {
|
||||
}
|
||||
|
||||
var steps = [];
|
||||
['master', '0.90'].forEach(function (branch) {
|
||||
branches.forEach(function (branch) {
|
||||
steps.push(
|
||||
checkoutStep(branch),
|
||||
updateStep(branch),
|
||||
|
||||
@ -4,6 +4,7 @@ module.exports = function (branch, done) {
|
||||
* @type {[type]}
|
||||
*/
|
||||
var _ = require('../../src/lib/utils');
|
||||
var utils = require('../../grunt/utils');
|
||||
var fs = require('fs');
|
||||
var async = require('async');
|
||||
var chalk = require('chalk');
|
||||
@ -16,9 +17,15 @@ module.exports = function (branch, done) {
|
||||
var apiSpec; // populated by parseSpecFiles
|
||||
var docVars; // slightly modified clone of apiSpec for the docs
|
||||
|
||||
var branchSuffix = branch === 'master' ? '' : '_' + _.snakeCase(branch);
|
||||
var branchSuffix = utils.branchSuffix(branch);
|
||||
var esDir = fromRoot('src/elasticsearch' + branchSuffix);
|
||||
var aliases = require('./aliases' + branchSuffix);
|
||||
var aliases;
|
||||
try {
|
||||
aliases = require('./aliases_' + _.snakeCase(branch));
|
||||
} catch (e) {
|
||||
// fall back to the master aliases
|
||||
aliases = require('./aliases');
|
||||
}
|
||||
|
||||
// generate the API
|
||||
async.series([
|
||||
@ -89,7 +96,7 @@ module.exports = function (branch, done) {
|
||||
}
|
||||
|
||||
function writeApiFile(done) {
|
||||
var outputPath = fromRoot('src/lib/api' + branchSuffix + '.js');
|
||||
var outputPath = fromRoot('src/lib/apis/' + _.snakeCase(branch) + '.js');
|
||||
fs.writeFileSync(outputPath, templates.apiFile(apiSpec));
|
||||
console.log(chalk.white.bold('wrote'), apiSpec.actions.length, 'api actions to', outputPath);
|
||||
done();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* jshint maxlen: false */
|
||||
|
||||
var ca = require('./client_action');
|
||||
var ca = require('../client_action');
|
||||
var api = module.exports = {};
|
||||
|
||||
api._namespaces = <%= stringify(namespaces) %>;<%
|
||||
|
||||
@ -1,16 +1,10 @@
|
||||
[[api-reference<%= branchSuffix %>]]<%
|
||||
|
||||
if ( branch === 'master' ) {%>
|
||||
== 1.0 API
|
||||
|
||||
NOTE: At this time, you must opt into the 1.0 API by setting the `apiVerion` config parameter.
|
||||
|
||||
<%
|
||||
} else {%>
|
||||
== 0.90 API
|
||||
|
||||
NOTE: This is currently the default API, but with the upcoming release of Elasticsearch 1.0 that will change. We recommend setting the `apiVersion` config param when you instantiate your client to make sure that the API does not change when the default does.
|
||||
[[api-reference<%= branchSuffix %>]]
|
||||
== <%= branch %> API
|
||||
|
||||
<% if (branchSuffix) { %>
|
||||
NOTE: At this time, you must opt into the <%= branch %> API by setting the `apiVerion` config parameter.
|
||||
<% } else { %>
|
||||
NOTE: This is currently the default API, but in upcomming versions that will change. We recommend setting the `apiVersion` config param when you instantiate your client to make sure that the API does not change unexpectedly.
|
||||
<%
|
||||
}
|
||||
|
||||
|
||||
@ -8,16 +8,17 @@ module.exports = function (branch, done) {
|
||||
var chalk = require('chalk');
|
||||
var path = require('path');
|
||||
var fromRoot = path.join.bind(path, require('find-root')(__dirname));
|
||||
var _ = require(fromRoot('src/lib/utils'));
|
||||
var utils = require(fromRoot('grunt/utils'));
|
||||
var tests = {}; // populated in readYamlTests
|
||||
|
||||
var branchSuffix = branch === 'master' ? '' : '_' + _.snakeCase(branch);
|
||||
var branchSuffix = utils.branchSuffix(branch);
|
||||
var esDir = fromRoot('src/elasticsearch' + branchSuffix);
|
||||
|
||||
// generate the yaml tests
|
||||
async.series([
|
||||
readYamlTests,
|
||||
writeYamlTests
|
||||
writeYamlTests,
|
||||
writeTestIndex
|
||||
], done);
|
||||
|
||||
function readYamlTests(done) {
|
||||
@ -48,4 +49,11 @@ module.exports = function (branch, done) {
|
||||
console.log(chalk.white.bold('wrote') + ' YAML tests as JSON to', testFile);
|
||||
done();
|
||||
}
|
||||
|
||||
function writeTestIndex(done) {
|
||||
var file = fromRoot('test/integration/yaml_suite/index' + branchSuffix + '.js');
|
||||
fs.writeFileSync(file, 'require(\'./run\')(\'' + branch + '\');', 'utf8');
|
||||
console.log(chalk.white.bold('wrote') + ' YAML index to', file);
|
||||
done();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user