Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion x-pack/test/common/services/ingest_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* 2.0.
*/

import { fleetSetupRouteService } from '@kbn/fleet-plugin/common';
import { API_VERSIONS, fleetSetupRouteService } from '@kbn/fleet-plugin/common';
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import { FtrProviderContext } from '../ftr_provider_context';

export function IngestManagerProvider({ getService }: FtrProviderContext) {
Expand All @@ -18,6 +19,7 @@ export function IngestManagerProvider({ getService }: FtrProviderContext) {
await retry.try(async () => {
await supertest
.post(fleetSetupRouteService.postFleetSetupPath())
.set(ELASTIC_HTTP_VERSION_HEADER, API_VERSIONS.public.v1)
.set(headers)
.send({ forceRecreate: true })
.expect(200);
Expand Down
1 change: 1 addition & 0 deletions x-pack/test/functional/page_objects/infra_hosts_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { AlertStatus } from '@kbn/rule-data-utils';
import { WebElementWrapper } from '../../../../test/functional/services/lib/web_element_wrapper';
import { FtrProviderContext } from '../ftr_provider_context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import { Client } from '@elastic/elasticsearch';
import { AGENTS_INDEX } from '@kbn/fleet-plugin/common';
import {
metadataIndexPattern,
eventsIndexPattern,
alertsIndexPattern,
policyIndexPattern,
eventsIndexPattern,
METADATA_DATASTREAM,
METADATA_UNITED_INDEX,
metadataCurrentIndexPattern,
metadataIndexPattern,
policyIndexPattern,
telemetryIndexPattern,
METADATA_UNITED_INDEX,
METADATA_DATASTREAM,
} from '@kbn/security-solution-plugin/common/endpoint/constants';

export function deleteDataStream(getService: (serviceName: 'es') => Client, index: string) {
Expand All @@ -38,10 +38,8 @@ export async function deleteAllDocsFromIndex(
const client = getService('es');
await client.deleteByQuery(
{
body: {
query: {
match_all: {},
},
query: {
match_all: {},
},
index,
wait_for_completion: true,
Expand Down Expand Up @@ -132,12 +130,12 @@ export function bulkIndex(
index: string,
docs: unknown[]
) {
const body = docs.flatMap((doc) => [{ create: { _index: index } }, doc]);
const operations = docs.flatMap((doc) => [{ create: { _index: index } }, doc]);
const client = getService('es');

return client.bulk({
index,
refresh: 'wait_for',
body,
operations,
});
}
8 changes: 6 additions & 2 deletions x-pack/test/security_solution_endpoint_api_int/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { getRegistryUrl as getRegistryUrlFromIngest } from '@kbn/fleet-plugin/server';
import { FtrProviderContext } from '../ftr_provider_context';
import { isRegistryEnabled, getRegistryUrlFromTestEnv } from '../registry';
import { getRegistryUrlFromTestEnv, isRegistryEnabled } from '../registry';
import { ROLE } from '../services/roles_users';

export default function endpointAPIIntegrationTests(providerContext: FtrProviderContext) {
Expand All @@ -28,7 +28,11 @@ export default function endpointAPIIntegrationTests(providerContext: FtrProvider

const roles = Object.values(ROLE);
before(async () => {
await ingestManager.setup();
try {
await ingestManager.setup();
} catch (err) {
log.warning(`Error setting up ingestManager: ${err}`);
}

// create role/user
for (const role of roles) {
Expand Down
26 changes: 15 additions & 11 deletions x-pack/test/security_solution_endpoint_api_int/apis/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { v4 as uuidv4 } from 'uuid';
import expect from '@kbn/expect';
import { TransformGetTransformStatsTransformStats } from '@elastic/elasticsearch/lib/api/types';
import {
METADATA_DATASTREAM,
ENDPOINT_DEFAULT_SORT_DIRECTION,
ENDPOINT_DEFAULT_SORT_FIELD,
HOST_METADATA_LIST_ROUTE,
METADATA_DATASTREAM,
METADATA_TRANSFORMS_STATUS_ROUTE,
METADATA_UNITED_INDEX,
METADATA_UNITED_TRANSFORM,
METADATA_TRANSFORMS_STATUS_ROUTE,
metadataTransformPrefix,
ENDPOINT_DEFAULT_SORT_FIELD,
ENDPOINT_DEFAULT_SORT_DIRECTION,
} from '@kbn/security-solution-plugin/common/endpoint/constants';
import { AGENTS_INDEX } from '@kbn/fleet-plugin/common';
import { indexFleetEndpointPolicy } from '@kbn/security-solution-plugin/common/endpoint/data_loaders/index_fleet_endpoint_policy';
Expand All @@ -29,22 +29,22 @@ import {
} from '@kbn/security-solution-plugin/common/endpoint/types';
import { generateAgentDocs, generateMetadataDocs } from './metadata.fixtures';
import {
bulkIndex,
deleteAllDocsFromFleetAgents,
deleteAllDocsFromIndex,
deleteAllDocsFromMetadataCurrentIndex,
deleteAllDocsFromMetadataDatastream,
stopTransform,
startTransform,
deleteAllDocsFromFleetAgents,
deleteAllDocsFromIndex,
bulkIndex,
stopTransform,
} from './data_stream_helper';
import { FtrProviderContext } from '../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const endpointTestResources = getService('endpointTestResources');
const log = getService('log');

// Failing: See https://github.com/elastic/kibana/issues/151854
describe.skip('test metadata apis', () => {
describe('test metadata apis', () => {
describe('list endpoints GET route', () => {
const numberOfHostsInFixture = 2;
let agent1Timestamp: number;
Expand All @@ -55,7 +55,11 @@ export default function ({ getService }: FtrProviderContext) {
await deleteAllDocsFromFleetAgents(getService);
await deleteAllDocsFromMetadataDatastream(getService);
await deleteAllDocsFromMetadataCurrentIndex(getService);
await deleteAllDocsFromIndex(getService, METADATA_UNITED_INDEX);
try {
await deleteAllDocsFromIndex(getService, METADATA_UNITED_INDEX);
} catch (err) {
log.warning(`Unable to delete index: ${err}`);
}

const customIndexFn = async (): Promise<IndexedHostsAndAlertsResponse> => {
// generate an endpoint policy and attach id to agents since
Expand Down