Skip to content
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

[Logs explorer] Using dockerized package registry in tests #192064

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ yarn test:ftr:runner --config ./x-pack/test_serverless/functional/test_suites/ob
yarn test:ftr:runner --config ./x-pack/test_serverless/functional/test_suites/observability/config.ts --include ./x-pack/test_serverless/functional/test_suites/observability/observability_logs_explorer/$1
```

### Using dockerized package registry

For tests using package registry we have enabled a configuration that uses a dockerized lite version to execute the tests in the CI, this will reduce the flakyness of them when calling the real endpoint.

To be able to run this version locally you must have a docker daemon running in your system and set `FLEET_PACKAGE_REGISTRY_PORT` env var. In order to set this variable execute

```
export set FLEET_PACKAGE_REGISTRY_PORT=12345
```

To unset the variable, and run the tests against the real endpoint again, execute

```
unset FLEET_PACKAGE_REGISTRY_PORT
```

## Checktypes

#### Logs Explorer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package_paths:
- /packages/package-storage
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
* 2.0.
*/

import { FtrConfigProviderContext, GenericFtrProviderContext } from '@kbn/test';
import {
FtrConfigProviderContext,
GenericFtrProviderContext,
defineDockerServersConfig,
} from '@kbn/test';
import { createLogger, LogLevel, LogsSynthtraceEsClient } from '@kbn/apm-synthtrace';
import path from 'path';
import { dockerImage } from '../../../fleet_api_integration/config.base';
import { FtrProviderContext as InheritedFtrProviderContext } from '../../ftr_provider_context';

export type InheritedServices = InheritedFtrProviderContext extends GenericFtrProviderContext<
Expand Down Expand Up @@ -37,9 +43,31 @@ export default async function createTestConfig({
const functionalConfig = await readConfigFile(require.resolve('../../config.base.js'));
const services = functionalConfig.get('services');

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 {
...functionalConfig.getAll(),
testFiles: [require.resolve('.')],
dockerServers: defineDockerServersConfig({
registry: {
enabled: !!dockerRegistryPort,
image: dockerImage,
portInContainer: 8080,
port: dockerRegistryPort,
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 2 * 1000, // 2 minutes
},
}),
services: {
...services,
logSynthtraceEsClient: (context: InheritedFtrProviderContext) => {
Expand Down
18 changes: 17 additions & 1 deletion x-pack/test_serverless/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,20 @@ describe("my test suite", async function() {
});
```

If you are running tests from your local against MKI projects, make sure to add `--exclude-tag=skipMKI` to your FTR command.
If you are running tests from your local against MKI projects, make sure to add `--exclude-tag=skipMKI` to your FTR command.

## Run tests with dockerized package registry

For tests using package registry we have enabled a configuration that uses a dockerized lite version to execute the tests in the CI, this will reduce the flakyness of them when calling the real endpoint.

To be able to run this version locally you must have a docker daemon running in your system and set `FLEET_PACKAGE_REGISTRY_PORT` env var. In order to set this variable execute

```
export set FLEET_PACKAGE_REGISTRY_PORT=12345
```

To unset the variable, and run the tests against the real endpoint again, execute

```
unset FLEET_PACKAGE_REGISTRY_PORT
```
6 changes: 2 additions & 4 deletions x-pack/test_serverless/functional/config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
* 2.0.
yngrdyn marked this conversation as resolved.
Show resolved Hide resolved
*/

import { resolve } from 'path';

import { FtrConfigProviderContext } from '@kbn/test';

import { resolve } from 'path';
import { pageObjects } from './page_objects';
import { services } from './services';
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'));

return {
...svlSharedConfig.getAll(),

Expand All @@ -37,7 +36,6 @@ export function createTestConfig(options: CreateTestConfigOptions) {
],
},
testFiles: options.testFiles,

uiSettings: {
defaults: {
'accessibility:disableAnimations': true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package_paths:
- /packages/package-storage
25 changes: 25 additions & 0 deletions x-pack/test_serverless/shared/config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,23 @@ import {
import { CA_CERT_PATH, kibanaDevServiceAccount } from '@kbn/dev-utils';
import { commonFunctionalServices } from '@kbn/ftr-common-functional-services';
import { MOCK_IDP_REALM_NAME } from '@kbn/mock-idp-utils';
import path from 'path';
import { defineDockerServersConfig } from '@kbn/test';
import { dockerImage } from '@kbn/test-suites-xpack/fleet_api_integration/config.base';
import { services } from './services';

export default async () => {
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;

const servers = {
kibana: {
...kbnTestConfig.getUrlParts(kibanaTestSuperuserServerless),
Expand Down Expand Up @@ -49,6 +63,17 @@ export default async () => {

return {
servers,
dockerServers: defineDockerServersConfig({
registry: {
enabled: !!dockerRegistryPort,
image: dockerImage,
portInContainer: 8080,
port: dockerRegistryPort,
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 2 * 1000, // 2 minutes
},
}),
browser: {
acceptInsecureCerts: true,
},
Expand Down