diff --git a/test/integration/yaml_suite/client_manager.js b/test/integration/yaml_suite/client_manager.js index c7328ef20..6c63b8258 100644 --- a/test/integration/yaml_suite/client_manager.js +++ b/test/integration/yaml_suite/client_manager.js @@ -13,6 +13,7 @@ var _ = require('../../../src/lib/utils'); var argv = require('./argv'); var path = require('path'); var fs = require('fs'); +var async = require('async'); var fromRoot = _.bindKey(path, 'join', require('find-root')(__dirname)); // current client @@ -94,6 +95,17 @@ module.exports = { log: logConfig }); + client.clearEs = function (done) { + async.parallel([ + function (done) { + client.indices.delete({ index: '*', ignore: 404 }, done); + }, + function (done) { + client.indices.deleteTemplate({ name: '*', ignore: 404 }, done); + } + ], done); + }; + _.nextTick(cb); } }, diff --git a/test/integration/yaml_suite/run.js b/test/integration/yaml_suite/run.js index f1497debe..93c02019b 100644 --- a/test/integration/yaml_suite/run.js +++ b/test/integration/yaml_suite/run.js @@ -1,6 +1,5 @@ module.exports = function (branch) { var path = require('path'); - var async = require('async'); var jsYaml = require('js-yaml'); var YamlFile = require('./yaml_file'); var root = require('find-root')(__dirname); @@ -23,15 +22,7 @@ module.exports = function (branch) { before(function (done) { // make sure ES is empty - var client = clientManager.get(); - async.parallel([ - function (done) { - client.indices.delete({ index: '*', ignore: 404 }, done); - }, - function (done) { - client.indices.deleteTemplate({ name: '*', ignore: 404 }, done); - } - ], done); + clientManager.get().clearEs(done); }); var files = _.map(require('./yaml_tests_' + _.snakeCase(branch) + '.json'), function (docs, filename) { diff --git a/test/integration/yaml_suite/yaml_doc.js b/test/integration/yaml_suite/yaml_doc.js index a5acf7cd3..b1598639b 100644 --- a/test/integration/yaml_suite/yaml_doc.js +++ b/test/integration/yaml_suite/yaml_doc.js @@ -96,10 +96,7 @@ function rangeMatchesCurrentVersion(rangeString, done) { // empty all of the indices in ES please function clearIndices(done) { - clientManager.get().indices.delete({ - index: '*', - ignore: 404 - }, done); + clientManager.get().clearEs(done); } function YamlDoc(doc, file) { diff --git a/test/integration/yaml_suite/yaml_file.js b/test/integration/yaml_suite/yaml_file.js index f09ca2db7..09fe8460c 100644 --- a/test/integration/yaml_suite/yaml_file.js +++ b/test/integration/yaml_suite/yaml_file.js @@ -30,10 +30,7 @@ function YamlFile(filename, docs) { }); afterEach(/* doc */function (done) { - clientManager.get().indices.delete({ - index: '*', - ignore: 404 - }, done); + clientManager.get().clearEs(done); }); });