diff --git a/test/common/services/es_delete_all_indices.ts b/test/common/services/es_delete_all_indices.ts index c0ffa44c2e2c3..5f0ecba2cbde8 100644 --- a/test/common/services/es_delete_all_indices.ts +++ b/test/common/services/es_delete_all_indices.ts @@ -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, }); @@ -23,7 +22,8 @@ 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) { @@ -31,7 +31,7 @@ export function EsDeleteAllIndicesProvider({ getService }: FtrProviderContext) { } // resolve pattern to concrete index names - const resp = await es.indices.getAlias( + const resp = await esNode.indices.getAlias( { index: pattern, }, @@ -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); } } }; diff --git a/x-pack/test/functional/apps/rollup_job/index.js b/x-pack/test/functional/apps/rollup_job/index.js index 943536539c5ad..f65396db754cb 100644 --- a/x-pack/test/functional/apps/rollup_job/index.js +++ b/x-pack/test/functional/apps/rollup_job/index.js @@ -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')); + } }); } diff --git a/x-pack/test/functional/apps/rollup_job/rollup_jobs.js b/x-pack/test/functional/apps/rollup_job/rollup_jobs.js index abf01f63c4676..1b2ba0457e02b 100644 --- a/x-pack/test/functional/apps/rollup_job/rollup_jobs.js +++ b/x-pack/test/functional/apps/rollup_job/rollup_jobs.js @@ -8,23 +8,33 @@ 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 }), @@ -32,15 +42,18 @@ export default function ({ getService, getPageObjects }) { datemath.parse('now-3d', { forceNow: now }), ]; before(async () => { - await security.testUser.setRoles(['manage_rollups_role']); + // + // 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( @@ -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', @@ -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(); }); diff --git a/x-pack/test/functional/config.ccs.ts b/x-pack/test/functional/config.ccs.ts index 6ed19292d9411..d04b542cfb965 100644 --- a/x-pack/test/functional/config.ccs.ts +++ b/x-pack/test/functional/config.ccs.ts @@ -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',