Skip to content

Commit a42abc8

Browse files
committed
Sync integration test with main
1 parent 4745ee7 commit a42abc8

File tree

12 files changed

+89
-2085
lines changed

12 files changed

+89
-2085
lines changed

test/integration/helper.js

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919

2020
'use strict'
2121

22+
const assert = require('assert')
23+
const fetch = require('node-fetch')
24+
2225
function runInParallel (client, operation, options, clientOptions) {
2326
if (options.length === 0) return Promise.resolve()
2427
const operations = options.map(opts => {
@@ -65,6 +68,9 @@ function isXPackTemplate (name) {
6568
if (name.startsWith('.transform-')) {
6669
return true
6770
}
71+
if (name.startsWith('.deprecation-')) {
72+
return true
73+
}
6874
switch (name) {
6975
case '.watches':
7076
case 'logstash-index-template':
@@ -84,14 +90,49 @@ function isXPackTemplate (name) {
8490
case 'synthetics-settings':
8591
case 'synthetics-mappings':
8692
case '.snapshot-blob-cache':
87-
case '.deprecation-indexing-template':
88-
case '.deprecation-indexing-mappings':
89-
case '.deprecation-indexing-settings':
9093
case 'data-streams-mappings':
91-
case '.logs-deprecation.elasticsearch-default':
9294
return true
9395
}
9496
return false
9597
}
9698

97-
module.exports = { runInParallel, delve, to, sleep, isXPackTemplate }
99+
async function getSpec () {
100+
const response = await fetch('https://raw.githubusercontent.com/elastic/elasticsearch-specification/main/output/schema/schema.json')
101+
return await response.json()
102+
}
103+
104+
let spec = null
105+
106+
// some keys for the path used in the yaml test are not support in the client
107+
// for example: snapshot.createRepository({ repository }) will not work.
108+
// This code changes the params to the appropriate name, in the example above,
109+
// "repository" will be renamed to "name"
110+
async function updateParams (cmd) {
111+
if (spec == null) {
112+
spec = await getSpec()
113+
}
114+
const endpoint = spec.endpoints.find(endpoint => endpoint.name === cmd.api)
115+
assert(endpoint != null)
116+
if (endpoint.request == null) return cmd
117+
118+
const type = spec.types.find(type => type.name.name === endpoint.request.name && type.name.namespace === endpoint.request.namespace)
119+
assert(type != null)
120+
121+
const pathParams = type.path.reduce((acc, val) => {
122+
if (val.codegenName != null) {
123+
acc[val.name] = val.codegenName
124+
}
125+
return acc
126+
}, {})
127+
128+
for (const key in cmd.params) {
129+
if (pathParams[key] != null) {
130+
cmd.params[pathParams[key]] = cmd.params[key]
131+
delete cmd.params[key]
132+
}
133+
}
134+
135+
return cmd
136+
}
137+
138+
module.exports = { runInParallel, delve, to, sleep, isXPackTemplate, updateParams }

test/integration/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const { join, sep } = require('path')
2929
const yaml = require('js-yaml')
3030
const ms = require('ms')
3131
const { Client } = require('../../index')
32+
const { kProductCheck } = require('@elastic/transport/lib/symbols')
3233
const build = require('./test-runner')
3334
const { sleep } = require('./helper')
3435
const createJunitReporter = require('./reporter')
@@ -49,6 +50,8 @@ const freeSkips = {
4950
'Body params with array param override query string',
5051
'Body params with string param scroll id override query string'
5152
],
53+
'free/cat.allocation/10_basic.yml': ['*'],
54+
'free/cat.snapshots/10_basic.yml': ['Test cat snapshots output'],
5255
// TODO: remove this once 'arbitrary_key' is implemented
5356
// https://github.com/elastic/elasticsearch/pull/41492
5457
'indices.split/30_copy_settings.yml': ['*'],
@@ -62,9 +65,11 @@ const freeSkips = {
6265
'search.aggregation/240_max_buckets.yml': ['*'],
6366
// the yaml runner assumes that null means "does not exists",
6467
// while null is a valid json value, so the check will fail
65-
'search/320_disallow_queries.yml': ['Test disallow expensive queries']
68+
'search/320_disallow_queries.yml': ['Test disallow expensive queries'],
69+
'free/tsdb/90_unsupported_operations.yml': ['noop update']
6670
}
6771
const platinumBlackList = {
72+
'api_key/20_query.yml': ['*'],
6873
'analytics/histogram.yml': ['Histogram requires values in increasing order'],
6974
// this two test cases are broken, we should
7075
// return on those in the future.
@@ -93,9 +98,15 @@ const platinumBlackList = {
9398
// The cleanup fails with a index not found when retrieving the jobs
9499
'ml/get_datafeed_stats.yml': ['Test get datafeed stats when total_search_time_ms mapping is missing'],
95100
'ml/bucket_correlation_agg.yml': ['Test correlation bucket agg simple'],
101+
// start should be a string
102+
'ml/jobs_get_result_overall_buckets.yml': ['Test overall buckets given epoch start and end params'],
103+
// this can't happen with the client
104+
'ml/start_data_frame_analytics.yml': ['Test start with inconsistent body/param ids'],
105+
'ml/stop_data_frame_analytics.yml': ['Test stop with inconsistent body/param ids'],
96106
'ml/preview_datafeed.yml': ['*'],
97107
// Investigate why is failing
98108
'ml/inference_crud.yml': ['*'],
109+
'ml/categorization_agg.yml': ['Test categorization aggregation with poor settings'],
99110
// investigate why this is failing
100111
'monitoring/bulk/10_basic.yml': ['*'],
101112
'monitoring/bulk/20_privileges.yml': ['*'],
@@ -161,6 +172,8 @@ function runner (opts = {}) {
161172
}
162173
}
163174
const client = new Client(options)
175+
// TODO: remove the following line once https://github.com/elastic/elasticsearch/issues/82358 is fixed
176+
client.transport[kProductCheck] = null
164177
log('Loading yaml suite')
165178
start({ client, isXPack: opts.isXPack })
166179
.catch(err => {

test/integration/integration/README.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

test/integration/integration/helper.js

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)