-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FTR test to ensure data views aren't recreated after subsequent i…
…ntegration installations
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* 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 '../../../api_integration/ftr_provider_context'; | ||
import { skipIfNoDockerRegistry } from '../../helpers'; | ||
import { setupFleetAndAgents } from '../agents/services'; | ||
|
||
export default function (providerContext: FtrProviderContext) { | ||
const { getService } = providerContext; | ||
|
||
const supertest = getService('supertest'); | ||
|
||
const testPkgs = [ | ||
{ | ||
name: 'apache', | ||
version: '0.1.4', | ||
}, | ||
{ | ||
name: 'nginx', | ||
version: '1.2.1', | ||
}, | ||
]; | ||
|
||
const uninstallPackage = async (name: string, version: string) => { | ||
await supertest.delete(`/api/fleet/epm/packages/${name}/${version}`).set('kbn-xsrf', 'xxxx'); | ||
}; | ||
|
||
const installPackage = async (name: string, version: string) => { | ||
await supertest | ||
.post(`/api/fleet/epm/packages/${name}/${version}`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.send({ force: true }); | ||
}; | ||
|
||
const listDataViews = async () => { | ||
const response = await supertest.get('/api/data_views'); | ||
|
||
return response.body.data_view; | ||
}; | ||
|
||
describe('EPM - data views', () => { | ||
skipIfNoDockerRegistry(providerContext); | ||
setupFleetAndAgents(providerContext); | ||
|
||
afterEach(async () => { | ||
await Promise.all(testPkgs.map((pkg) => uninstallPackage(pkg.name, pkg.version))); | ||
}); | ||
|
||
describe('with subsequent integration installation', async () => { | ||
it('does not recreate managed data views', async () => { | ||
await installPackage(testPkgs[0].name, testPkgs[0].version); | ||
const initialDataViews: any[] = await listDataViews(); | ||
const initialLogsDataView = initialDataViews.find(({ title }) => title === 'logs-*'); | ||
const initialMetricsDataView = initialDataViews.find(({ title }) => title === 'metrics-*'); | ||
|
||
expect(initialLogsDataView).to.be.ok(); | ||
expect(initialMetricsDataView).to.be.ok(); | ||
|
||
await installPackage(testPkgs[1].name, testPkgs[1].version); | ||
const subsequentDataViews: any[] = await listDataViews(); | ||
const subsequentLogsDataView = subsequentDataViews.find(({ title }) => title === 'logs-*'); | ||
const subsequentMetricsDataView = subsequentDataViews.find( | ||
({ title }) => title === 'metrics-*' | ||
); | ||
|
||
// ID's should not have changed as the data views should not have been recreated | ||
expect(initialLogsDataView.id).to.eql(subsequentLogsDataView.id); | ||
expect(initialMetricsDataView.id).to.eql(subsequentMetricsDataView.id); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters