[Fleet] Rename ingest_manager_api_integration tests fleet_api_integration (#83011) (#83326)

This commit is contained in:
Nicolas Chaulet 2020-11-12 16:37:41 -05:00 committed by GitHub
parent 5f36a27b33
commit acd3e35f90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
168 changed files with 107 additions and 143 deletions

View file

@ -69,7 +69,7 @@ export const IGNORE_FILE_GLOBS = [
'x-pack/plugins/maps/server/fonts/**/*',
// packages for the ingest manager's api integration tests could be valid semver which has dashes
'x-pack/test/ingest_manager_api_integration/apis/fixtures/test_packages/**/*',
'x-pack/test/fleet_api_integration/apis/fixtures/test_packages/**/*',
];
/**

View file

@ -87,7 +87,7 @@ def withFunctionalTestEnv(List additionalEnvs = [], Closure closure) {
def kibanaPort = "61${parallelId}1"
def esPort = "61${parallelId}2"
def esTransportPort = "61${parallelId}3"
def ingestManagementPackageRegistryPort = "61${parallelId}4"
def fleetPackageRegistryPort = "61${parallelId}4"
def alertingProxyPort = "61${parallelId}5"
withEnv([
@ -100,7 +100,7 @@ def withFunctionalTestEnv(List additionalEnvs = [], Closure closure) {
"TEST_ES_URL=http://elastic:changeme@localhost:${esPort}",
"TEST_ES_TRANSPORT_PORT=${esTransportPort}",
"KBN_NP_PLUGINS_BUILT=true",
"INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=${ingestManagementPackageRegistryPort}",
"FLEET_PACKAGE_REGISTRY_PORT=${fleetPackageRegistryPort}",
"ALERTING_PROXY_PORT=${alertingProxyPort}"
] + additionalEnvs) {
closure()

View file

@ -55,17 +55,17 @@ You need to have `docker` to run ingest manager api integration tests
1. In one terminal, run the tests from the Kibana root directory with
```
INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:server --config x-pack/test/ingest_manager_api_integration/config.ts
FLEET_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:server --config x-pack/test/fleet_api_integration/config.ts
```
1. in a second terminal, run the tests from the Kibana root directory with
```
INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:runner --config x-pack/test/ingest_manager_api_integration/config.ts
FLEET_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:runner --config x-pack/test/fleet_api_integration/config.ts
```
Optionally you can filter which tests you want to run using `--grep`
```
INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:runner --config x-pack/test/ingest_manager_api_integration/config.ts --grep='fleet'
FLEET_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:runner --config x-pack/test/fleet_api_integration/config.ts --grep='fleet'
```

View file

@ -5,29 +5,29 @@ Many API integration tests for Ingest Manager trigger at some point a connection
- the deployed registry is temporarily unavailable
- the packages served by the registry do not match the expectation of the code under test
For that reason, we run a dockerized version of the package registry in Kibana CI. For this to work, our tests must run against a custom test configuration and be kept in a custom directory, `x-pack/test/ingest_manager_api_integration`.
For that reason, we run a dockerized version of the package registry in Kibana CI. For this to work, our tests must run against a custom test configuration and be kept in a custom directory, `x-pack/test/fleet_api_integration`.
## How to run the tests locally
Usually, having the test server and the test runner in two different shells is most efficient, as it is possible to keep the server running and only rerun the test runner as often as needed. To do so, in one shell in the main `kibana` directory, run:
```
$ export INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345
$ yarn test:ftr:server --config x-pack/test/ingest_manager_api_integration/config.ts
$ export FLEET_PACKAGE_REGISTRY_PORT=12345
$ yarn test:ftr:server --config x-pack/test/fleet_api_integration/config.ts
```
In another shell in the same directory, run
```
$ export INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345
$ yarn test:ftr:runner --config x-pack/test/ingest_manager_api_integration/config.ts
$ export FLEET_PACKAGE_REGISTRY_PORT=12345
$ yarn test:ftr:runner --config x-pack/test/fleet_api_integration/config.ts
```
However, it is also possible to **alternatively** run everything in one go, again from the main `kibana` directory:
```
$ export INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345
$ yarn test:ftr --config x-pack/test/ingest_manager_api_integration/config.ts
$ export FLEET_PACKAGE_REGISTRY_PORT=12345
$ yarn test:ftr --config x-pack/test/fleet_api_integration/config.ts
```
Port `12345` is used as an example here, it can be anything, but the environment variable has to be present for the tests to run at all.
@ -37,7 +37,7 @@ Port `12345` is used as an example here, it can be anything, but the environment
We use the `DockerServers` service provided by `kbn-test`. The documentation for this functionality can be found here:
https://github.com/elastic/kibana/blob/master/packages/kbn-test/src/functional_test_runner/lib/docker_servers/README.md
The main configuration for the `DockerServers` service for our tests can be found in `x-pack/test/ingest_manager_api_integration/config.ts`:
The main configuration for the `DockerServers` service for our tests can be found in `x-pack/test/fleet_api_integration/config.ts`:
### Specify the arguments to pass to `docker run`:
@ -74,13 +74,13 @@ The containerized package registry contains a set of packages which should be su
docker run -p 8080:8080 docker.elastic.co/package-registry/package-registry:kibana-testing-1
```
Additional packages for testing certain corner cases or error conditions can be put into `x-pack/test/ingest_manager_api_integration/apis/fixtures/test_packages`. A package `filetest` has been added there as an example.
Additional packages for testing certain corner cases or error conditions can be put into `x-pack/test/fleet_api_integration/apis/fixtures/test_packages`. A package `filetest` has been added there as an example.
## Some DockerServers background
For the `DockerServers` servers to run correctly in CI, the `INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT` environment variable needs to be under control of the CI environment. The reason behind this: it is possible that several versions of our tests are run in parallel on the same worker in Jenkins, and if we used a hard-coded port number here, those tests would run into port conflicts. (This is also the case for a few other ports, and the setup happens in `vars/kibanaPipeline.groovy`).
For the `DockerServers` servers to run correctly in CI, the `FLEET_PACKAGE_REGISTRY_PORT` environment variable needs to be under control of the CI environment. The reason behind this: it is possible that several versions of our tests are run in parallel on the same worker in Jenkins, and if we used a hard-coded port number here, those tests would run into port conflicts. (This is also the case for a few other ports, and the setup happens in `vars/kibanaPipeline.groovy`).
Also, not every developer has `docker` installed on their workstation, so it must be possible to run the testsuite as a whole without `docker`, and preferably this should be the default behaviour. Therefore, our `DockerServers` service is only enabled when `INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT` is set. This needs to be checked in every test like this:
Also, not every developer has `docker` installed on their workstation, so it must be possible to run the testsuite as a whole without `docker`, and preferably this should be the default behaviour. Therefore, our `DockerServers` service is only enabled when `FLEET_PACKAGE_REGISTRY_PORT` is set. This needs to be checked in every test like this:
```
it('fetches a .json search file', async function () {
@ -105,7 +105,7 @@ If the tests are skipped in this way, they are marked in the test summary as `pe
└-> "before all" hook
└-> lists all packages from the registry
└-> "before each" hook: global before each
│ warn disabling tests because DockerServers service is not enabled, set INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT to run them
│ warn disabling tests because DockerServers service is not enabled, set FLEET_PACKAGE_REGISTRY_PORT to run them
└-> lists all packages from the registry
└-> "after all" hook
[...]

View file

@ -28,7 +28,7 @@ The endpoint functional tests are located [here](../../test/security_solution_en
### Using Docker
To run the tests using the recommended docker image version you must have `docker` installed. The testing infrastructure
will stand up a docker container using the image defined [here](../../test/ingest_manager_api_integration/config.ts#L15)
will stand up a docker container using the image defined [here](../../test/fleet_api_integration/config.ts#L15)
Make sure you're in the Kibana root directory.
@ -37,13 +37,13 @@ Make sure you're in the Kibana root directory.
In one terminal, run:
```bash
INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:server --config x-pack/test/security_solution_endpoint_api_int/config.ts
FLEET_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:server --config x-pack/test/security_solution_endpoint_api_int/config.ts
```
In another terminal, run:
```bash
INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:runner --config x-pack/test/security_solution_endpoint_api_int/config.ts
FLEET_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:runner --config x-pack/test/security_solution_endpoint_api_int/config.ts
```
#### Endpoint Functional Tests
@ -51,13 +51,13 @@ INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:runner --config x-pa
In one terminal, run:
```bash
INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:server --config x-pack/test/security_solution_endpoint/config.ts
FLEET_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:server --config x-pack/test/security_solution_endpoint/config.ts
```
In another terminal, run:
```bash
INGEST_MANAGEMENT_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:runner --config x-pack/test/security_solution_endpoint/config.ts
FLEET_PACKAGE_REGISTRY_PORT=12345 yarn test:ftr:runner --config x-pack/test/security_solution_endpoint/config.ts
```
### Running your own package registry

View file

@ -63,7 +63,7 @@ require('@kbn/test').runTestsCli([
require.resolve('../test/reporting_api_integration/reporting_and_security.config.ts'),
require.resolve('../test/reporting_api_integration/reporting_without_security.config.ts'),
require.resolve('../test/security_solution_endpoint_api_int/config.ts'),
require.resolve('../test/ingest_manager_api_integration/config.ts'),
require.resolve('../test/fleet_api_integration/config.ts'),
require.resolve('../test/functional_enterprise_search/without_host_configured.config.ts'),
require.resolve('../test/functional_vis_wizard/config.ts'),
require.resolve('../test/saved_object_tagging/functional/config.ts'),

View file

@ -11,7 +11,7 @@ export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');
describe('ingest_manager_agent_policies', () => {
describe('fleet_agent_policies', () => {
const createdPolicyIds: string[] = [];
after(async () => {
const deletedPromises = createdPolicyIds.map((agentPolicyId) =>

View file

@ -7,7 +7,7 @@
import expect from '@kbn/expect';
import { skipIfNoDockerRegistry } from '../../helpers';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { setupIngest, getSupertestWithoutAuth } from '../fleet/agents/services';
import { setupFleetAndAgents, getSupertestWithoutAuth } from '../agents/services';
export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
@ -68,7 +68,7 @@ export default function (providerContext: FtrProviderContext) {
}
// Test all the side effect that should occurs when we create|update an agent policy
describe('ingest_manager_agent_policies_with_agents_setup', () => {
describe('fleet_agent_policies_with_agents_setup', () => {
skipIfNoDockerRegistry(providerContext);
before(async () => {
@ -78,7 +78,7 @@ export default function (providerContext: FtrProviderContext) {
await esArchiver.unload('fleet/agents');
});
setupIngest(providerContext);
setupFleetAndAgents(providerContext);
describe('POST /api/fleet/agent_policies', () => {
it('should create an enrollment key and an agent action `POLICY_CHANGE` for the policy', async () => {

View file

@ -5,7 +5,7 @@
*/
export default function loadTests({ loadTestFile }) {
describe('Ingest Manager Endpoints', () => {
describe('Fleet Endpoints', () => {
loadTestFile(require.resolve('./agent_policy_with_agents_setup'));
loadTestFile(require.resolve('./agent_policy'));
});

View file

@ -6,7 +6,7 @@
import expect from '@kbn/expect';
import uuid from 'uuid';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { getSupertestWithoutAuth } from './services';
export default function (providerContext: FtrProviderContext) {

View file

@ -5,7 +5,7 @@
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;

View file

@ -7,9 +7,9 @@
import expect from '@kbn/expect';
import uuid from 'uuid';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { getSupertestWithoutAuth, setupIngest } from './services';
import { skipIfNoDockerRegistry } from '../../../helpers';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { getSupertestWithoutAuth, setupFleetAndAgents } from './services';
import { skipIfNoDockerRegistry } from '../../helpers';
export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
@ -46,7 +46,7 @@ export default function (providerContext: FtrProviderContext) {
},
});
});
setupIngest(providerContext);
setupFleetAndAgents(providerContext);
after(async () => {
await esArchiver.unload('fleet/agents');
});

View file

@ -6,9 +6,9 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { setupIngest, getSupertestWithoutAuth } from './services';
import { skipIfNoDockerRegistry } from '../../../helpers';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { setupFleetAndAgents, getSupertestWithoutAuth } from './services';
import { skipIfNoDockerRegistry } from '../../helpers';
export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
@ -24,7 +24,7 @@ export default function (providerContext: FtrProviderContext) {
before(async () => {
await esArchiver.load('empty_kibana');
});
setupIngest(providerContext);
setupFleetAndAgents(providerContext);
after(async () => {
await esArchiver.unload('empty_kibana');
});

View file

@ -5,7 +5,7 @@
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');

View file

@ -7,9 +7,9 @@
import expect from '@kbn/expect';
import uuid from 'uuid';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { getSupertestWithoutAuth, setupIngest, getEsClientForAPIKey } from './services';
import { skipIfNoDockerRegistry } from '../../../helpers';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { getSupertestWithoutAuth, setupFleetAndAgents, getEsClientForAPIKey } from './services';
import { skipIfNoDockerRegistry } from '../../helpers';
export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
@ -52,7 +52,7 @@ export default function (providerContext: FtrProviderContext) {
const kibanaVersionAccessor = kibanaServer.version;
kibanaVersion = await kibanaVersionAccessor.get();
});
setupIngest(providerContext);
setupFleetAndAgents(providerContext);
after(async () => {
await esArchiver.unload('fleet/agents');
});

View file

@ -6,7 +6,7 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');

View file

@ -6,7 +6,7 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');

View file

@ -4,8 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { setupIngest } from './services';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { setupFleetAndAgents } from './services';
export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
@ -13,7 +13,7 @@ export default function (providerContext: FtrProviderContext) {
const supertest = getService('supertest');
describe('fleet_reassign_agent', () => {
setupIngest(providerContext);
setupFleetAndAgents(providerContext);
before(async () => {
await esArchiver.loadIfNeeded('fleet/agents');
});

View file

@ -8,7 +8,7 @@ import supertestAsPromised from 'supertest-as-promised';
import { Client } from '@elastic/elasticsearch';
import { format as formatUrl } from 'url';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
export function getSupertestWithoutAuth({ getService }: FtrProviderContext) {
const config = getService('config');
@ -31,7 +31,7 @@ export function getEsClientForAPIKey({ getService }: FtrProviderContext, esApiKe
});
}
export function setupIngest({ getService }: FtrProviderContext) {
export function setupFleetAndAgents({ getService }: FtrProviderContext) {
before(async () => {
await getService('supertest').post(`/api/fleet/setup`).set('kbn-xsrf', 'xxx').send();
await getService('supertest')

View file

@ -7,9 +7,9 @@
import expect from '@kbn/expect';
import uuid from 'uuid';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { setupIngest } from './services';
import { skipIfNoDockerRegistry } from '../../../helpers';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { setupFleetAndAgents } from './services';
import { skipIfNoDockerRegistry } from '../../helpers';
export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
@ -24,7 +24,7 @@ export default function (providerContext: FtrProviderContext) {
before(async () => {
await esArchiver.loadIfNeeded('fleet/agents');
});
setupIngest(providerContext);
setupFleetAndAgents(providerContext);
beforeEach(async () => {
const { body: accessAPIKeyBody } = await esClient.security.createApiKey({
body: {

View file

@ -6,10 +6,10 @@
import expect from '@kbn/expect/expect.js';
import semver from 'semver';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { setupIngest } from './services';
import { skipIfNoDockerRegistry } from '../../../helpers';
import { AGENT_SAVED_OBJECT_TYPE } from '../../../../../plugins/fleet/common';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { setupFleetAndAgents } from './services';
import { skipIfNoDockerRegistry } from '../../helpers';
import { AGENT_SAVED_OBJECT_TYPE } from '../../../../plugins/fleet/common';
const makeSnapshotVersion = (version: string) => {
return version.endsWith('-SNAPSHOT') ? version : `${version}-SNAPSHOT`;
@ -23,7 +23,7 @@ export default function (providerContext: FtrProviderContext) {
describe('fleet upgrade agent', () => {
skipIfNoDockerRegistry(providerContext);
setupIngest(providerContext);
setupFleetAndAgents(providerContext);
beforeEach(async () => {
await esArchiver.loadIfNeeded('fleet/agents');
});

View file

@ -5,15 +5,15 @@
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { skipIfNoDockerRegistry } from '../../helpers';
import { FtrProviderContext } from '../../api_integration/ftr_provider_context';
import { skipIfNoDockerRegistry } from '../helpers';
export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
const supertest = getService('supertest');
const es = getService('es');
describe('fleet_setup', () => {
describe('fleet_agents_setup', () => {
skipIfNoDockerRegistry(providerContext);
beforeEach(async () => {
try {

View file

@ -6,9 +6,9 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../../api_integration/ftr_provider_context';
import { setupIngest, getEsClientForAPIKey } from '../agents/services';
import { skipIfNoDockerRegistry } from '../../../helpers';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { setupFleetAndAgents, getEsClientForAPIKey } from '../agents/services';
import { skipIfNoDockerRegistry } from '../../helpers';
const ENROLLMENT_KEY_ID = 'ed22ca17-e178-4cfe-8b02-54ea29fbd6d0';
@ -28,7 +28,7 @@ export default function (providerContext: FtrProviderContext) {
});
skipIfNoDockerRegistry(providerContext);
setupIngest(providerContext);
setupFleetAndAgents(providerContext);
describe('GET /fleet/enrollment-api-keys', async () => {
it('should list existing api keys', async () => {

View file

@ -7,7 +7,7 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { skipIfNoDockerRegistry } from '../../helpers';
import { setupIngest } from '../fleet/agents/services';
import { setupFleetAndAgents } from '../agents/services';
export default function (providerContext: FtrProviderContext) {
const { getService } = providerContext;
@ -19,7 +19,7 @@ export default function (providerContext: FtrProviderContext) {
describe('EPM - list', async function () {
skipIfNoDockerRegistry(providerContext);
setupIngest(providerContext);
setupFleetAndAgents(providerContext);
describe('list api tests', async () => {
it('lists all packages from the registry', async function () {

Some files were not shown because too many files have changed in this diff Show more