Skip to content

Commit 3715ca7

Browse files
[8.19] [Data Streams] Fix forward-compatibility api test failures (#224795) (#225641)
# Backport This will backport the following commits from `main` to `8.19`: - [[Data Streams] Fix forward-compatibility api test failures (#224795)](#224795) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Sonia Sanz Vivas","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-06-25T11:55:46Z","message":"[Data Streams] Fix forward-compatibility api test failures (#224795)\n\nFixes https://github.com/elastic/kibana/issues/223990\n\n## Summary\n\nThis PR fixes the forward-compatibility test for index mode, which\nfailed because the index mode was added to Get Data Streams API in 8.19\nand 9.1 (see elastic/elasticsearch#122486), so\nif Kibana 8.19 is run with Es 9.0, the index mode is always displayed as\n\"Standard\" because Es doesn't return an index mode field.\n\nIn this PR, we separate all index mode-related tests into a separate\nfile, and only run it for Es versions 8.19 or 9.1+.\n\nThis was also fixed for functional tests in\nhttps://github.com//pull/223129\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"493ca9f1061ab1e451741c6875107d8d16953d23","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Index Management","Team:Kibana Management","release_note:skip","backport missing","backport:version","v9.1.0","v8.19.0"],"title":"[Data Streams] Fix forward-compatibility api test failures","number":224795,"url":"https://github.com/elastic/kibana/pull/224795","mergeCommit":{"message":"[Data Streams] Fix forward-compatibility api test failures (#224795)\n\nFixes https://github.com/elastic/kibana/issues/223990\n\n## Summary\n\nThis PR fixes the forward-compatibility test for index mode, which\nfailed because the index mode was added to Get Data Streams API in 8.19\nand 9.1 (see elastic/elasticsearch#122486), so\nif Kibana 8.19 is run with Es 9.0, the index mode is always displayed as\n\"Standard\" because Es doesn't return an index mode field.\n\nIn this PR, we separate all index mode-related tests into a separate\nfile, and only run it for Es versions 8.19 or 9.1+.\n\nThis was also fixed for functional tests in\nhttps://github.com//pull/223129\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"493ca9f1061ab1e451741c6875107d8d16953d23"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/224795","number":224795,"mergeCommit":{"message":"[Data Streams] Fix forward-compatibility api test failures (#224795)\n\nFixes https://github.com/elastic/kibana/issues/223990\n\n## Summary\n\nThis PR fixes the forward-compatibility test for index mode, which\nfailed because the index mode was added to Get Data Streams API in 8.19\nand 9.1 (see elastic/elasticsearch#122486), so\nif Kibana 8.19 is run with Es 9.0, the index mode is always displayed as\n\"Standard\" because Es doesn't return an index mode field.\n\nIn this PR, we separate all index mode-related tests into a separate\nfile, and only run it for Es versions 8.19 or 9.1+.\n\nThis was also fixed for functional tests in\nhttps://github.com//pull/223129\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"493ca9f1061ab1e451741c6875107d8d16953d23"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Damian Polewski <[email protected]> Co-authored-by: Damian Polewski <[email protected]>
1 parent 106c69d commit 3715ca7

File tree

3 files changed

+97
-76
lines changed

3 files changed

+97
-76
lines changed

x-pack/platform/test/api_integration/apis/management/index_management/data_streams.ts

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import { datastreamsHelpers } from './lib/datastreams.helpers';
1414

1515
export default function ({ getService }: FtrProviderContext) {
1616
const supertest = getService('supertest');
17-
const es = getService('es');
18-
const esVersion = getService('esVersion');
1917

2018
const {
2119
createDataStream,
@@ -171,80 +169,6 @@ export default function ({ getService }: FtrProviderContext) {
171169
indexMode: 'standard',
172170
});
173171
});
174-
175-
describe('index mode', () => {
176-
it('correctly returns index mode property based on index settings', async () => {
177-
const logsdbDataStreamName = 'logsdb-test-data-stream';
178-
const indexMode = 'logsdb';
179-
180-
await createDataStream(logsdbDataStreamName, indexMode);
181-
182-
const { body: dataStream } = await supertest
183-
.get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`)
184-
.set('kbn-xsrf', 'xxx')
185-
.expect(200);
186-
187-
expect(dataStream.indexMode).to.eql(indexMode);
188-
189-
await deleteDataStream(logsdbDataStreamName);
190-
});
191-
192-
describe('index mode of logs-*-* data streams', () => {
193-
const logsdbDataStreamName = 'logs-test-ds';
194-
195-
before(async () => {
196-
await createDataStream(logsdbDataStreamName);
197-
});
198-
199-
after(async () => {
200-
await deleteDataStream(logsdbDataStreamName);
201-
});
202-
203-
const logsdbSettings: Array<{
204-
enabled: boolean | null;
205-
prior_logs_usage: boolean;
206-
indexMode: string;
207-
}> = [
208-
{ enabled: true, prior_logs_usage: true, indexMode: 'logsdb' },
209-
{ enabled: false, prior_logs_usage: true, indexMode: 'standard' },
210-
// In stateful Kibana, when cluster.logsb.enabled setting is not set, the index mode is always standard
211-
// For versions 9.0+, if prior_logs_usage is set to false, the cluster.logsdb.enabled setting is true by default, so logsdb index mode
212-
{ enabled: null, prior_logs_usage: true, indexMode: 'standard' },
213-
{
214-
enabled: null,
215-
prior_logs_usage: false,
216-
indexMode: esVersion.matchRange('>=9.0.0') ? 'logsdb' : 'standard',
217-
},
218-
];
219-
220-
// eslint-disable-next-line @typescript-eslint/naming-convention
221-
logsdbSettings.forEach(({ enabled, prior_logs_usage, indexMode }) => {
222-
it(`returns ${indexMode} index mode if logsdb.enabled setting is ${enabled} and logs.prior_logs_usage is ${prior_logs_usage}`, async () => {
223-
await es.cluster.putSettings({
224-
body: {
225-
persistent: {
226-
cluster: {
227-
logsdb: {
228-
enabled,
229-
},
230-
},
231-
logsdb: {
232-
prior_logs_usage,
233-
},
234-
},
235-
},
236-
});
237-
238-
const { body: dataStream } = await supertest
239-
.get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`)
240-
.set('kbn-xsrf', 'xxx')
241-
.expect(200);
242-
243-
expect(dataStream.indexMode).to.eql(indexMode);
244-
});
245-
});
246-
});
247-
});
248172
});
249173

