From 123f392f828f19896b921e3684f37c3e7a96515d Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 8 Apr 2021 11:38:15 +0200 Subject: [PATCH 1/3] Wrap inside array ndjson bodies --- test/integration/test-runner.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 77be7a9b3..542830d60 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -25,6 +25,8 @@ const assert = require('assert') const semver = require('semver') const helper = require('./helper') const deepEqual = require('fast-deep-equal') +const { join } = require('path') +const { locations } = require('clone-elasticsearch') const { ConfigurationError } = require('../../lib/errors') const { delve, to, isXPackTemplate, sleep } = helper @@ -362,6 +364,11 @@ function build (opts = {}) { if (!Array.isArray(options.ignore)) options.ignore = [options.ignore] if (cmd.params.ignore) delete cmd.params.ignore + // ndjson apis should always send the body as an array + if (isNDJson(cmd.method) && !Array.isArray(cmd.params.body)) { + cmd.params.body = [cmd.params.body] + } + const [err, result] = await to(api(cmd.params, options)) let warnings = result ? result.warnings : null const body = result ? result.body : null @@ -848,6 +855,12 @@ function shouldSkip (esVersion, action) { return false } +function isNDJson (api) { + const spec = require(join(locations.specFolder, `${api}.json`)) + const { content_type } = spec[Object.keys(spec)[0]].headers + return Boolean(content_type && content_type.includes('application/x-ndjson')) +} + /** * Updates the array syntax of keys and values * eg: 'hits.hits.1.stuff' to 'hits.hits[1].stuff' From f8a2773fdc79b0ded7af77f8f28a2f7317e9303d Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 8 Apr 2021 15:02:30 +0200 Subject: [PATCH 2/3] Fix path --- test/integration/test-runner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 542830d60..68e3c6213 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -26,7 +26,7 @@ const semver = require('semver') const helper = require('./helper') const deepEqual = require('fast-deep-equal') const { join } = require('path') -const { locations } = require('clone-elasticsearch') +const { locations } = require('../../scripts/download-artifacts') const { ConfigurationError } = require('../../lib/errors') const { delve, to, isXPackTemplate, sleep } = helper From d82f8806be59ceb75d19515de317f0339f1f4135 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 8 Apr 2021 15:24:55 +0200 Subject: [PATCH 3/3] Use orignal api name --- test/integration/test-runner.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 68e3c6213..7dbd7c158 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -365,7 +365,7 @@ function build (opts = {}) { if (cmd.params.ignore) delete cmd.params.ignore // ndjson apis should always send the body as an array - if (isNDJson(cmd.method) && !Array.isArray(cmd.params.body)) { + if (isNDJson(cmd.api) && !Array.isArray(cmd.params.body)) { cmd.params.body = [cmd.params.body] } @@ -703,6 +703,7 @@ function parseDo (action) { // converts underscore to camelCase // eg: put_mapping => putMapping acc.method = val.replace(/_([a-z])/g, g => g[1].toUpperCase()) + acc.api = val acc.params = camelify(action[val]) } return acc