Skip to content

Commit

Permalink
Sync integration test with main
Browse files Browse the repository at this point in the history
  • Loading branch information
delvedor committed Feb 11, 2022
1 parent 4745ee7 commit a42abc8
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 2,085 deletions.
51 changes: 46 additions & 5 deletions test/integration/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

'use strict'

const assert = require('assert')
const fetch = require('node-fetch')

function runInParallel (client, operation, options, clientOptions) {
if (options.length === 0) return Promise.resolve()
const operations = options.map(opts => {
Expand Down Expand Up @@ -65,6 +68,9 @@ function isXPackTemplate (name) {
if (name.startsWith('.transform-')) {
return true
}
if (name.startsWith('.deprecation-')) {
return true
}
switch (name) {
case '.watches':
case 'logstash-index-template':
Expand All @@ -84,14 +90,49 @@ function isXPackTemplate (name) {
case 'synthetics-settings':
case 'synthetics-mappings':
case '.snapshot-blob-cache':
case '.deprecation-indexing-template':
case '.deprecation-indexing-mappings':
case '.deprecation-indexing-settings':
case 'data-streams-mappings':
case '.logs-deprecation.elasticsearch-default':
return true
}
return false
}

module.exports = { runInParallel, delve, to, sleep, isXPackTemplate }
async function getSpec () {
const response = await fetch('https://raw.githubusercontent.com/elastic/elasticsearch-specification/main/output/schema/schema.json')
return await response.json()
}

let spec = null

// some keys for the path used in the yaml test are not support in the client
// for example: snapshot.createRepository({ repository }) will not work.
// This code changes the params to the appropriate name, in the example above,
// "repository" will be renamed to "name"
async function updateParams (cmd) {
if (spec == null) {
spec = await getSpec()
}
const endpoint = spec.endpoints.find(endpoint => endpoint.name === cmd.api)
assert(endpoint != null)
if (endpoint.request == null) return cmd

const type = spec.types.find(type => type.name.name === endpoint.request.name && type.name.namespace === endpoint.request.namespace)
assert(type != null)

const pathParams = type.path.reduce((acc, val) => {
if (val.codegenName != null) {
acc[val.name] = val.codegenName
}
return acc
}, {})

for (const key in cmd.params) {
if (pathParams[key] != null) {
cmd.params[pathParams[key]] = cmd.params[key]
delete cmd.params[key]
}
}

return cmd
}

module.exports = { runInParallel, delve, to, sleep, isXPackTemplate, updateParams }
15 changes: 14 additions & 1 deletion test/integration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const { join, sep } = require('path')
const yaml = require('js-yaml')
const ms = require('ms')
const { Client } = require('../../index')
const { kProductCheck } = require('@elastic/transport/lib/symbols')
const build = require('./test-runner')
const { sleep } = require('./helper')
const createJunitReporter = require('./reporter')
Expand All @@ -49,6 +50,8 @@ const freeSkips = {
'Body params with array param override query string',
'Body params with string param scroll id override query string'
],
'free/cat.allocation/10_basic.yml': ['*'],
'free/cat.snapshots/10_basic.yml': ['Test cat snapshots output'],
// TODO: remove this once 'arbitrary_key' is implemented
// https://github.com/elastic/elasticsearch/pull/41492
'indices.split/30_copy_settings.yml': ['*'],
Expand All @@ -62,9 +65,11 @@ const freeSkips = {
'search.aggregation/240_max_buckets.yml': ['*'],
// the yaml runner assumes that null means "does not exists",
// while null is a valid json value, so the check will fail
'search/320_disallow_queries.yml': ['Test disallow expensive queries']
'search/320_disallow_queries.yml': ['Test disallow expensive queries'],
'free/tsdb/90_unsupported_operations.yml': ['noop update']
}
const platinumBlackList = {
'api_key/20_query.yml': ['*'],
'analytics/histogram.yml': ['Histogram requires values in increasing order'],
// this two test cases are broken, we should
// return on those in the future.
Expand Down Expand Up @@ -93,9 +98,15 @@ const platinumBlackList = {
// The cleanup fails with a index not found when retrieving the jobs
'ml/get_datafeed_stats.yml': ['Test get datafeed stats when total_search_time_ms mapping is missing'],
'ml/bucket_correlation_agg.yml': ['Test correlation bucket agg simple'],
// start should be a string
'ml/jobs_get_result_overall_buckets.yml': ['Test overall buckets given epoch start and end params'],
// this can't happen with the client
'ml/start_data_frame_analytics.yml': ['Test start with inconsistent body/param ids'],
'ml/stop_data_frame_analytics.yml': ['Test stop with inconsistent body/param ids'],
'ml/preview_datafeed.yml': ['*'],
// Investigate why is failing
'ml/inference_crud.yml': ['*'],
'ml/categorization_agg.yml': ['Test categorization aggregation with poor settings'],
// investigate why this is failing
'monitoring/bulk/10_basic.yml': ['*'],
'monitoring/bulk/20_privileges.yml': ['*'],
Expand Down Expand Up @@ -161,6 +172,8 @@ function runner (opts = {}) {
}
}
const client = new Client(options)
// TODO: remove the following line once https://github.com/elastic/elasticsearch/issues/82358 is fixed
client.transport[kProductCheck] = null
log('Loading yaml suite')
start({ client, isXPack: opts.isXPack })
.catch(err => {
Expand Down
52 changes: 0 additions & 52 deletions test/integration/integration/README.md

This file was deleted.

96 changes: 0 additions & 96 deletions test/integration/integration/helper.js

This file was deleted.

Loading

0 comments on commit a42abc8

Please sign in to comment.