Skip to content

Commit

Permalink
[LogsUI] Clean up indices before running no data test suite (elastic#…
Browse files Browse the repository at this point in the history
…196500)

## 📓 Summary

Closes elastic#196031 

These changes add a preventive indices cleanup before the log rate and
log categories tests where assertions run against expected no-data
pages. This is a preventive measure in case other test suites in the
same configuration are not correctly cleaning the installed data or race
conditions occur.

Co-authored-by: Marco Antonio Ghiani <[email protected]>
  • Loading branch information
tonyghiani and Marco Antonio Ghiani authored Nov 5, 2024
1 parent 13a1de4 commit 47f1b9d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
};

describe('with a trial license', () => {
before(() => logsUi.cleanIndices());

it('Shows no data page when indices do not exist', async () => {
await logsUi.logEntryCategoriesPage.navigateTo();

Expand Down
4 changes: 3 additions & 1 deletion x-pack/test/functional/apps/infra/logs/log_entry_rate_tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { FtrProviderContext } from '../../../ftr_provider_context';

export default ({ getPageObjects, getService }: FtrProviderContext) => {
const PageObjects = getPageObjects(['security']);
const esArchiver = getService('esArchiver');
const logsUi = getService('logsUi');
const retry = getService('retry');
const esArchiver = getService('esArchiver');
const security = getService('security');

describe('Log Entry Rate Tab', function () {
Expand Down Expand Up @@ -58,6 +58,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
};

describe('with a trial license', () => {
before(() => logsUi.cleanIndices());

it('shows no data page when indices do not exist', async () => {
await logsUi.logEntryRatePage.navigateTo();

Expand Down
16 changes: 16 additions & 0 deletions x-pack/test/functional/services/logs_ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,21 @@ export function LogsUiProvider(context: FtrProviderContext) {
logEntryCategoriesPage: LogEntryCategoriesPageProvider(context),
logEntryRatePage: LogEntryRatePageProvider(context),
logStreamPage: LogStreamPageProvider(context),
cleanIndices: createCleanIndicesHandler(context),
};
}

const createCleanIndicesHandler = (context: FtrProviderContext) => async () => {
const es = context.getService('es');
const log = context.getService('log');

log.info('Deleting all the indices');

const indicesResponse = await es.indices.get({ index: '*' });

const indicesDeletionPromises = Object.keys(indicesResponse).map((index) =>
es.indices.delete({ index })
);

return Promise.all(indicesDeletionPromises);
};

0 comments on commit 47f1b9d

Please sign in to comment.