[Index Management] Add node plugins serverless tests (#172040)

This commit is contained in:
Ignacio Rivas 2023-11-28 21:03:20 +01:00 committed by GitHub
parent 98b2cfbbb0
commit 8e36ba77f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 20 deletions

View file

@ -1,16 +0,0 @@
/*
* 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';
export const registerHelpers = ({ supertest }: { supertest: any }) => {
const getNodesPlugins = () => supertest.get(`${API_BASE_PATH}/nodes/plugins`);
return {
getNodesPlugins,
};
};

View file

@ -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 () => {

View file

@ -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,
};
}

View file

@ -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) {
@ -17,6 +18,9 @@ export function IndexManagementProvider({ getService }: FtrProviderContext) {
api: indicesApi(getService),
helpers: indicesHelpers(getService),
},
clusterNodes: {
api: clusterNodesApi(getService),
},
datastreams: {
helpers: datastreamsHelpers(getService),
},

View file

@ -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);
});
});
}

View file

@ -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'));
});