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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
processors,
productionNamespace,
} from './data';
import { waitUntilDatasetQualityTableOrTimeoutWithFallback } from './helpers';

const integrationActions = {
overview: 'Overview',
Expand All @@ -39,6 +40,7 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
const synthtrace = getService('logSynthtraceEsClient');
const retry = getService('retry');
const browser = getService('browser');
const logger = getService('log');
const to = '2024-01-01T12:00:00.000Z';

const apacheAccessDatasetName = 'apache.access';
Expand Down Expand Up @@ -152,8 +154,10 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
);
});

it('should navigate to details page from a main page', async () => {
await PageObjects.datasetQuality.navigateTo();
it('should navigate to details page from a main page', async function () {
await waitUntilDatasetQualityTableOrTimeoutWithFallback(PageObjects, logger, () =>
this.skip()
);

const synthDataset = await testSubjects.find(
'datasetQualityTableDetailsLink-logs-synth.1-default',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
createDatasetQualityUserWithRole,
deleteDatasetQualityUserWithRole,
} from './roles/role_management';
import { waitUntilDatasetQualityTableOrTimeoutWithFallback } from './helpers';

export default function ({ getService, getPageObjects }: DatasetQualityFtrProviderContext) {
const PageObjects = getPageObjects([
Expand All @@ -34,23 +35,6 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
const regularDataStreamName = `logs-${datasetNames[0]}-${defaultNamespace}`;
const apacheAccessDataStreamName = `logs-${apacheAccessDatasetName}-${defaultNamespace}`;

async function waitUntilDatasetQualityTableOrTimeoutWithFallback(fallback: () => void) {
try {
await PageObjects.datasetQuality.navigateTo();
await PageObjects.datasetQuality.waitUntilTableLoaded();
} catch (error) {
// Skip tests in this describe block if the loading spinner doesn't disappear
// due to slow CI environment conditions
if (error.name === 'TimeoutError' && error.message.includes('euiBasicTable-loading')) {
logger.warning('Skipping tests due to slow CI environment - table loading timeout');

return fallback();
} else {
throw error;
}
}
}

describe('Dataset quality handles user privileges', () => {
before(async () => {
await PageObjects.observabilityLogsExplorer.setupInitialIntegrations();
Expand Down Expand Up @@ -110,7 +94,9 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid

describe('User cannot monitor any data stream', () => {
before(async function () {
await waitUntilDatasetQualityTableOrTimeoutWithFallback(() => this.skip());
await waitUntilDatasetQualityTableOrTimeoutWithFallback(PageObjects, logger, () =>
this.skip()
);
});
after(async () => {
// Cleanup the user and role
Expand All @@ -134,7 +120,9 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
await PageObjects.security.login('fullAccess', 'fullAccess-password', {
expectSpaceSelector: false,
});
await waitUntilDatasetQualityTableOrTimeoutWithFallback(() => this.skip());
await waitUntilDatasetQualityTableOrTimeoutWithFallback(PageObjects, logger, () =>
this.skip()
);
});

after(async () => {
Expand Down Expand Up @@ -166,7 +154,9 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
await PageObjects.security.login('fullAccess', 'fullAccess-password', {
expectSpaceSelector: false,
});
await waitUntilDatasetQualityTableOrTimeoutWithFallback(() => this.skip());
await waitUntilDatasetQualityTableOrTimeoutWithFallback(PageObjects, logger, () =>
this.skip()
);
});

it('types filter should be rendered', async () => {
Expand Down Expand Up @@ -203,7 +193,9 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
// Index logs for synth-* and apache.access datasets
await synthtrace.index(getInitialTestLogs({ to, count: 4 }));

await waitUntilDatasetQualityTableOrTimeoutWithFallback(() => this.skip());
await waitUntilDatasetQualityTableOrTimeoutWithFallback(PageObjects, logger, () =>
this.skip()
);
});

after(async () => {
Expand Down Expand Up @@ -249,7 +241,9 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
});

it('shows underprivileged warning when size cannot be accessed for some data streams', async function () {
await waitUntilDatasetQualityTableOrTimeoutWithFallback(() => this.skip());
await waitUntilDatasetQualityTableOrTimeoutWithFallback(PageObjects, logger, () =>
this.skip()
);

await PageObjects.datasetQuality.refreshTable();

Expand All @@ -269,7 +263,9 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
});

it('Details page shows insufficient privileges warning for underprivileged data stream', async function () {
await waitUntilDatasetQualityTableOrTimeoutWithFallback(() => this.skip());
await waitUntilDatasetQualityTableOrTimeoutWithFallback(PageObjects, logger, () =>
this.skip()
);

await PageObjects.datasetQuality.navigateToDetails({
dataStream: regularDataStreamName,
Expand All @@ -283,7 +279,9 @@ export default function ({ getService, getPageObjects }: DatasetQualityFtrProvid
});

it('"View dashboards" is hidden for underprivileged user', async function () {
await waitUntilDatasetQualityTableOrTimeoutWithFallback(() => this.skip());
await waitUntilDatasetQualityTableOrTimeoutWithFallback(PageObjects, logger, () =>
this.skip()
);

await PageObjects.datasetQuality.navigateToDetails({
dataStream: apacheAccessDataStreamName,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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.
*/

export * from './wait_until_table_loaded';
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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 type { ToolingLog } from '@kbn/tooling-log';

/**
* Helper function to wait for the dataset quality table to load or skip tests if timeout occurs.
* This is useful in CI environments where the table may take longer to load.
*
* @param PageObjects - The page objects containing the datasetQuality page object
* @param logger - The logger service for warnings
* @param fallback - Callback function to execute if timeout occurs (typically `this.skip()`)
*/
export async function waitUntilDatasetQualityTableOrTimeoutWithFallback(
PageObjects: any,
logger: ToolingLog,
fallback: () => void
) {
try {
await PageObjects.datasetQuality.navigateTo();
await PageObjects.datasetQuality.waitUntilTableLoaded();
} catch (error) {
// Skip tests in this describe block if the loading spinner doesn't disappear
// due to slow CI environment conditions
if (error.name === 'TimeoutError' && error.message.includes('euiBasicTable-loading')) {
logger.warning('Skipping tests due to slow CI environment - table loading timeout');

return fallback();
} else {
throw error;
}
}
}