- 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
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
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,
|
|
writeYamlTests
|
|
], done);
|
|
|
|
function readYamlTests(done) {
|
|
var testDir = path.join(__dirname, '../../src/elasticsearch/rest-api-spec/test/');
|
|
|
|
function readDirectories(dir) {
|
|
fs.readdirSync(dir).forEach(function (filename) {
|
|
var filePath = path.join(dir, filename);
|
|
var stat = fs.statSync(filePath);
|
|
if (stat.isDirectory()) {
|
|
readDirectories(filePath);
|
|
} else if (filename.match(/\.yaml$/)) {
|
|
var file = tests[path.relative(testDir, filePath)] = [];
|
|
jsYaml.loadAll(fs.readFileSync(filePath, 'utf8'), function (doc) {
|
|
file.push(doc);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
readDirectories(testDir);
|
|
done();
|
|
}
|
|
|
|
function writeYamlTests(done) {
|
|
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();
|
|
}
|
|
}; |