Skip to content

Commit

Permalink
[Index Management] Add node plugins serverless tests (#172040)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarasaba authored Nov 28, 2023
1 parent 98b2cfb commit 8e36ba7
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 20 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
import expect from '@kbn/expect';

import { FtrProviderContext } from '../../../ftr_provider_context';
import { registerHelpers } from './cluster_nodes.helpers';
import { clusterNodesApi } from './lib/cluster_nodes.api';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');

const { getNodesPlugins } = registerHelpers({ supertest });
const { getNodesPlugins } = clusterNodesApi(getService);

describe('nodes', () => {
it('should fetch the nodes plugins', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { API_BASE_PATH } from '../constants';
import { FtrProviderContext } from '../../../../ftr_provider_context';

export function clusterNodesApi(getService: FtrProviderContext['getService']) {
const supertest = getService('supertest');

const getNodesPlugins = () =>
supertest
.get(`${API_BASE_PATH}/nodes/plugins`)
.set('kbn-xsrf', 'xxx')
.set('x-elastic-internal-origin', 'xxx');

return {
getNodesPlugins,
};
}
4 changes: 4 additions & 0 deletions x-pack/test/api_integration/services/index_management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FtrProviderContext } from '../ftr_provider_context';
import { indicesApi } from '../apis/management/index_management/lib/indices.api';
import { mappingsApi } from '../apis/management/index_management/lib/mappings.api';
import { indicesHelpers } from '../apis/management/index_management/lib/indices.helpers';
import { clusterNodesApi } from '../apis/management/index_management/lib/cluster_nodes.api';
import { datastreamsHelpers } from '../apis/management/index_management/lib/datastreams.helpers';

export function IndexManagementProvider({ getService }: FtrProviderContext) {
Expand All @@ -17,6 +18,9 @@ export function IndexManagementProvider({ getService }: FtrProviderContext) {
api: indicesApi(getService),
helpers: indicesHelpers(getService),
},
clusterNodes: {
api: clusterNodesApi(getService),
},
datastreams: {
helpers: datastreamsHelpers(getService),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import expect from '@kbn/expect';

import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const indexManagementService = getService('indexManagement');

describe('nodes', () => {
let getNodesPlugins: typeof indexManagementService['clusterNodes']['api']['getNodesPlugins'];

before(async () => {
({
clusterNodes: {
api: { getNodesPlugins },
},
} = indexManagementService);
});

it('should fetch the nodes plugins', async () => {
const { body } = await getNodesPlugins().expect(200);

expect(Array.isArray(body)).to.be(true);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function ({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./index_templates'));
loadTestFile(require.resolve('./indices'));
loadTestFile(require.resolve('./create_enrich_policies'));
loadTestFile(require.resolve('./cluster_nodes'));
loadTestFile(require.resolve('./datastreams'));
loadTestFile(require.resolve('./mappings'));
});
Expand Down

0 comments on commit 8e36ba7

Please sign in to comment.