mirror of
https://github.com/elastic/kibana.git
synced 2025-06-29 03:24:45 -04:00
## Summary
Update built in definitions on plugin start. The update overwrites index
templates and ingest pipelines with the latest versions but has to
delete the transforms since we can only update a subset of settings in
the [update
api](https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html)
which does not include the aggregations.
## Testing
### api tests
Since the upgrade logic happens in plugin startup method we cannot
directly trigger it from api tests without some tweaks. I've added a
[fixture
plugin](a87ae8b210/x-pack/test/api_integration/apis/entity_manager/fixture_plugin/server/plugin.ts
)
that is launched in the entity manager test server, this plugin creates
a test route exposing the upgrade api which can then be called in api
tests.
### manual
- install builtin definitions `PUT
kbn:/internal/api/entities/managed/enablement`
- bump builtin [service
definition](https://github.com/elastic/kibana/blob/main/x-pack/plugins/observability_solution/entity_manager/server/lib/entities/built_in/services.ts#L23)
version
- restart kibana server
- logs should output `[INFO ][plugins.entityManager] Updating built-in
entity definition [builtin_services] from v0.1.0 to v<new version>`
- `GET kbn:/internal/api/entities/definition` should output the new
definition
- verify latest version of definition components are installed
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
45 lines
1.5 KiB
TypeScript
45 lines
1.5 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 { resolve } from 'path';
|
|
import { FtrConfigProviderContext, GenericFtrProviderContext } from '@kbn/test';
|
|
import { FtrProviderContext } from '../../ftr_provider_context';
|
|
|
|
type InheritedServices = FtrProviderContext extends GenericFtrProviderContext<infer TServices, {}>
|
|
? TServices
|
|
: {};
|
|
|
|
interface EntityManagerConfig {
|
|
services: InheritedServices & {};
|
|
}
|
|
|
|
export default async function createTestConfig({
|
|
readConfigFile,
|
|
}: FtrConfigProviderContext): Promise<EntityManagerConfig> {
|
|
const baseIntegrationTestsConfig = await readConfigFile(require.resolve('../../config.ts'));
|
|
const services = baseIntegrationTestsConfig.get('services');
|
|
const entityManagerFixturePlugin = resolve(__dirname, './fixture_plugin');
|
|
|
|
return {
|
|
...baseIntegrationTestsConfig.getAll(),
|
|
testFiles: [require.resolve('.')],
|
|
kbnTestServer: {
|
|
...baseIntegrationTestsConfig.get('kbnTestServer'),
|
|
serverArgs: [
|
|
...baseIntegrationTestsConfig.get('kbnTestServer.serverArgs'),
|
|
`--plugin-path=${entityManagerFixturePlugin}`,
|
|
],
|
|
},
|
|
services: {
|
|
...services,
|
|
},
|
|
};
|
|
}
|
|
|
|
export type CreateTestConfig = Awaited<ReturnType<typeof createTestConfig>>;
|
|
|
|
export type AssetManagerServices = CreateTestConfig['services'];
|