mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
This commit is contained in:
parent
63bac2e2a6
commit
93aa2a13a9
2 changed files with 33 additions and 2 deletions
|
@ -839,6 +839,33 @@ describe('EPM template', () => {
|
|||
});
|
||||
|
||||
describe('updateCurrentWriteIndices', () => {
|
||||
it('update all the index matching, index template index pattern', async () => {
|
||||
const esClient = elasticsearchServiceMock.createElasticsearchClient();
|
||||
esClient.indices.getDataStream.mockResolvedValue({
|
||||
body: {
|
||||
data_streams: [{ name: 'test.prefix1-default' }],
|
||||
},
|
||||
} as any);
|
||||
const logger = loggerMock.create();
|
||||
await updateCurrentWriteIndices(esClient, logger, [
|
||||
{
|
||||
templateName: 'test',
|
||||
indexTemplate: {
|
||||
index_patterns: ['test.*-*'],
|
||||
template: {
|
||||
settings: { index: {} },
|
||||
mappings: { properties: {} },
|
||||
},
|
||||
} as any,
|
||||
},
|
||||
]);
|
||||
expect(esClient.indices.getDataStream).toBeCalledWith({
|
||||
name: 'test.*-*',
|
||||
});
|
||||
const putMappingsCall = esClient.indices.putMapping.mock.calls.map(([{ index }]) => index);
|
||||
expect(putMappingsCall).toHaveLength(1);
|
||||
expect(putMappingsCall[0]).toBe('test.prefix1-default');
|
||||
});
|
||||
it('update non replicated datastream', async () => {
|
||||
const esClient = elasticsearchServiceMock.createElasticsearchClient();
|
||||
esClient.indices.getDataStream.mockResolvedValue({
|
||||
|
@ -854,6 +881,7 @@ describe('EPM template', () => {
|
|||
{
|
||||
templateName: 'test',
|
||||
indexTemplate: {
|
||||
index_patterns: ['test-*'],
|
||||
template: {
|
||||
settings: { index: {} },
|
||||
mappings: { properties: {} },
|
||||
|
|
|
@ -468,8 +468,11 @@ const getDataStreams = async (
|
|||
esClient: ElasticsearchClient,
|
||||
template: IndexTemplateEntry
|
||||
): Promise<CurrentDataStream[] | undefined> => {
|
||||
const { templateName, indexTemplate } = template;
|
||||
const { body } = await esClient.indices.getDataStream({ name: `${templateName}-*` });
|
||||
const { indexTemplate } = template;
|
||||
|
||||
const { body } = await esClient.indices.getDataStream({
|
||||
name: indexTemplate.index_patterns.join(','),
|
||||
});
|
||||
|
||||
const dataStreams = body.data_streams;
|
||||
if (!dataStreams.length) return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue