Skip to content

Commit

Permalink
[Security Solution] fix endpoint list + metadata api FTR tests (#170489)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeypoon authored Dec 11, 2023
1 parent 61cd731 commit a50b97f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const retryResponseStatuses = [
410, // Gone
];

const retryMessages = ['no_shard_available_action_exception'];

const isRetryableError = (e: any, additionalResponseStatuses: number[] = []) =>
retryMessages.some((msg) => e.message.includes(msg)) ||
e instanceof EsErrors.NoLivingConnectionsError ||
e instanceof EsErrors.ConnectionError ||
e instanceof EsErrors.TimeoutError ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

import semverLte from 'semver/functions/lte';

const MIN_ENDPOINT_PACKAGE_V2_VERSION = '8.12.0';
function parseSemver(semver: string) {
return semver.includes('-') ? semver.substring(0, semver.indexOf('-')) : semver;
}

const MIN_ENDPOINT_PACKAGE_V2_VERSION = '8.13.0';
export function isEndpointPackageV2(version: string) {
return semverLte(MIN_ENDPOINT_PACKAGE_V2_VERSION, version);
const parsedVersion = parseSemver(version);
return semverLte(MIN_ENDPOINT_PACKAGE_V2_VERSION, parsedVersion);
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.endpoint.navigateToEndpointList();
});

// FLAKY: https://github.com/elastic/kibana/issues/170357
describe.skip('when there is data,', () => {
describe('when there is data,', () => {
before(async () => {
indexedData = await endpointTestResources.loadEndpointData({ numHosts: 3 });
await pageObjects.endpoint.navigateToEndpointList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
);
};

describe('Response Actions Responder', function () {
// FLAKY: https://github.com/elastic/kibana/issues/153071
describe.skip('Response Actions Responder', function () {
targetTags(this, ['@ess', '@serverless']);

let indexedData: IndexedHostsAndAlertsResponse;
Expand Down
11 changes: 9 additions & 2 deletions x-pack/test/security_solution_endpoint/services/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { errors } from '@elastic/elasticsearch';
import { Client } from '@elastic/elasticsearch';
import { AGENTS_INDEX } from '@kbn/fleet-plugin/common';
import {
metadataCurrentIndexPattern,
metadataTransformPrefix,
Expand Down Expand Up @@ -94,7 +95,7 @@ export class EndpointTestResources extends FtrService {
* @param [options.enableFleetIntegration=true] When set to `true`, Fleet data will also be loaded (ex. Integration Policies, Agent Policies, "fake" Agents)
* @param [options.generatorSeed='seed`] The seed to be used by the data generator. Important in order to ensure the same data is generated on very run.
* @param [options.waitUntilTransformed=true] If set to `true`, the data loading process will wait until the endpoint hosts metadata is processed by the transform
* @param [options.waitTimeout=60000] If waitUntilTransformed=true, number of ms to wait until timeout
* @param [options.waitTimeout=120000] If waitUntilTransformed=true, number of ms to wait until timeout
* @param [options.customIndexFn] If provided, will use this function to generate and index data instead
*/
async loadEndpointData(
Expand All @@ -116,7 +117,7 @@ export class EndpointTestResources extends FtrService {
enableFleetIntegration = true,
generatorSeed = 'seed',
waitUntilTransformed = true,
waitTimeout = 60000,
waitTimeout = 120000,
customIndexFn,
} = options;

Expand Down Expand Up @@ -197,6 +198,12 @@ export class EndpointTestResources extends FtrService {

await this.retry.waitForWithTimeout(`endpoint hosts in ${index}`, timeout, async () => {
try {
if (index === METADATA_UNITED_INDEX) {
// United metadata transform occasionally can't find docs in .fleet-agents.
// Running a search on the index first eliminates this issue.
// Replacing the search with a refresh does not resolve flakiness.
await this.esClient.search({ index: AGENTS_INDEX });
}
const searchResponse = await this.esClient.search({
index,
size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ export default function ({ getService }: FtrProviderContext) {
const endpointTestResources = getService('endpointTestResources');
const log = getService('log');

// Failing: See https://github.com/elastic/kibana/issues/151854
describe.skip('test metadata apis', function () {
describe('test metadata apis', function () {
targetTags(this, ['@ess', '@serverless']);

describe('list endpoints GET route', () => {
Expand Down

0 comments on commit a50b97f

Please sign in to comment.