Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rollups] Fix functional tests #186103

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions x-pack/test/functional/apps/rollup_job/hybrid_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import datemath from '@kbn/datemath';
import expect from '@kbn/expect';
import mockRolledUpData, { mockIndices } from './hybrid_index_helper';
import { MOCK_ROLLUP_INDEX_NAME, createMockRollupIndex } from './test_helpers';

export default function ({ getService, getPageObjects }) {
const es = getService('es');
Expand All @@ -17,9 +18,7 @@ export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['common', 'settings']);
const esDeleteAllIndices = getService('esDeleteAllIndices');

// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/183975
// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/183976
describe.skip('hybrid index pattern', function () {
describe('hybrid index pattern', function () {
//Since rollups can only be created once with the same name (even if you delete it),
//we add the Date.now() to avoid name collision if you run the tests locally back to back.
const rollupJobName = `hybrid-index-pattern-test-rollup-job-${Date.now()}`;
Expand All @@ -43,6 +42,10 @@ export default function ({ getService, getPageObjects }) {
await kibanaServer.uiSettings.replace({
defaultIndex: 'rollup',
});

// 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
await createMockRollupIndex(es);
});

it('create hybrid index pattern', async () => {
Expand Down Expand Up @@ -107,7 +110,7 @@ export default function ({ getService, getPageObjects }) {
// ensure all fields are available
await PageObjects.settings.clickIndexPatternByName(rollupIndexPatternName);
const fields = await PageObjects.settings.getFieldNames();
expect(fields).to.eql(['@timestamp', '_id', '_index', '_score', '_source']);
expect(fields).to.eql(['@timestamp', '_id', '_ignored', '_index', '_score', '_source']);
});

after(async () => {
Expand All @@ -118,6 +121,7 @@ export default function ({ getService, getPageObjects }) {
rollupTargetIndexName,
`${regularIndexPrefix}*`,
`${rollupSourceIndexPrefix}*`,
MOCK_ROLLUP_INDEX_NAME,
]);
await kibanaServer.savedObjects.cleanStandardList();
});
Expand Down
15 changes: 7 additions & 8 deletions x-pack/test/functional/apps/rollup_job/rollup_jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import datemath from '@kbn/datemath';
import expect from '@kbn/expect';
import { mockIndices } from './hybrid_index_helper';
// import { FtrProviderContext } from '../../ftr_provider_context';
import { MOCK_ROLLUP_INDEX_NAME, createMockRollupIndex } from './test_helpers';

export default function ({ getService, getPageObjects }) {
const config = getService('config');
Expand All @@ -23,12 +23,7 @@ export default function ({ getService, getPageObjects }) {
remoteEs = getService('remoteEs');
}

// FLAKY: https://github.com/elastic/kibana/issues/183925
// FLAKY: https://github.com/elastic/kibana/issues/183926
// FLAKY: https://github.com/elastic/kibana/issues/183927
// FLAKY: https://github.com/elastic/kibana/issues/183928
// FLAKY: https://github.com/elastic/kibana/issues/104569
describe.skip('rollup job', function () {
describe('rollup job', function () {
// Since rollups can only be created once with the same name (even if you delete it),
// we add the Date.now() to avoid name collision.
const rollupJobName = 'rollup-to-be-' + Date.now();
Expand All @@ -52,6 +47,10 @@ export default function ({ getService, getPageObjects }) {
// await security.testUser.setRoles(['manage_rollups_role', 'global_ccr_role']);
await security.testUser.setRoles(['superuser']);
await PageObjects.common.navigateToApp('rollupJob');

// 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
await createMockRollupIndex(es);
});

it('create new rollup job', async () => {
Expand Down Expand Up @@ -88,7 +87,7 @@ export default function ({ getService, getPageObjects }) {
});

// Delete all data indices that were created.
await esDeleteAllIndices([targetIndexName], false);
await esDeleteAllIndices([targetIndexName, MOCK_ROLLUP_INDEX_NAME], false);
if (isRunningCcs) {
await esDeleteAllIndices([indexPatternToUse], true);
} else {
Expand Down
45 changes: 45 additions & 0 deletions x-pack/test/functional/apps/rollup_job/test_helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import Client from '@elastic/elasticsearch/lib/client';

export const MOCK_ROLLUP_INDEX_NAME = 'mock-rollup-index';

export const createMockRollupIndex = async (es: Client) => {
await es.indices.create({
index: MOCK_ROLLUP_INDEX_NAME,
mappings: {
_meta: {
_rollup: {
logs_job: {
id: 'mockRollupJob',
index_pattern: MOCK_ROLLUP_INDEX_NAME,
rollup_index: 'rollup_index',
cron: '0 0 0 ? * 7',
page_size: 1000,
groups: {
date_histogram: {
interval: '24h',
delay: '1d',
time_zone: 'UTC',
field: 'testCreatedField',
},
terms: {
fields: ['testTotalField', 'testTagField'],
},
histogram: {
interval: '7',
fields: ['testTotalField'],
},
},
},
},
'rollup-version': '',
},
},
});
};
15 changes: 11 additions & 4 deletions x-pack/test/functional/apps/rollup_job/tsvb.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import expect from '@kbn/expect';
import mockRolledUpData from './hybrid_index_helper';
import { MOCK_ROLLUP_INDEX_NAME, createMockRollupIndex } from './test_helpers';

export default function ({ getService, getPageObjects }) {
const es = getService('es');
Expand All @@ -24,9 +25,7 @@ export default function ({ getService, getPageObjects }) {
const fromTime = 'Oct 15, 2019 @ 00:00:01.000';
const toTime = 'Oct 15, 2019 @ 19:31:44.000';

// FLAKY: https://github.com/elastic/kibana/issues/56816
// FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/168267
describe.skip('tsvb integration', function () {
describe('tsvb integration', function () {
//Since rollups can only be created once with the same name (even if you delete it),
//we add the Date.now() to avoid name collision if you run the tests locally back to back.
const rollupJobName = `tsvb-test-rollup-job-${Date.now()}`;
Expand All @@ -49,6 +48,10 @@ export default function ({ getService, getPageObjects }) {
'metrics:allowStringIndices': true,
'timepicker:timeDefaults': `{ "from": "${fromTime}", "to": "${toTime}"}`,
});

// 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
await createMockRollupIndex(es);
});

it('create rollup tsvb', async () => {
Expand Down Expand Up @@ -108,7 +111,11 @@ export default function ({ getService, getPageObjects }) {
method: 'DELETE',
});

await esDeleteAllIndices([rollupTargetIndexName, rollupSourceIndexName]);
await esDeleteAllIndices([
rollupTargetIndexName,
rollupSourceIndexName,
MOCK_ROLLUP_INDEX_NAME,
]);
await kibanaServer.importExport.unload(
'x-pack/test/functional/fixtures/kbn_archiver/rollup/rollup.json'
);
Expand Down