diff --git a/x-pack/test/monitoring_api_integration/apis/apm/index.ts b/x-pack/test/monitoring_api_integration/apis/apm/index.ts index dbbae596a7b59..0171da7e6b83a 100644 --- a/x-pack/test/monitoring_api_integration/apis/apm/index.ts +++ b/x-pack/test/monitoring_api_integration/apis/apm/index.ts @@ -6,9 +6,12 @@ */ import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; +import { installPackage } from '../../packages'; -export default function ({ loadTestFile }: FtrProviderContext) { +export default function ({ loadTestFile, getService }: FtrProviderContext) { describe('APM', () => { + before(() => installPackage(getService('supertest'), 'beat')); + loadTestFile(require.resolve('./overview')); loadTestFile(require.resolve('./instances')); }); diff --git a/x-pack/test/monitoring_api_integration/apis/beats/index.ts b/x-pack/test/monitoring_api_integration/apis/beats/index.ts index 01d2bc6a3c3d6..79d051835ec3a 100644 --- a/x-pack/test/monitoring_api_integration/apis/beats/index.ts +++ b/x-pack/test/monitoring_api_integration/apis/beats/index.ts @@ -6,9 +6,12 @@ */ import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; +import { installPackage } from '../../packages'; -export default function ({ loadTestFile }: FtrProviderContext) { +export default function ({ loadTestFile, getService }: FtrProviderContext) { describe('Beats', () => { + before(() => installPackage(getService('supertest'), 'beat')); + loadTestFile(require.resolve('./overview')); loadTestFile(require.resolve('./beats')); loadTestFile(require.resolve('./beat')); diff --git a/x-pack/test/monitoring_api_integration/apis/elasticsearch/index.ts b/x-pack/test/monitoring_api_integration/apis/elasticsearch/index.ts index 8b43525fb03e2..cfcb7bf5570aa 100644 --- a/x-pack/test/monitoring_api_integration/apis/elasticsearch/index.ts +++ b/x-pack/test/monitoring_api_integration/apis/elasticsearch/index.ts @@ -6,9 +6,12 @@ */ import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; +import { installPackage } from '../../packages'; -export default function ({ loadTestFile }: FtrProviderContext) { +export default function ({ loadTestFile, getService }: FtrProviderContext) { describe('Elasticsearch', () => { + before(() => installPackage(getService('supertest'), 'elasticsearch')); + loadTestFile(require.resolve('./ccr')); loadTestFile(require.resolve('./indices')); loadTestFile(require.resolve('./ml_jobs')); diff --git a/x-pack/test/monitoring_api_integration/apis/enterprisesearch/index.ts b/x-pack/test/monitoring_api_integration/apis/enterprisesearch/index.ts index 5942fde0fe95a..a7195e283232a 100644 --- a/x-pack/test/monitoring_api_integration/apis/enterprisesearch/index.ts +++ b/x-pack/test/monitoring_api_integration/apis/enterprisesearch/index.ts @@ -6,9 +6,12 @@ */ import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; +import { installPackage } from '../../packages'; -export default function ({ loadTestFile }: FtrProviderContext) { +export default function ({ loadTestFile, getService }: FtrProviderContext) { describe('Enterprisesearch', () => { + before(() => installPackage(getService('supertest'), 'enterprisesearch')); + loadTestFile(require.resolve('./overview')); }); } diff --git a/x-pack/test/monitoring_api_integration/apis/kibana/index.ts b/x-pack/test/monitoring_api_integration/apis/kibana/index.ts index 24c5e6865021a..4409c5a871397 100644 --- a/x-pack/test/monitoring_api_integration/apis/kibana/index.ts +++ b/x-pack/test/monitoring_api_integration/apis/kibana/index.ts @@ -6,9 +6,12 @@ */ import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; +import { installPackage } from '../../packages'; -export default function ({ loadTestFile }: FtrProviderContext) { +export default function ({ loadTestFile, getService }: FtrProviderContext) { describe('Kibana', () => { + before(() => installPackage(getService('supertest'), 'kibana')); + loadTestFile(require.resolve('./overview')); loadTestFile(require.resolve('./instances')); }); diff --git a/x-pack/test/monitoring_api_integration/apis/logstash/index.ts b/x-pack/test/monitoring_api_integration/apis/logstash/index.ts index 88a5980273ef5..bcde9e2cc5f31 100644 --- a/x-pack/test/monitoring_api_integration/apis/logstash/index.ts +++ b/x-pack/test/monitoring_api_integration/apis/logstash/index.ts @@ -6,9 +6,12 @@ */ import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; +import { installPackage } from '../../packages'; -export default function ({ loadTestFile }: FtrProviderContext) { +export default function ({ loadTestFile, getService }: FtrProviderContext) { describe('Logstash', () => { + before(() => installPackage(getService('supertest'), 'logstash')); + loadTestFile(require.resolve('./overview')); loadTestFile(require.resolve('./nodes')); loadTestFile(require.resolve('./pipelines')); diff --git a/x-pack/test/monitoring_api_integration/config.ts b/x-pack/test/monitoring_api_integration/config.ts index cd016afb6dcfd..786fde0bb1d30 100644 --- a/x-pack/test/monitoring_api_integration/config.ts +++ b/x-pack/test/monitoring_api_integration/config.ts @@ -7,8 +7,6 @@ import { FtrConfigProviderContext } from '@kbn/test'; -import { bundledPackagesLocation, getPackagesArgs } from './packages'; - export default async function ({ readConfigFile }: FtrConfigProviderContext) { const xPackAPITestsConfig = await readConfigFile(require.resolve('../api_integration/config.ts')); @@ -22,11 +20,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { esTestCluster: xPackAPITestsConfig.get('esTestCluster'), kbnTestServer: { ...xPackAPITestsConfig.get('kbnTestServer'), - serverArgs: [ - ...xPackAPITestsConfig.get('kbnTestServer.serverArgs'), - `--xpack.fleet.developer.bundledPackageLocation=${bundledPackagesLocation}`, - ...getPackagesArgs(), - ], + serverArgs: [...xPackAPITestsConfig.get('kbnTestServer.serverArgs')], }, }; } diff --git a/x-pack/test/monitoring_api_integration/packages.ts b/x-pack/test/monitoring_api_integration/packages.ts index aaa11d8d0fe9e..284bba089a55c 100644 --- a/x-pack/test/monitoring_api_integration/packages.ts +++ b/x-pack/test/monitoring_api_integration/packages.ts @@ -6,6 +6,10 @@ */ import path from 'path'; +import { createReadStream } from 'fs'; +import type SuperTest from 'supertest'; + +type SupportedPackage = 'beat' | 'elasticsearch' | 'enterprisesearch' | 'logstash' | 'kibana'; const PACKAGES = [ { name: 'beat', version: '0.1.3' }, @@ -25,3 +29,26 @@ export const getPackagesArgs = (): string[] => { }; export const bundledPackagesLocation = path.join(path.dirname(__filename), '/fixtures/packages'); + +export function installPackage( + supertest: SuperTest.SuperTest, + packageName: SupportedPackage +) { + const pkg = PACKAGES.find(({ name }) => name === packageName); + const request = supertest + .post('/api/fleet/epm/packages') + .set('kbn-xsrf', 'xxx') + .set('content-type', 'application/zip'); + + return new Promise((resolve, reject) => { + createReadStream(path.join(bundledPackagesLocation, `${pkg!.name}-${pkg!.version}.zip`)) + .on('data', (chunk) => request.write(chunk)) + .on('end', () => { + request + .send() + .expect(200) + .then(() => resolve()) + .catch(reject); + }); + }); +}