-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Index Management] Add settings route api tests (#172042)
- Loading branch information
1 parent
b794378
commit a766fe6
Showing
6 changed files
with
165 additions
and
26 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
x-pack/test/api_integration/apis/management/index_management/lib/settings.api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { IndexSettings } from '@kbn/index-management-plugin/common'; | ||
|
||
import { API_BASE_PATH } from '../constants'; | ||
import { FtrProviderContext } from '../../../../ftr_provider_context'; | ||
|
||
export function settingsApi(getService: FtrProviderContext['getService']) { | ||
const supertest = getService('supertest'); | ||
|
||
const getIndexSettings = (index: string) => | ||
supertest | ||
.get(`${API_BASE_PATH}/settings/${index}`) | ||
.set('kbn-xsrf', 'xxx') | ||
.set('x-elastic-internal-origin', 'xxx'); | ||
|
||
const updateIndexSettings = (index: string, settings: IndexSettings) => | ||
supertest | ||
.put(`${API_BASE_PATH}/settings/${index}`) | ||
.set('kbn-xsrf', 'xxx') | ||
.set('x-elastic-internal-origin', 'xxx') | ||
.send(settings); | ||
|
||
return { | ||
getIndexSettings, | ||
updateIndexSettings, | ||
}; | ||
} |
20 changes: 0 additions & 20 deletions
20
x-pack/test/api_integration/apis/management/index_management/settings.helpers.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
x-pack/test_serverless/api_integration/test_suites/common/index_management/settings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
|
||
import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
||
export default function ({ getService }: FtrProviderContext) { | ||
const indexManagementService = getService('indexManagement'); | ||
|
||
describe('settings', () => { | ||
let getIndexSettings: typeof indexManagementService['settings']['api']['getIndexSettings']; | ||
let updateIndexSettings: typeof indexManagementService['settings']['api']['updateIndexSettings']; | ||
let createIndex: typeof indexManagementService['indices']['helpers']['createIndex']; | ||
let deleteAllIndices: typeof indexManagementService['indices']['helpers']['deleteAllIndices']; | ||
|
||
before(async () => { | ||
({ | ||
settings: { | ||
api: { getIndexSettings, updateIndexSettings }, | ||
}, | ||
indices: { | ||
helpers: { createIndex, deleteAllIndices }, | ||
}, | ||
} = indexManagementService); | ||
}); | ||
|
||
after(async () => await deleteAllIndices()); | ||
|
||
it('should fetch an index settings', async () => { | ||
const index = await createIndex(); | ||
|
||
const { body } = await getIndexSettings(index).expect(200); | ||
|
||
// Verify we fetch the corret index settings | ||
expect(body.settings.index.provided_name).to.be(index); | ||
|
||
const expectedSettings = [ | ||
'max_inner_result_window', | ||
'unassigned', | ||
'max_terms_count', | ||
'lifecycle', | ||
'routing_partition_size', | ||
'max_docvalue_fields_search', | ||
'merge', | ||
'max_refresh_listeners', | ||
'max_regex_length', | ||
'load_fixed_bitset_filters_eagerly', | ||
'number_of_routing_shards', | ||
'write', | ||
'verified_before_close', | ||
'mapping', | ||
'source_only', | ||
'soft_deletes', | ||
'max_script_fields', | ||
'query', | ||
'format', | ||
'frozen', | ||
'sort', | ||
'priority', | ||
'codec', | ||
'max_rescore_window', | ||
'analyze', | ||
'gc_deletes', | ||
'max_ngram_diff', | ||
'translog', | ||
'auto_expand_replicas', | ||
'requests', | ||
'data_path', | ||
'highlight', | ||
'routing', | ||
'search', | ||
'fielddata', | ||
'default_pipeline', | ||
'max_slices_per_scroll', | ||
'shard', | ||
'xpack', | ||
'percolator', | ||
'allocation', | ||
'refresh_interval', | ||
'indexing', | ||
'compound_format', | ||
'blocks', | ||
'max_result_window', | ||
'store', | ||
'queries', | ||
'warmer', | ||
'max_shingle_diff', | ||
'query_string', | ||
]; | ||
|
||
// Make sure none of the settings have been removed from ES API | ||
expectedSettings.forEach((setting) => { | ||
try { | ||
expect(body.defaults.index.hasOwnProperty(setting)).to.be(true); | ||
} catch { | ||
throw new Error(`Expected setting "${setting}" not found.`); | ||
} | ||
}); | ||
}); | ||
|
||
it('should update an index settings', async () => { | ||
const index = await createIndex(); | ||
|
||
const { body: body1 } = await getIndexSettings(index); | ||
expect(body1.settings.index.number_of_replicas).to.be('1'); | ||
|
||
const settings = { | ||
index: { | ||
number_of_replicas: 2, | ||
}, | ||
}; | ||
await updateIndexSettings(index, settings); | ||
|
||
const { body: body2 } = await getIndexSettings(index); | ||
expect(body2.settings.index.number_of_replicas).to.be('2'); | ||
}); | ||
}); | ||
} |