Skip to content

Commit

Permalink
[Rollups] Fix API integration tests (#186079)
Browse files Browse the repository at this point in the history
Fixes #183928
Fixes #184073
Fixes #184081
Fixes #184128

## Summary

This PR fixes the failing Rollup API integration tests. The reason for
the failures is that, since 8.15, Es doesn't allow creating a new rollup
job if there is no existing rollup usage in the cluster, where rollup
usage is considered rollup jobs or rollup indices. To fix the tests, we
create a mock rollup index which essentially is an index that has a
`_meta` mappings property with rollup information.

Flaky test runner build x200:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6296
(there are some failure but they are not related to rollups)
  • Loading branch information
ElenaStoeva committed Jun 13, 2024
1 parent b44e778 commit c23a622
Show file tree
Hide file tree
Showing 4 changed files with 248 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,24 @@ import { stringify } from 'query-string';
import { registerHelpers } from './rollup.test_helpers';
import { getRandomString } from './lib';
import { DataViewType } from '@kbn/data-views-plugin/common';
import { INDEX_TO_ROLLUP_MAPPINGS } from './constants';

export default function ({ getService }) {
const supertest = getService('supertest');

const { createIndexWithMappings, getJobPayload, createJob, cleanUp } =
const { createIndexWithMappings, createMockRollupIndex, getJobPayload, createJob, cleanUp } =
registerHelpers(getService);

describe('index patterns extension', () => {
// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/184081
describe.skip('Fields for wildcards', () => {
// From 8.15, Es only allows creating a new rollup job when there is existing rollup usage in the cluster
// We will simulate rollup usage by creating a mock-up rollup index
before(async () => {
await createMockRollupIndex();
});

after(() => cleanUp());

describe('Fields for wildcards', () => {
describe('query params validation', () => {
let uri;
let body;
Expand Down Expand Up @@ -57,15 +65,14 @@ export default function ({ getService }) {

it('should return the correct fields', async () => {
// Create a Rollup job on an index with the INDEX_TO_ROLLUP_MAPPINGS
const indexName = await createIndexWithMappings();
const indexName = await createIndexWithMappings(undefined, INDEX_TO_ROLLUP_MAPPINGS);
const rollupIndex = getRandomString();
const payload = getJobPayload(indexName, undefined, rollupIndex);
await createJob(payload);

// Query for wildcard
const params = {
pattern: indexName,
type: DataViewType.ROLLUP,
rollup_index: rollupIndex,
};
const uri = `${BASE_URI}?${stringify(params, { sort: false })}`;
Expand All @@ -75,12 +82,12 @@ export default function ({ getService }) {
.expect(200);

// Verify that the fields for wildcard correspond to our declared mappings
// noting that testTotalField and testTagField are not shown in the field caps results
const fieldsForWildcard = body.fields.map((field) => field.name);
expect(fieldsForWildcard.sort()).eql(['testCreatedField']);

// Cleanup
await cleanUp();
expect(fieldsForWildcard.sort()).eql([
'testCreatedField',
'testTagField',
'testTotalField',
]);
});
});
});
Expand Down
Loading

0 comments on commit c23a622

Please sign in to comment.