diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 77be7a9b3..7dbd7c158 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('../../scripts/download-artifacts') 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.api) && !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 @@ -696,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 @@ -848,6 +856,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'