250174
describe('Update', () => {
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import expect from '@kbn/expect';
9+
10+
import { FtrProviderContext } from '../../../ftr_provider_context';
11+
import { API_BASE_PATH } from './constants';
12+
import { datastreamsHelpers } from './lib/datastreams.helpers';
13+
14+
export default function ({ getService }: FtrProviderContext) {
15+
const supertest = getService('supertest');
16+
const es = getService('es');
17+
const esVersion = getService('esVersion');
18+
19+
const { createDataStream, deleteDataStream } = datastreamsHelpers(getService);
20+
21+
describe('Data streams index mode', function () {
22+
// This mutes the forward-compatibility test with Elasticsearch, 8.19 kibana and 9.0 ES.
23+
// They are not expected to work together since the index mode field was added to
24+
// the Get Data Streams API in 8.19 and 9.1, but not in 9.0.
25+
this.onlyEsVersion('8.19 || >=9.1');
26+
it('correctly returns index mode property based on index settings', async () => {
27+
const logsdbDataStreamName = 'logsdb-test-data-stream';
28+
const indexMode = 'logsdb';
29+
30+
await createDataStream(logsdbDataStreamName, indexMode);
31+
32+
const { body: dataStream } = await supertest
33+
.get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`)
34+
.set('kbn-xsrf', 'xxx')
35+
.expect(200);
36+
37+
expect(dataStream.indexMode).to.eql(indexMode);
38+
39+
await deleteDataStream(logsdbDataStreamName);
40+
});
41+
42+
describe('index mode of logs-*-* data streams', () => {
43+
const logsdbDataStreamName = 'logs-test-ds';
44+
45+
before(async () => {
46+
await createDataStream(logsdbDataStreamName);
47+
});
48+
49+
after(async () => {
50+
await deleteDataStream(logsdbDataStreamName);
51+
});
52+
53+
const logsdbSettings: Array<{
54+
enabled: boolean | null;
55+
prior_logs_usage: boolean;
56+
indexMode: string;
57+
}> = [
58+
{ enabled: true, prior_logs_usage: true, indexMode: 'logsdb' },
59+
{ enabled: false, prior_logs_usage: true, indexMode: 'standard' },
60+
// In stateful Kibana, when cluster.logsb.enabled setting is not set, the index mode is always standard
61+
// For versions 9.0+, if prior_logs_usage is set to false, the cluster.logsdb.enabled setting is true by default, so logsdb index mode
62+
{ enabled: null, prior_logs_usage: true, indexMode: 'standard' },
63+
{
64+
enabled: null,
65+
prior_logs_usage: false,
66+
indexMode: esVersion.matchRange('>=9.0.0') ? 'logsdb' : 'standard',
67+
},
68+
];
69+
70+
// eslint-disable-next-line @typescript-eslint/naming-convention
71+
logsdbSettings.forEach(({ enabled, prior_logs_usage, indexMode }) => {
72+
it(`returns ${indexMode} index mode if logsdb.enabled setting is ${enabled} and logs.prior_logs_usage is ${prior_logs_usage}`, async () => {
73+
await es.cluster.putSettings({
74+
persistent: {
75+
cluster: {
76+
logsdb: {
77+
enabled,
78+
},
79+
},
80+
logsdb: {
81+
prior_logs_usage,
82+
},
83+
},
84+
});
85+
86+
const { body: dataStream } = await supertest
87+
.get(`${API_BASE_PATH}/data_streams/${logsdbDataStreamName}`)
88+
.set('kbn-xsrf', 'xxx')
89+
.expect(200);
90+
91+
expect(dataStream.indexMode).to.eql(indexMode);
92+
});
93+
});
94+
});
95+
});
96+
}

x-pack/platform/test/api_integration/apis/management/index_management/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default function ({ loadTestFile }: FtrProviderContext) {
1414
loadTestFile(require.resolve('./settings'));
1515
loadTestFile(require.resolve('./stats'));
1616
loadTestFile(require.resolve('./data_streams'));
17+
loadTestFile(require.resolve('./data_streams_index_mode'));
1718
loadTestFile(require.resolve('./templates'));
1819
loadTestFile(require.resolve('./component_templates'));
1920
loadTestFile(require.resolve('./cluster_nodes'));

0 commit comments

Comments
 (0)