Skip to content

Commit 3c3ae8b

Browse files
[Index Management] Fix serverless API integration tests (#166203)
Fixes #165565 Fixes #165609 ## Summary Two of the PUT requests in the IM serverless API integration tests were failing with the following error: `{"statusCode":400,"error":"Bad Request","message":"uri [https://localhost:5620/internal/index_management/indices/create] with method [put] exists but is not available with the current configuration"}`. I think this is because they were missing the `x-elastic-internal-origin` header which needs to be provided when we try to access an internal API in serverless outside of the `core.http` service. Once I added the headers, the tests started passing successfully. --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent f8927dd commit 3c3ae8b

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • x-pack/test_serverless/api_integration/test_suites/common/index_management

x-pack/test_serverless/api_integration/test_suites/common/index_management/indices.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,19 @@ export default function ({ getService }: FtrProviderContext) {
1717
const es = getService('es');
1818
const log = getService('log');
1919

20-
// FLAKY: https://github.com/elastic/kibana/issues/165565
21-
describe.skip('Indices', function () {
20+
describe('Indices', function () {
2221
const indexName = `index-${Math.random()}`;
2322

2423
before(async () => {
2524
// Create a new index to test against
25+
const indexExists = await es.indices.exists({ index: indexName });
26+
27+
// Index should not exist, but in the case that it already does, we bypass the create request
28+
if (indexExists) {
29+
return;
30+
}
31+
32+
log.debug(`Creating index: '${indexName}'`);
2633
try {
2734
await es.indices.create({ index: indexName });
2835
} catch (err) {
@@ -99,6 +106,7 @@ export default function ({ getService }: FtrProviderContext) {
99106
await supertest
100107
.put(`${INTERNAL_API_BASE_PATH}/indices/create`)
101108
.set('kbn-xsrf', 'xxx')
109+
.set('x-elastic-internal-origin', 'xxx')
102110
.send({
103111
indexName: createIndexName,
104112
})
@@ -119,6 +127,7 @@ export default function ({ getService }: FtrProviderContext) {
119127
await supertest
120128
.put(`${INTERNAL_API_BASE_PATH}/indices/create`)
121129
.set('kbn-xsrf', 'xxx')
130+
.set('x-elastic-internal-origin', 'xxx')
122131
.send({
123132
indexName: createIndexName,
124133
})

0 commit comments

Comments
 (0)