## Summary Closes #90454 Closes https://github.com/elastic/kibana/issues/72959 * Rename the component templates which are [installed for some packages](https://github.com/elastic/kibana/blob/master/x-pack/plugins/fleet/server/services/epm/elasticsearch/template/install.ts#L197-L213) from `${templateName}-mappings` and `${templateName}-settings` to `${templateName}@mappings` and `${templateName}@settings` * When any package is installed, add a component template named `${templateName}@custom` * Any of above templates also include a `_meta` property with `{ package: { name: packageName } }` * On package installation, add any installed component templates to the `installed_es` property of the `epm-packages` saved object * On package removal, remove any installed component templates from the `installed_es` property of the `epm-packages` saved object <details><summary>Kibana logs showing component templates added for package</summary> ``` │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.file@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.registry@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [.logs-endpoint.diagnostic.collection@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.library@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.security@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.network@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.alerts@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metrics@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.process@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.policy@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metadata@mappings] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.registry@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [.logs-endpoint.diagnostic.collection@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.security@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.file@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.library@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.network@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.alerts@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metrics@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.policy@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [logs-endpoint.events.process@custom] │ info [o.e.c.m.MetadataIndexTemplateService] [JFSIII.local] adding component template [metrics-endpoint.metadata@custom] ``` </details> <details><summary>screenshot - component templates are editable in the Stack Management UI</summary> <img width="1342" alt="Screen Shot 2021-06-17 at 4 06 24 PM" src="https://user-images.githubusercontent.com/57655/122465421-1502bb80-cf86-11eb-94f4-9880cb3ea844.png"> </details> ### Checklist Delete any items that are not applicable to this PR. - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
71 lines
2.7 KiB
TypeScript
71 lines
2.7 KiB
TypeScript
/*
|
|
* 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 path from 'path';
|
|
|
|
import { FtrConfigProviderContext } from '@kbn/test';
|
|
import { defineDockerServersConfig } from '@kbn/test';
|
|
|
|
// Docker image to use for Fleet API integration tests.
|
|
// This hash comes from the latest successful build of the Snapshot Distribution of the Package Registry, for
|
|
// example: https://beats-ci.elastic.co/blue/organizations/jenkins/Ingest-manager%2Fpackage-storage/detail/snapshot/74/pipeline/257#step-302-log-1.
|
|
// It should be updated any time there is a new Docker image published for the Snapshot Distribution of the Package Registry.
|
|
export const dockerImage =
|
|
process.env.FLEET_PACKAGE_REGISTRY_DOCKER_IMAGE ||
|
|
'docker.elastic.co/package-registry/distribution:fc104ac437370d80518e24da6d0b84370edf0c0c';
|
|
|
|
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
|
const xPackAPITestsConfig = await readConfigFile(require.resolve('../api_integration/config.ts'));
|
|
|
|
const registryPort: string | undefined = process.env.FLEET_PACKAGE_REGISTRY_PORT;
|
|
|
|
// mount the config file for the package registry as well as
|
|
// the directory containing additional packages into the container
|
|
const dockerArgs: string[] = [
|
|
'-v',
|
|
`${path.join(
|
|
path.dirname(__filename),
|
|
'./apis/fixtures/package_registry_config.yml'
|
|
)}:/package-registry/config.yml`,
|
|
'-v',
|
|
`${path.join(
|
|
path.dirname(__filename),
|
|
'./apis/fixtures/test_packages'
|
|
)}:/packages/test-packages`,
|
|
];
|
|
|
|
return {
|
|
testFiles: [require.resolve('./apis')],
|
|
servers: xPackAPITestsConfig.get('servers'),
|
|
dockerServers: defineDockerServersConfig({
|
|
registry: {
|
|
enabled: !!registryPort,
|
|
image: dockerImage,
|
|
portInContainer: 8080,
|
|
port: registryPort,
|
|
args: dockerArgs,
|
|
waitForLogLine: 'package manifests loaded',
|
|
},
|
|
}),
|
|
services: xPackAPITestsConfig.get('services'),
|
|
junit: {
|
|
reportName: 'X-Pack EPM API Integration Tests',
|
|
},
|
|
esTestCluster: xPackAPITestsConfig.get('esTestCluster'),
|
|
kbnTestServer: {
|
|
...xPackAPITestsConfig.get('kbnTestServer'),
|
|
serverArgs: [
|
|
...xPackAPITestsConfig.get('kbnTestServer.serverArgs'),
|
|
// always install Endpoint package by default when Fleet sets up
|
|
`--xpack.fleet.packages.0.name=endpoint`,
|
|
`--xpack.fleet.packages.0.version=latest`,
|
|
...(registryPort ? [`--xpack.fleet.registryUrl=http://localhost:${registryPort}`] : []),
|
|
],
|
|
},
|
|
};
|
|
}
|