mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Logs explorer] Using dockerized package registry in tests (#192064)
Closes https://github.com/elastic/kibana/issues/190343. This PR aims to use a dockerized package registry version for testing. In order to test it locally you have to set the value of `FLEET_PACKAGE_REGISTRY_PORT` env var in your terminal, and you also need to have a docker daemon running. For example, you can open a terminal and start the server ``` yarn test:ftr:server --config ./x-pack/test/functional/apps/observability_logs_explorer/config.ts ``` then open a new terminal set the var value and start the runner with the specific test using this configuration ``` export set FLEET_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:runner --config ./x-pack/test/functional/apps/observability_logs_explorer/config.ts --include ./x-pack/test/functional/apps/observability_logs_explorer/data_source_selector ``` If you want to test again without the dockerized version, you should remove the value of the var ``` unset FLEET_PACKAGE_REGISTRY_PORT ```
This commit is contained in:
parent
ad7d935de0
commit
d8445ccab6
7 changed files with 93 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
package_paths:
|
||||
- /packages/package-storage
|
|
@ -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<
|
||||
|
@ -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) => {
|
||||
|
|
|
@ -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
|
||||
```
|
||||
|
|
|
@ -5,10 +5,8 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
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';
|
||||
|
@ -16,6 +14,7 @@ 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(),
|
||||
|
||||
|
@ -37,7 +36,6 @@ export function createTestConfig(options: CreateTestConfigOptions) {
|
|||
],
|
||||
},
|
||||
testFiles: options.testFiles,
|
||||
|
||||
uiSettings: {
|
||||
defaults: {
|
||||
'accessibility:disableAnimations': true,
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
package_paths:
|
||||
- /packages/package-storage
|
|
@ -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),
|
||||
|
@ -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,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue