[Index Management] Fix templates API integration tests (#209322)

Closes https://github.com/elastic/kibana/issues/209027

## Summary

This PR unskips and updates the Templates API integration tests to
reflect the recent changes to Elasticsearch
(https://github.com/elastic/elasticsearch/pull/121049). Previously, the
`cluster.logsdb.enabled` setting was always false by default in stateful
Kibana. With the new changes, it is true by default if the
`logsdb.prior_logs_usage` setting is false (which is the case for new
test clusters, hence the test failure), and true otherwise. Therefore,
we need to update the tests so that we test both cases.

Flaky test runner:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7829
This commit is contained in:
Elena Stoeva 2025-02-04 04:19:31 +00:00 committed by GitHub
parent ff22f800f3
commit 2a56791b2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,8 +28,7 @@ export default function ({ getService }: FtrProviderContext) {
simulateTemplateByName,
} = templatesApi(getService);
// Failing: See https://github.com/elastic/kibana/issues/209027
describe.skip('index templates', () => {
describe('index templates', () => {
after(async () => await cleanUpTemplates());
describe('get all', () => {
@ -247,13 +246,21 @@ export default function ({ getService }: FtrProviderContext) {
await deleteTemplates([{ name: logsdbTemplateName }]);
});
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
const logsdbSettings: Array<{
enabled: boolean | null;
prior_logs_usage: boolean;
indexMode: string;
}> = [
{ enabled: true, prior_logs_usage: true, indexMode: 'logsdb' },
{ enabled: false, prior_logs_usage: true, indexMode: 'standard' },
// In stateful Kibana, if prior_logs_usage is set to true, the cluster.logsdb.enabled setting is false by default, so standard index mode
{ enabled: null, prior_logs_usage: true, indexMode: 'standard' },
// In stateful Kibana, if prior_logs_usage is set to false, the cluster.logsdb.enabled setting is true by default, so logsdb index mode
{ enabled: null, prior_logs_usage: false, indexMode: 'logsdb' },
];
logsdbSettings.forEach(({ enabled, indexMode }) => {
// eslint-disable-next-line @typescript-eslint/naming-convention
logsdbSettings.forEach(({ enabled, prior_logs_usage, indexMode }) => {
it(`returns ${indexMode} index mode if logsdb.enabled setting is ${enabled}`, async () => {
await es.cluster.putSettings({
body: {
@ -263,6 +270,9 @@ export default function ({ getService }: FtrProviderContext) {
enabled,
},
},
logsdb: {
prior_logs_usage,
},
},
},
});