Skip to content
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: 6 additions & 6 deletions test/common/services/es_delete_all_indices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
import { FtrProviderContext } from '../ftr_provider_context';

export function EsDeleteAllIndicesProvider({ getService }: FtrProviderContext) {
const es = getService('es');
const log = getService('log');

async function deleteConcreteIndices(indices: string[]) {
async function deleteConcreteIndices(indices: string[], esNode: any) {
try {
await es.indices.delete({
await esNode.indices.delete({
index: indices,
ignore_unavailable: true,
});
Expand All @@ -23,15 +22,16 @@ export function EsDeleteAllIndicesProvider({ getService }: FtrProviderContext) {
}
}

return async (patterns: string | string[]) => {
return async (patterns: string | string[], remote: boolean = false) => {
const esNode = remote ? getService('remoteEs' as 'es') : getService('es');
for (const pattern of [patterns].flat()) {
for (let attempt = 1; ; attempt++) {
if (attempt > 5) {
throw new Error(`Failed to delete all indices with pattern [${pattern}]`);
}

// resolve pattern to concrete index names
const resp = await es.indices.getAlias(
const resp = await esNode.indices.getAlias(
{
index: pattern,
},
Expand All @@ -55,7 +55,7 @@ export function EsDeleteAllIndicesProvider({ getService }: FtrProviderContext) {
);

// delete the concrete indexes we found and try again until this pattern resolves to no indexes
await deleteConcreteIndices(indices);
await deleteConcreteIndices(indices, esNode);
}
}
};
Expand Down
9 changes: 6 additions & 3 deletions x-pack/test/functional/apps/rollup_job/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
* 2.0.
*/

export default function ({ loadTestFile }) {
export default function ({ loadTestFile, getService }) {
const config = getService('config');
describe('rollup app', function () {
loadTestFile(require.resolve('./rollup_jobs'));
loadTestFile(require.resolve('./hybrid_index_pattern'));
loadTestFile(require.resolve('./tsvb'));
if (!config.get('esTestCluster.ccs')) {
loadTestFile(require.resolve('./hybrid_index_pattern'));
loadTestFile(require.resolve('./tsvb'));
}
});
}
40 changes: 29 additions & 11 deletions x-pack/test/functional/apps/rollup_job/rollup_jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,52 @@
import datemath from '@kbn/datemath';
import expect from '@kbn/expect';
import { mockIndices } from './hybrid_index_helper';
// import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
const es = getService('es');
const config = getService('config');
const PageObjects = getPageObjects(['rollup', 'common', 'security']);
const security = getService('security');
const esDeleteAllIndices = getService('esDeleteAllIndices');
const kibanaServer = getService('kibanaServer');
const es = getService('es');
const isRunningCcs = config.get('esTestCluster.ccs') ? true : false;
let remoteEs;
if (isRunningCcs) {
remoteEs = getService('remoteEs');
}

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.
// 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();
const targetIndexName = 'rollup-to-be';
const rollupSourceIndexPattern = 'to-be*';
const indexPatternToUse = 'to-be*';
const rollupSourceIndexPattern = isRunningCcs
? 'ftr-remote:' + indexPatternToUse
: indexPatternToUse;
const rollupSourceDataPrepend = 'to-be';

//make sure all dates have the same concept of "now"
// make sure all dates have the same concept of "now"
const now = new Date();
const pastDates = [
datemath.parse('now-1d', { forceNow: now }),
datemath.parse('now-2d', { forceNow: now }),
datemath.parse('now-3d', { forceNow: now }),
];
before(async () => {
await security.testUser.setRoles(['manage_rollups_role']);
// <issue for security roles not working as expected>
// https://github.com/elastic/kibana/issues/143720
// await security.testUser.setRoles(['manage_rollups_role', 'global_ccr_role']);
await security.testUser.setRoles(['superuser']);
await PageObjects.common.navigateToApp('rollupJob');
});

it('create new rollup job', async () => {
const interval = '1000ms';

const esNode = isRunningCcs ? remoteEs : es;
for (const day of pastDates) {
await es.index(mockIndices(day, rollupSourceDataPrepend));
await esNode.index(mockIndices(day, rollupSourceDataPrepend));
}

await PageObjects.rollup.createNewRollUpJob(
Expand All @@ -58,7 +71,7 @@ export default function ({ getService, getPageObjects }) {
});

after(async () => {
//Stop the running rollup job.
// Stop the running rollup job.
await es.transport.request({
path: `/_rollup/job/${rollupJobName}/_stop?wait_for_completion=true`,
method: 'POST',
Expand All @@ -69,8 +82,13 @@ export default function ({ getService, getPageObjects }) {
method: 'DELETE',
});

//Delete all data indices that were created.
await esDeleteAllIndices([targetIndexName, rollupSourceIndexPattern]);
// Delete all data indices that were created.
await esDeleteAllIndices([targetIndexName], false);
if (isRunningCcs) {
await esDeleteAllIndices([indexPatternToUse], true);
} else {
await esDeleteAllIndices([indexPatternToUse], false);
}
await kibanaServer.savedObjects.cleanStandardList();
await security.testUser.restoreDefaults();
});
Expand Down
6 changes: 5 additions & 1 deletion x-pack/test/functional/config.ccs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
return {
...functionalConfig.getAll(),

testFiles: [require.resolve('./apps/canvas'), require.resolve('./apps/lens/group1')],
testFiles: [
require.resolve('./apps/canvas'),
require.resolve('./apps/lens/group1'),
require.resolve('./apps/rollup_job'),
],

junit: {
reportName: 'X-Pack CCS Tests',
Expand Down