diff --git a/x-pack/test/api_integration/apis/management/index_management/data_streams.ts b/x-pack/test/api_integration/apis/management/index_management/data_streams.ts index bfbc15ea61ddf..3b3575168e9d3 100644 --- a/x-pack/test/api_integration/apis/management/index_management/data_streams.ts +++ b/x-pack/test/api_integration/apis/management/index_management/data_streams.ts @@ -182,83 +182,45 @@ export default function ({ getService }: FtrProviderContext) { await deleteDataStream(logsdbDataStreamName); }); - it('returns logsdb index mode for logs-*-* data stream if logsdg.enabled setting is true', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: true, - }, - }, - }, - }, - }); - - const logsdbDataStreamName = 'logs-test-1'; - await createDataStream(logsdbDataStreamName); - - const { body: dataStream } = await supertest - .get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`) - .set('kbn-xsrf', 'xxx') - .expect(200); + describe('index mode of logs-*-* data streams', () => { + const logsdbDataStreamName = 'logs-test-ds'; - expect(dataStream.indexMode).to.eql('logsdb'); - - await deleteDataStream(logsdbDataStreamName); - }); - - it('returns standard index mode for logs-*-* data stream if logsdg.enabled setting is false', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: false, - }, - }, - }, - }, + before(async () => { + await svlDatastreamsHelpers.createDataStream(logsdbDataStreamName); }); - const logsdbDataStreamName = 'logs-test-2'; - await createDataStream(logsdbDataStreamName); - - const { body: dataStream } = await supertest - .get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`) - .set('kbn-xsrf', 'xxx') - .expect(200); - - expect(dataStream.indexMode).to.eql('standard'); - - await deleteDataStream(logsdbDataStreamName); - }); + after(async () => { + await svlDatastreamsHelpers.deleteDataStream(logsdbDataStreamName); + }); - // In stateful Kibana, the cluster.logsdb.enabled setting is false by default - it('returns standard index mode for logs-*-* data stream if logsdg.enabled setting is not set', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: null, + const logsdbSettings: Array<{ enabled: boolean | null; indexMode: string }> = [ + { enabled: true, indexMode: 'logsdb' }, + { enabled: false, indexMode: 'standard' }, + { enabled: null, indexMode: 'standard' }, // In stateful Kibana, the cluster.logsdb.enabled setting is false by default, so standard index mode + ]; + + logsdbSettings.forEach(({ enabled, indexMode }) => { + it(`returns ${indexMode} index mode if logsdb.enabled setting is ${enabled}`, async () => { + await es.cluster.putSettings({ + body: { + persistent: { + cluster: { + logsdb: { + enabled, + }, + }, }, }, - }, - }, - }); + }); - const logsdbDataStreamName = 'logs-test-3'; - await createDataStream(logsdbDataStreamName); + const { body: dataStream } = await supertest + .get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`) + .set('kbn-xsrf', 'xxx') + .expect(200); - const { body: dataStream } = await supertest - .get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`) - .set('kbn-xsrf', 'xxx') - .expect(200); - - expect(dataStream.indexMode).to.eql('standard'); - - await deleteDataStream(logsdbDataStreamName); + expect(dataStream.indexMode).to.eql(indexMode); + }); + }); }); }); }); diff --git a/x-pack/test/api_integration/apis/management/index_management/templates.ts b/x-pack/test/api_integration/apis/management/index_management/templates.ts index 8631c40077459..acd8f0e21deef 100644 --- a/x-pack/test/api_integration/apis/management/index_management/templates.ts +++ b/x-pack/test/api_integration/apis/management/index_management/templates.ts @@ -246,56 +246,29 @@ export default function ({ getService }: FtrProviderContext) { await deleteTemplates([{ name: logsdbTemplateName }]); }); - it('returns logsdb index mode if logsdg.enabled setting is true', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: true, + const logsdbSettings: Array<{ enabled: boolean | null; indexMode: string }> = [ + { enabled: true, indexMode: 'logsdb' }, + { enabled: false, indexMode: 'standard' }, + { enabled: null, indexMode: 'logsdb' }, // In stateful Kibana, the cluster.logsdb.enabled setting is false by default, so standard index mode + ]; + + logsdbSettings.forEach(({ enabled, indexMode }) => { + it(`returns ${indexMode} index mode if logsdb.enabled setting is ${enabled}`, async () => { + await es.cluster.putSettings({ + body: { + persistent: { + cluster: { + logsdb: { + enabled, + }, }, }, }, - }, - }); + }); - const { body } = await getOneTemplate(logsdbTemplateName).expect(200); - expect(body.indexMode).to.equal('logsdb'); - }); - - it('returns standard index mode if logsdg.enabled setting is false', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: false, - }, - }, - }, - }, + const { body } = await getOneTemplate(logsdbTemplateName).expect(200); + expect(body.indexMode).to.equal(indexMode); }); - - const { body } = await getOneTemplate(logsdbTemplateName).expect(200); - expect(body.indexMode).to.equal('standard'); - }); - - // In stateful Kibana, the cluster.logsdb.enabled setting is false by default - it('returns standard index mode if logsdg.enabled setting is not set', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: null, - }, - }, - }, - }, - }); - - const { body } = await getOneTemplate(logsdbTemplateName).expect(200); - expect(body.indexMode).to.equal('standard'); }); }); }); diff --git a/x-pack/test_serverless/api_integration/test_suites/common/index_management/datastreams.ts b/x-pack/test_serverless/api_integration/test_suites/common/index_management/datastreams.ts index c52f2fcbd0c46..7b1cea7b59cf5 100644 --- a/x-pack/test_serverless/api_integration/test_suites/common/index_management/datastreams.ts +++ b/x-pack/test_serverless/api_integration/test_suites/common/index_management/datastreams.ts @@ -128,100 +128,44 @@ export default function ({ getService }: FtrProviderContext) { }); }); - describe('index mode', () => { - it('correctly returns index mode property based on index settings', async () => { - const logsdbDataStreamName = 'logsdb-test-data-stream'; - const indexMode = 'logsdb'; + describe('index mode of logs-*-* data streams', () => { + const logsdbDataStreamName = 'logs-test-ds'; - await svlDatastreamsHelpers.createDataStream(logsdbDataStreamName, indexMode); - - const { body: dataStream } = await supertest - .get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`) - .set('kbn-xsrf', 'xxx') - .expect(200); - - expect(dataStream.indexMode).to.eql(indexMode); - - await svlDatastreamsHelpers.deleteDataStream(logsdbDataStreamName); - }); - - it('returns logsdb index mode for logs-*-* data stream if logsdg.enabled setting is true', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: true, - }, - }, - }, - }, - }); - - const logsdbDataStreamName = 'logs-test-1'; + before(async () => { await svlDatastreamsHelpers.createDataStream(logsdbDataStreamName); - - const { body: dataStream } = await supertest - .get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`) - .set('kbn-xsrf', 'xxx') - .expect(200); - - expect(dataStream.indexMode).to.eql('logsdb'); - - await svlDatastreamsHelpers.deleteDataStream(logsdbDataStreamName); }); - it('returns standard index mode for logs-*-* data stream if logsdg.enabled setting is false', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: false, - }, - }, - }, - }, - }); - - const logsdbDataStreamName = 'logs-test-2'; - await svlDatastreamsHelpers.createDataStream(logsdbDataStreamName); - - const { body: dataStream } = await supertest - .get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`) - .set('kbn-xsrf', 'xxx') - .expect(200); - - expect(dataStream.indexMode).to.eql('standard'); - + after(async () => { await svlDatastreamsHelpers.deleteDataStream(logsdbDataStreamName); }); - // In serverless Kibana, the cluster.logsdb.enabled setting is true by default - it('returns logsdb index mode for logs-*-* data stream if logsdg.enabled setting is not set', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: null, + const logsdbSettings: Array<{ enabled: boolean | null; indexMode: string }> = [ + { enabled: true, indexMode: 'logsdb' }, + { enabled: false, indexMode: 'standard' }, + { enabled: null, indexMode: 'logsdb' }, // In serverless Kibana, the cluster.logsdb.enabled setting is true by default, so logsdb index mode + ]; + + logsdbSettings.forEach(({ enabled, indexMode }) => { + it(`returns ${indexMode} index mode if logsdb.enabled setting is ${enabled}`, async () => { + await es.cluster.putSettings({ + body: { + persistent: { + cluster: { + logsdb: { + enabled, + }, }, }, }, - }, - }); - - const logsdbDataStreamName = 'logs-test-3'; - await svlDatastreamsHelpers.createDataStream(logsdbDataStreamName); - - const { body: dataStream } = await supertest - .get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`) - .set('kbn-xsrf', 'xxx') - .expect(200); + }); - expect(dataStream.indexMode).to.eql('logsdb'); + const { body: dataStream } = await supertest + .get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`) + .set('kbn-xsrf', 'xxx') + .expect(200); - await svlDatastreamsHelpers.deleteDataStream(logsdbDataStreamName); + expect(dataStream.indexMode).to.eql(indexMode); + }); }); }); }); diff --git a/x-pack/test_serverless/api_integration/test_suites/common/index_management/index_templates.ts b/x-pack/test_serverless/api_integration/test_suites/common/index_management/index_templates.ts index 3471ed2cb08e2..45edb3432c615 100644 --- a/x-pack/test_serverless/api_integration/test_suites/common/index_management/index_templates.ts +++ b/x-pack/test_serverless/api_integration/test_suites/common/index_management/index_templates.ts @@ -133,75 +133,40 @@ export default function ({ getService }: FtrProviderContext) { const template = svlTemplatesHelpers.getTemplatePayload(logsdbTemplateName, [ 'logs-*-*', ]); - await svlTemplatesApi.createTemplate(template).expect(200); + await svlTemplatesApi.createTemplate(template, roleAuthc).expect(200); }); after(async () => { - await svlTemplatesApi.deleteTemplates([{ name: logsdbTemplateName }]); + await svlTemplatesApi.deleteTemplates([{ name: logsdbTemplateName }, roleAuthc]); }); - it('returns logsdb index mode if logsdg.enabled setting is true', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: true, + const logsdbSettings: Array<{ enabled: boolean | null; indexMode: string }> = [ + { enabled: true, indexMode: 'logsdb' }, + { enabled: false, indexMode: 'standard' }, + { enabled: null, indexMode: 'logsdb' }, // In serverless Kibana, the cluster.logsdb.enabled setting is true by default, so logsdb index mode + ]; + + logsdbSettings.forEach(({ enabled, indexMode }) => { + it(`returns ${indexMode} index mode if logsdb.enabled setting is ${enabled}`, async () => { + await es.cluster.putSettings({ + body: { + persistent: { + cluster: { + logsdb: { + enabled, + }, }, }, }, - }, + }); + + const { body, status } = await supertestWithoutAuth + .get(`${API_BASE_PATH}/index_templates/${logsdbTemplateName}`) + .set(internalReqHeader) + .set(roleAuthc.apiKeyHeader); + expect(status).to.eql(200); + expect(body.indexMode).to.equal(indexMode); }); - - const { body, status } = await supertestWithoutAuth - .get(`${API_BASE_PATH}/index_templates/${logsdbTemplateName}`) - .set(internalReqHeader) - .set(roleAuthc.apiKeyHeader); - expect(status).to.eql(200); - expect(body.indexMode).to.equal('logsdb'); - }); - - it('returns standard index mode if logsdg.enabled setting is false', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: false, - }, - }, - }, - }, - }); - - const { body, status } = await supertestWithoutAuth - .get(`${API_BASE_PATH}/index_templates/${logsdbTemplateName}`) - .set(internalReqHeader) - .set(roleAuthc.apiKeyHeader); - expect(status).to.eql(200); - expect(body.indexMode).to.equal('standard'); - }); - - // In serverless Kibana, the cluster.logsdb.enabled setting is true by default - it('returns logsdb index mode if logsdg.enabled setting is not set', async () => { - await es.cluster.putSettings({ - body: { - persistent: { - cluster: { - logsdb: { - enabled: null, - }, - }, - }, - }, - }); - - const { body, status } = await supertestWithoutAuth - .get(`${API_BASE_PATH}/index_templates/${logsdbTemplateName}`) - .set(internalReqHeader) - .set(roleAuthc.apiKeyHeader); - expect(status).to.eql(200); - expect(body.indexMode).to.equal('logsdb'); }); }); });