Skip to content

Commit

Permalink
Fix type errors and simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaStoeva committed Jan 22, 2025
1 parent 9f6b123 commit b6b361c
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
});
Expand Down
Loading

0 comments on commit b6b361c

Please sign in to comment.