From a2cd45a5e4477c51ee09bb03e828993fc248c4b4 Mon Sep 17 00:00:00 2001 From: Yngrid Coello Date: Wed, 4 Sep 2024 12:00:40 +0200 Subject: [PATCH] Adding dockerized package registry for serverless functional tests --- .../common/package_registry_config.yml | 2 ++ .../test_serverless/functional/config.base.ts | 28 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 x-pack/test_serverless/functional/common/package_registry_config.yml diff --git a/x-pack/test_serverless/functional/common/package_registry_config.yml b/x-pack/test_serverless/functional/common/package_registry_config.yml new file mode 100644 index 0000000000000..1885fa5c2ebe5 --- /dev/null +++ b/x-pack/test_serverless/functional/common/package_registry_config.yml @@ -0,0 +1,2 @@ +package_paths: + - /packages/package-storage diff --git a/x-pack/test_serverless/functional/config.base.ts b/x-pack/test_serverless/functional/config.base.ts index 22fb253d9896b..ddf3f34f52453 100644 --- a/x-pack/test_serverless/functional/config.base.ts +++ b/x-pack/test_serverless/functional/config.base.ts @@ -5,10 +5,11 @@ * 2.0. */ -import { resolve } from 'path'; +import path, { resolve } from 'path'; -import { FtrConfigProviderContext } from '@kbn/test'; +import { FtrConfigProviderContext, defineDockerServersConfig } from '@kbn/test'; +import { dockerImage } from '@kbn/test-suites-xpack/fleet_api_integration/config.base'; import { pageObjects } from './page_objects'; import { services } from './services'; import type { CreateTestConfigOptions } from '../shared/types'; @@ -16,6 +17,17 @@ import type { CreateTestConfigOptions } from '../shared/types'; export function createTestConfig(options: CreateTestConfigOptions) { return async ({ readConfigFile }: FtrConfigProviderContext) => { const svlSharedConfig = await readConfigFile(require.resolve('../shared/config.base.ts')); + const packageRegistryConfig = path.join(__dirname, './common/package_registry_config.yml'); + const dockerArgs: string[] = ['-v', `${packageRegistryConfig}:/package-registry/config.yml`]; + + /** + * This is used by CI to set the docker registry port + * you can also define this environment variable locally when running tests which + * will spin up a local docker package registry locally for you + * if this is defined it takes precedence over the `packageRegistryOverride` variable + */ + const dockerRegistryPort: string | undefined = process.env.FLEET_PACKAGE_REGISTRY_PORT; + return { ...svlSharedConfig.getAll(), @@ -37,7 +49,17 @@ export function createTestConfig(options: CreateTestConfigOptions) { ], }, testFiles: options.testFiles, - + dockerServers: defineDockerServersConfig({ + registry: { + enabled: !!dockerRegistryPort, + image: dockerImage, + portInContainer: 8080, + port: dockerRegistryPort, + args: dockerArgs, + waitForLogLine: 'package manifests loaded', + waitForLogLineTimeoutMs: 60 * 2 * 10000, // 2 minutes + }, + }), uiSettings: { defaults: { 'accessibility:disableAnimations': true,