From 131cd058c5c18b4f41e6b38bad918c1e980c79b7 Mon Sep 17 00:00:00 2001 From: Maxim Kholod Date: Fri, 17 Apr 2026 14:11:42 +0200 Subject: [PATCH] [Entity Analytics] Fix CSV upload test to stop automated-resolution maintainer After PR #263732 (init on install), entity maintainers are initialized during the Entity Store install flow. The CSV upload test relied on maintainers not being initialized, causing a race condition where the automated-resolution maintainer links entities before the test can assert. Stop the maintainer explicitly in the before hook with a try/catch for backward compatibility. --- .../resolution_csv_upload.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/x-pack/solutions/security/test/security_solution_api_integration/test_suites/entity_analytics/entity_resolution/trial_license_complete_tier/resolution_csv_upload.ts b/x-pack/solutions/security/test/security_solution_api_integration/test_suites/entity_analytics/entity_resolution/trial_license_complete_tier/resolution_csv_upload.ts index 32a6c41c68864..8cc1397003f86 100644 --- a/x-pack/solutions/security/test/security_solution_api_integration/test_suites/entity_analytics/entity_resolution/trial_license_complete_tier/resolution_csv_upload.ts +++ b/x-pack/solutions/security/test/security_solution_api_integration/test_suites/entity_analytics/entity_resolution/trial_license_complete_tier/resolution_csv_upload.ts @@ -12,6 +12,7 @@ import { ENTITY_STORE_ROUTES, API_VERSIONS } from '@kbn/entity-store/common'; import { ENTITY_RESOLUTION_CSV_UPLOAD_URL } from '@kbn/security-solution-plugin/common/entity_analytics/entity_store/constants'; import type { FtrProviderContext } from '../../../../ftr_provider_context'; import { EntityStoreUtils } from '../../utils'; +import { entityMaintainerRouteHelpersFactory } from '../../utils/entity_maintainers'; const TEST_PREFIX = 'csv-test:'; @@ -49,6 +50,7 @@ export default ({ getService }: FtrProviderContext) => { const log = getService('log'); const retry = getService('retry'); const entityStoreUtils = EntityStoreUtils(getService); + const maintainerRoutes = entityMaintainerRouteHelpersFactory(supertest); const uploadCsv = (csvContent: string) => supertest @@ -116,11 +118,18 @@ export default ({ getService }: FtrProviderContext) => { describe('@ess @serverless @skipInServerlessMKI Entity Resolution CSV Upload', () => { before(async () => { - // Use enableEntityStoreV2 (without maintainer init) to prevent the - // automated resolution maintainer from racing with CSV upload tests. - // The maintainer would link entities sharing the same user.email, - // interfering with the test's own resolution assertions. await entityStoreUtils.enableEntityStoreV2(); + + // Stop the automated resolution maintainer to prevent it from racing + // with CSV upload tests. The maintainer would link entities sharing + // the same user.email, interfering with the test's own assertions. + try { + await maintainerRoutes.stopMaintainer('automated-resolution'); + } catch (e) { + // Maintainer may not be initialized yet (pre-#263732); safe to ignore. + log.debug(`Could not stop automated-resolution maintainer: ${e.message}`); + } + await cleanEntities(); await seedEntities(); await waitForEntities();