From 4694c5124f49176a09706213a554c5fcb1dbfa14 Mon Sep 17 00:00:00 2001 From: "Joey F. Poon" Date: Mon, 11 Dec 2023 16:56:03 -0800 Subject: [PATCH] [Security Solution] fix flaky endpoint cypress tests --- .../management/cypress/e2e/endpoint_list/endpoints.cy.ts | 3 +-- .../cypress/e2e/response_actions/responder.cy.ts | 3 +-- .../support/plugin_handlers/endpoint_data_loader.ts | 8 ++++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/security_solution/public/management/cypress/e2e/endpoint_list/endpoints.cy.ts b/x-pack/plugins/security_solution/public/management/cypress/e2e/endpoint_list/endpoints.cy.ts index 61874be0f8654..2baf3b583aed4 100644 --- a/x-pack/plugins/security_solution/public/management/cypress/e2e/endpoint_list/endpoints.cy.ts +++ b/x-pack/plugins/security_solution/public/management/cypress/e2e/endpoint_list/endpoints.cy.ts @@ -32,8 +32,7 @@ import { createEndpointHost } from '../../tasks/create_endpoint_host'; import { deleteAllLoadedEndpointData } from '../../tasks/delete_all_endpoint_data'; import { enableAllPolicyProtections } from '../../tasks/endpoint_policy'; -// Failing: See https://github.com/elastic/kibana/issues/169903 -describe.skip('Endpoints page', { tags: ['@ess', '@serverless'] }, () => { +describe('Endpoints page', { tags: ['@ess', '@serverless'] }, () => { let indexedPolicy: IndexedFleetEndpointPolicyResponse; let policy: PolicyData; let createdHost: CreateAndEnrollEndpointHostResponse; diff --git a/x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/responder.cy.ts b/x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/responder.cy.ts index ebcac6dd439df..09e11e82abea5 100644 --- a/x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/responder.cy.ts +++ b/x-pack/plugins/security_solution/public/management/cypress/e2e/response_actions/responder.cy.ts @@ -40,8 +40,7 @@ describe('When accessing Endpoint Response Console', { tags: ['@ess', '@serverle login(); }); - // FLAKY: https://github.com/elastic/kibana/issues/169894 - describe.skip('from Cases', () => { + describe('from Cases', () => { let endpointData: ReturnTypeFromChainable; let caseData: ReturnTypeFromChainable; let alertData: ReturnTypeFromChainable; diff --git a/x-pack/plugins/security_solution/public/management/cypress/support/plugin_handlers/endpoint_data_loader.ts b/x-pack/plugins/security_solution/public/management/cypress/support/plugin_handlers/endpoint_data_loader.ts index b81a446a09a7d..b9020b4b528f5 100644 --- a/x-pack/plugins/security_solution/public/management/cypress/support/plugin_handlers/endpoint_data_loader.ts +++ b/x-pack/plugins/security_solution/public/management/cypress/support/plugin_handlers/endpoint_data_loader.ts @@ -10,6 +10,7 @@ import type { KbnClient } from '@kbn/test'; import pRetry from 'p-retry'; import { kibanaPackageJson } from '@kbn/repo-info'; import type { ToolingLog } from '@kbn/tooling-log'; +import { AGENTS_INDEX } from '@kbn/fleet-plugin/common'; import { STARTED_TRANSFORM_STATES } from '../../../../../common/constants'; import { ENDPOINT_ALERTS_INDEX, @@ -202,6 +203,13 @@ const waitForEndpoints = async ( await pRetry( async () => { + 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 esClient.search({ index: AGENTS_INDEX }); + } + const response = await esClient.search({ index, size: expectedSize,