-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fleet] Add integration test for epm install on multiple spaces #156864
Merged
criamico
merged 5 commits into
elastic:main
from
criamico:150686_integration_test_multiple_spaces
May 8, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3cd7f96
[Fleet] Add integration test for epm install on multiple spaces
criamico 4171768
Merge branch 'main' into 150686_integration_test_multiple_spaces
kibanamachine 0592860
Verify installed_kibana_space_id
criamico 86636fd
Merge branch 'main' into 150686_integration_test_multiple_spaces
kibanamachine 98b71d5
Merge branch 'main' into 150686_integration_test_multiple_spaces
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
121 changes: 121 additions & 0 deletions
121
x-pack/test/fleet_api_integration/apis/epm/install_integration_in_multiple_spaces.ts
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,121 @@ | ||
/* | ||
* 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'; | ||
|
||
const testSpaceId = 'fleet_test_space'; | ||
|
||
export default function (providerContext: FtrProviderContext) { | ||
const { getService } = providerContext; | ||
const kibanaServer = getService('kibanaServer'); | ||
const supertest = getService('supertest'); | ||
const dockerServers = getService('dockerServers'); | ||
const server = dockerServers.get('registry'); | ||
const pkgName = 'system'; | ||
const pkgVersion = '1.27.0'; | ||
|
||
const installPackage = async (name: string, version: string) => { | ||
await supertest | ||
.post(`/api/fleet/epm/packages/${name}/${version}`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.send({ force: true }); | ||
}; | ||
|
||
const uninstallPackage = async (pkg: string, version: string) => { | ||
await supertest | ||
.delete(`/api/fleet/epm/packages/${pkg}/${version}`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.expect(200); | ||
}; | ||
|
||
const installPackageInSpace = async (pkg: string, version: string, spaceId: string) => { | ||
await supertest | ||
.post(`/s/${spaceId}/api/fleet/epm/packages/${pkg}/${version}`) | ||
.set('kbn-xsrf', 'xxxx') | ||
.send({ force: true }) | ||
.expect(200); | ||
}; | ||
|
||
const createSpace = async (spaceId: string) => { | ||
await supertest.post(`/api/spaces/space`).set('kbn-xsrf', 'xxxx').send({ | ||
name: spaceId, | ||
id: spaceId, | ||
initials: 's', | ||
color: '#D6BF57', | ||
disabledFeatures: [], | ||
imageUrl: '', | ||
}); | ||
}; | ||
|
||
const deleteSpace = async (spaceId: string) => { | ||
await supertest.delete(`/api/spaces/space/${spaceId}`).set('kbn-xsrf', 'xxxx').send(); | ||
}; | ||
|
||
const getTag = async (id: string, space?: string) => | ||
kibanaServer.savedObjects | ||
.get({ | ||
type: 'tag', | ||
id, | ||
...(space && { space }), | ||
}) | ||
.catch(() => {}); | ||
|
||
describe('When installing system integration in multiple spaces', async () => { | ||
skipIfNoDockerRegistry(providerContext); | ||
setupFleetAndAgents(providerContext); | ||
|
||
before(async () => { | ||
if (!server.enabled) return; | ||
await installPackage(pkgName, pkgVersion); | ||
|
||
await createSpace(testSpaceId); | ||
await uninstallPackage(pkgName, pkgVersion); | ||
await installPackageInSpace(pkgName, pkgVersion, testSpaceId); | ||
}); | ||
|
||
after(async () => { | ||
await deleteSpace(testSpaceId); | ||
}); | ||
|
||
it('should install kibana assets', async function () { | ||
// These are installed from Fleet along with every package | ||
const resIndexPatternLogs = await kibanaServer.savedObjects.get({ | ||
type: 'index-pattern', | ||
id: 'logs-*', | ||
}); | ||
expect(resIndexPatternLogs.id).equal('logs-*'); | ||
const resIndexPatternMetrics = await kibanaServer.savedObjects.get({ | ||
type: 'index-pattern', | ||
id: 'metrics-*', | ||
}); | ||
expect(resIndexPatternMetrics.id).equal('metrics-*'); | ||
}); | ||
|
||
it('should correctly set installed_kibana_space_id on the SO', async function () { | ||
const resEPMPackages = await kibanaServer.savedObjects.get({ | ||
type: 'epm-packages', | ||
id: pkgName, | ||
}); | ||
expect(resEPMPackages.attributes.installed_kibana_space_id).to.eql('fleet_test_space'); | ||
}); | ||
|
||
it('should create managed tag saved objects', async () => { | ||
const defaultTag = await getTag('fleet-managed-default'); | ||
expect(defaultTag).not.equal(undefined); | ||
|
||
const spaceTag = await getTag('fleet-managed-fleet_test_space', testSpaceId); | ||
expect(spaceTag).not.equal(undefined); | ||
}); | ||
|
||
it('should create package tag saved objects', async () => { | ||
const spaceTag = await getTag(`fleet-pkg-${pkgName}-fleet_test_space`, testSpaceId); | ||
expect(spaceTag).not.equal(undefined); | ||
}); | ||
}); | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to check that the
installed_kibana_space_id
is set correctly on the SO. We have seen a support issue recently where this was the problem.