Skip to content

Commit

Permalink
[Index Management] Fix enrich policies api test (#172923)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarasaba authored Dec 13, 2023
1 parent 43b48ad commit d3535bd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`;

Expand Down Expand Up @@ -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 () => {
Expand All @@ -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);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ 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');

const ENRICH_INDEX_NAME = 'test-policy-1';
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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d3535bd

Please sign in to comment.