From d3535bd96dcf2499a8134c550e8e642dfe72bc49 Mon Sep 17 00:00:00 2001 From: Ignacio Rivas Date: Wed, 13 Dec 2023 09:52:40 +0100 Subject: [PATCH] [Index Management] Fix enrich policies api test (#172923) --- .../index_management/enrich_policies.ts | 6 +++-- .../index_management/enrich_policies.ts | 25 +++++++++---------- .../index_management/create_enrich_policy.ts | 4 --- .../index_management/enrich_policies.ts | 5 ---- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/x-pack/test/api_integration/apis/management/index_management/enrich_policies.ts b/x-pack/test/api_integration/apis/management/index_management/enrich_policies.ts index c76c7d1c016c9..9fe4bd67baceb 100644 --- a/x-pack/test/api_integration/apis/management/index_management/enrich_policies.ts +++ b/x-pack/test/api_integration/apis/management/index_management/enrich_policies.ts @@ -65,9 +65,11 @@ export default function ({ getService }: FtrProviderContext) { }); it('should be able to delete a policy', async () => { - const { body } = await removeEnrichPolicy(POLICY_NAME).expect(200); + const { status } = await removeEnrichPolicy(POLICY_NAME); - expect(body).toStrictEqual({ acknowledged: true }); + // In the odd case that the policy is somehow still being executed, the delete + // method might return a 429 so we need to account for that. + expect([200, 429]).toContain(status); }); }); } diff --git a/x-pack/test_serverless/api_integration/test_suites/common/index_management/enrich_policies.ts b/x-pack/test_serverless/api_integration/test_suites/common/index_management/enrich_policies.ts index 27020322a0e4e..d3b8f655cab2c 100644 --- a/x-pack/test_serverless/api_integration/test_suites/common/index_management/enrich_policies.ts +++ b/x-pack/test_serverless/api_integration/test_suites/common/index_management/enrich_policies.ts @@ -12,8 +12,7 @@ export default function ({ getService }: FtrProviderContext) { const log = getService('log'); const indexManagementService = getService('indexManagement'); - // Failing: See https://github.com/elastic/kibana/issues/172697 - describe.skip('Enrich policies', function () { + describe('Enrich policies', function () { const INDEX_NAME = `index-${Math.random()}`; const POLICY_NAME = `policy-${Math.random()}`; @@ -54,15 +53,13 @@ export default function ({ getService }: FtrProviderContext) { it('should list all policies', async () => { const { body } = await getAllEnrichPolicies().expect(200); - expect(body).toEqual([ - { - enrichFields: ['firstName'], - matchField: 'email', - name: POLICY_NAME, - sourceIndices: [INDEX_NAME], - type: 'match', - }, - ]); + expect(body).toContainEqual({ + enrichFields: ['firstName'], + matchField: 'email', + name: POLICY_NAME, + sourceIndices: [INDEX_NAME], + type: 'match', + }); }); it('should be able to execute a policy', async () => { @@ -74,9 +71,11 @@ export default function ({ getService }: FtrProviderContext) { }); it('should be able to delete a policy', async () => { - const { body } = await removeEnrichPolicy(POLICY_NAME).expect(200); + const { status } = await removeEnrichPolicy(POLICY_NAME); - expect(body).toEqual({ acknowledged: true }); + // In the odd case that the policy is somehow still being executed, the delete + // method might return a 429 so we need to account for that. + expect([200, 429]).toContain(status); }); }); } diff --git a/x-pack/test_serverless/functional/test_suites/common/management/index_management/create_enrich_policy.ts b/x-pack/test_serverless/functional/test_suites/common/management/index_management/create_enrich_policy.ts index 81a8551a0b8b4..43b325f9f469d 100644 --- a/x-pack/test_serverless/functional/test_suites/common/management/index_management/create_enrich_policy.ts +++ b/x-pack/test_serverless/functional/test_suites/common/management/index_management/create_enrich_policy.ts @@ -11,7 +11,6 @@ import { FtrProviderContext } from '../../../../ftr_provider_context'; export default ({ getPageObjects, getService }: FtrProviderContext) => { const pageObjects = getPageObjects(['common', 'indexManagement', 'header', 'svlCommonPage']); const log = getService('log'); - const security = getService('security'); const comboBox = getService('comboBox'); const testSubjects = getService('testSubjects'); const es = getService('es'); @@ -20,8 +19,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const POLICY_NAME = `policy-${Math.random()}`; describe('Create enrich policy', function () { - // TimeoutError: Waiting for element to be located By(css selector, [data-test-subj="enrichPoliciesEmptyPromptCreateButton"]) - this.tags(['failsOnMKI']); before(async () => { log.debug('Creating test index'); try { @@ -47,7 +44,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { log.debug('Navigating to the enrich policies tab'); await pageObjects.svlCommonPage.login(); - await security.testUser.setRoles(['index_management_user']); await pageObjects.common.navigateToApp('indexManagement'); // Navigate to the enrich policies tab diff --git a/x-pack/test_serverless/functional/test_suites/common/management/index_management/enrich_policies.ts b/x-pack/test_serverless/functional/test_suites/common/management/index_management/enrich_policies.ts index 2a60ea95ebe0c..707bd598bb3d8 100644 --- a/x-pack/test_serverless/functional/test_suites/common/management/index_management/enrich_policies.ts +++ b/x-pack/test_serverless/functional/test_suites/common/management/index_management/enrich_policies.ts @@ -13,7 +13,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const pageObjects = getPageObjects(['common', 'indexManagement', 'header', 'svlCommonPage']); const log = getService('log'); const browser = getService('browser'); - const security = getService('security'); const testSubjects = getService('testSubjects'); const es = getService('es'); @@ -21,9 +20,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const ENRICH_POLICY_NAME = 'test-policy-1'; describe('Enrich policies tab', function () { - // TimeoutError: Waiting for element to be located By(css selector, [data-test-subj="kibana-chrome"]) - this.tags(['failsOnMKI']); - before(async () => { log.debug('Creating required index and enrich policy'); try { @@ -55,7 +51,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { log.debug('Navigating to the enrich policies tab'); await pageObjects.svlCommonPage.login(); - await security.testUser.setRoles(['index_management_user']); await pageObjects.common.navigateToApp('indexManagement'); // Navigate to the enrich policies tab