[8.5] Added Rollups CCS Test (#144074) (#145787)

# Backport

This will backport the following commits from `main` to `8.5`:
- [Added Rollups CCS Test
(#144074)](https://github.com/elastic/kibana/pull/144074)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"John
Dorlus","email":"jsdorlus@elastic.co"},"sourceCommit":{"committedDate":"2022-10-28T19:20:50Z","message":"Added
Rollups CCS Test (#144074)\n\n* Removed comment of the issue that was
referenced for the skip. But the tests were already skipped.\r\n\r\n*
Unskipping test as a fix has been made. 138510\r\n\r\n* Made CCS test
for rollups and made it conditional based on configuration.\r\n\r\n*
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache
--fix'\r\n\r\n* Fixed issues in build.\r\n\r\n* Added comment to rollups
test and using super user until the perms issue is
fixed.\r\n\r\nCo-authored-by: cuffs
<cuffs@cuffss-Office-MacBook-Pro.local>\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"20ebb175df760246b93d17b71130fd945fe3cf7f","branchLabelMapping":{"^v8.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:QA","test_ui_functional","test_xpack_functional","Team:Deployment
Management","release_note:skip","backport missing","Feature:Functional
Testing","auto-backport","backport:prev-minor"],"number":144074,"url":"https://github.com/elastic/kibana/pull/144074","mergeCommit":{"message":"Added
Rollups CCS Test (#144074)\n\n* Removed comment of the issue that was
referenced for the skip. But the tests were already skipped.\r\n\r\n*
Unskipping test as a fix has been made. 138510\r\n\r\n* Made CCS test
for rollups and made it conditional based on configuration.\r\n\r\n*
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache
--fix'\r\n\r\n* Fixed issues in build.\r\n\r\n* Added comment to rollups
test and using super user until the perms issue is
fixed.\r\n\r\nCo-authored-by: cuffs
<cuffs@cuffss-Office-MacBook-Pro.local>\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"20ebb175df760246b93d17b71130fd945fe3cf7f"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[]}]
BACKPORT-->
This commit is contained in:
John Dorlus 2022-11-19 00:47:46 -05:00 committed by GitHub
parent bbe4643bdd
commit 23151dc465
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 21 deletions

View file

@ -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);
}
}
};

View file

@ -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'));
}
});
}

View file

@ -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']);
// <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(
@ -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();
});

View file

@ -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',