Skip to content

Commit

Permalink
[Serverless][Observability] Use role-based testing - functional (#184823
Browse files Browse the repository at this point in the history
)

part of: [#184033](#184033)

## Summary

This PR changes the observability serverless tests to not run with
operator privileges.


### How to test

- Follow the steps from
https://github.com/elastic/kibana/blob/main/x-pack/test_serverless/README.md#run-tests-on-mki

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
crespocarlos and kibanamachine authored Jun 7, 2024
1 parent f87eccf commit c7d6823
Show file tree
Hide file tree
Showing 26 changed files with 101 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

describe('Observability advanced settings', function () {
before(async () => {
await pageObjects.svlCommonPage.login();
await pageObjects.svlCommonPage.loginWithRole('admin');
await pageObjects.common.navigateToApp('settings');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
describe('Cases persistable attachments', function () {
describe('lens visualization', () => {
before(async () => {
await svlCommonPage.login();
await svlCommonPage.loginWithRole('admin');
await kibanaServer.savedObjects.cleanStandardList();
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional');
await kibanaServer.importExport.load(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {

describe('Configure Case', function () {
before(async () => {
await svlCommonPage.login();
await svlCommonPage.loginWithRole('admin');
await svlObltNavigation.navigateToLandingPage();
await svlCommonNavigation.sidenav.clickLink({ deepLinkId: 'observability-overview:cases' });
await header.waitUntilLoadingHasFinished();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default ({ getService, getPageObject }: FtrProviderContext) => {
const header = getPageObject('header');

before(async () => {
await svlCommonPage.login();
await svlCommonPage.loginWithRole('admin');
});

beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {

describe('Cases list', function () {
before(async () => {
await svlCommonPage.login();
await svlCommonPage.loginWithRole('admin');
await svlObltNavigation.navigateToLandingPage();
await svlCommonNavigation.sidenav.clickLink({ deepLinkId: 'observability-overview:cases' });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {

describe('Case View', function () {
before(async () => {
await svlCommonPage.login();
await svlCommonPage.loginWithRole('admin');
});

after(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
describe('Header menu', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs');
await pageObjects.svlCommonPage.login();
await pageObjects.svlCommonPage.loginWithRole('viewer');
});

after(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await Promise.all([
esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'),
]);
await pageObjects.svlCommonPage.login();
await pageObjects.svlCommonPage.loginWithRole('viewer');
await browser.setWindowSize(1600, 1200);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

describe('Infra pages', function () {
before(async () => {
await pageObjects.svlCommonPage.login();
await pageObjects.svlCommonPage.loginWithRole('viewer');
});

after(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

describe('Infra Side Navigation', () => {
before(async () => {
await pageObjects.svlCommonPage.login();
await pageObjects.svlCommonPage.loginWithRole('viewer');
await svlObltNavigation.navigateToLandingPage();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs');

await pageObjects.svlCommonPage.login();
await pageObjects.svlCommonPage.loginWithRole('viewer');
await pageObjects.common.navigateToApp(
`metrics/${NODE_DETAILS_PATH}/demo-stack-kubernetes-01`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
// Error: Failed to delete all indices with pattern [.ml-*]
this.tags(['failsOnMKI']);
before(async () => {
await PageObjects.svlCommonPage.login();
await PageObjects.svlCommonPage.loginWithRole('admin');

// Load logstash* data and create dataview for logstash*, logstash-2015.09.22
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/logstash_functional');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,80 +10,90 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['header', 'svlCommonPage', 'svlCommonNavigation']);

const allLabels = [
{ label: 'Machine Learning', expected: true },
{ label: 'Machine Learning / Overview', expected: true },
{ label: 'Machine Learning / Anomaly Detection', expected: true },
{ label: 'Machine Learning / Anomaly Detection / Anomaly explorer', expected: true },
{ label: 'Machine Learning / Anomaly Detection / Single metric viewer', expected: true },
{ label: 'Machine Learning / Data Frame Analytics', expected: false },
{ label: 'Machine Learning / Data Frame Analytics / Results explorer', expected: false },
{ label: 'Machine Learning / Data Frame Analytics / Analytics map', expected: false },
{ label: 'Machine Learning / Model Management', expected: true },
{ label: 'Machine Learning / Model Management / Trained Models', expected: true },
{ label: 'Machine Learning / Model Management / Nodes', expected: false },
{ label: 'Machine Learning / Memory Usage', expected: true },
{ label: 'Machine Learning / Settings', expected: true },
{ label: 'Machine Learning / Settings / Calendars', expected: true },
{ label: 'Machine Learning / Settings / Filter Lists', expected: true },
{ label: 'Machine Learning / AIOps', expected: true },
{ label: 'Machine Learning / AIOps / Log Rate Analysis', expected: true },
{ label: 'Machine Learning / AIOps / Log Pattern Analysis', expected: true },
{ label: 'Machine Learning / AIOps / Change Point Detection', expected: true },
{ label: 'Machine Learning / Notifications', expected: true },
{ label: 'Machine Learning / Data Visualizer', expected: true },
{ label: 'Machine Learning / File Upload', expected: true },
{ label: 'Machine Learning / Index Data Visualizer', expected: true },
{ label: 'Machine Learning / ES|QL Data Visualizer', expected: true },
{ label: 'Machine Learning / Data Drift', expected: true },
{ label: 'Alerts and Insights / Machine Learning', expected: true },
];
const allLabels = {
viewer: [
{ label: 'Machine Learning', expected: true },
{ label: 'Machine Learning / Overview', expected: true },
{ label: 'Machine Learning / Anomaly Detection', expected: true },
{ label: 'Machine Learning / Anomaly Detection / Anomaly explorer', expected: true },
{ label: 'Machine Learning / Anomaly Detection / Single metric viewer', expected: true },
{ label: 'Machine Learning / Data Frame Analytics', expected: false },
{ label: 'Machine Learning / Data Frame Analytics / Results explorer', expected: false },
{ label: 'Machine Learning / Data Frame Analytics / Analytics map', expected: false },
{ label: 'Machine Learning / Model Management', expected: true },
{ label: 'Machine Learning / Model Management / Trained Models', expected: true },
{ label: 'Machine Learning / Model Management / Nodes', expected: false },
{ label: 'Machine Learning / Memory Usage', expected: true },
{ label: 'Machine Learning / Settings', expected: true },
{ label: 'Machine Learning / Settings / Calendars', expected: true },
{ label: 'Machine Learning / Settings / Filter Lists', expected: true },
{ label: 'Machine Learning / AIOps', expected: true },
{ label: 'Machine Learning / AIOps / Log Rate Analysis', expected: true },
{ label: 'Machine Learning / AIOps / Log Pattern Analysis', expected: true },
{ label: 'Machine Learning / AIOps / Change Point Detection', expected: true },
{ label: 'Machine Learning / Notifications', expected: true },
{ label: 'Machine Learning / Data Visualizer', expected: true },
{ label: 'Machine Learning / File Upload', expected: true },
{ label: 'Machine Learning / Index Data Visualizer', expected: true },
{ label: 'Machine Learning / ES|QL Data Visualizer', expected: true },
{ label: 'Machine Learning / Data Drift', expected: true },
],
admin: [{ label: 'Alerts and Insights / Machine Learning', expected: true }],
};

describe('Search bar features', () => {
before(async () => {
await PageObjects.svlCommonPage.login();
});
([{ role: 'viewer' }, { role: 'admin' }] as Array<{ role: keyof typeof allLabels }>).forEach(
({ role }) => {
describe(`user role: ${role}`, () => {
before(async () => {
await PageObjects.svlCommonPage.loginWithRole(role);
});

after(async () => {
await PageObjects.svlCommonPage.forceLogout();
});
after(async () => {
await PageObjects.svlCommonPage.forceLogout();
});

describe('list features', () => {
it('has the correct features enabled', async () => {
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.svlCommonNavigation.search.showSearch();
describe('list features', () => {
it('has the correct features enabled', async () => {
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.svlCommonNavigation.search.showSearch();

const expectedLabels = allLabels.filter((l) => l.expected).map((l) => l.label);
const expectedLabels = allLabels[role].filter((l) => l.expected).map((l) => l.label);

for (const expectedLabel of expectedLabels) {
await PageObjects.svlCommonNavigation.search.searchFor(expectedLabel);
const [result] = await PageObjects.svlCommonNavigation.search.getDisplayedResults();
const label = result?.label;
expect(label).to.eql(
expectedLabel,
`First result should be ${expectedLabel} (got matching items '${label}')`
);
}
await PageObjects.svlCommonNavigation.search.hideSearch();
});
for (const expectedLabel of expectedLabels) {
await PageObjects.svlCommonNavigation.search.searchFor(expectedLabel);
const [result] = await PageObjects.svlCommonNavigation.search.getDisplayedResults();
const label = result?.label;
expect(label).to.eql(
expectedLabel,
`First result should be ${expectedLabel} (got matching items '${label}')`
);
}
await PageObjects.svlCommonNavigation.search.hideSearch();
});

it('has the correct features disabled', async () => {
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.svlCommonNavigation.search.showSearch();
it('has the correct features disabled', async () => {
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.svlCommonNavigation.search.showSearch();

const notExpectedLabels = allLabels.filter((l) => !l.expected).map((l) => l.label);
const notExpectedLabels = allLabels[role]
.filter((l) => !l.expected)
.map((l) => l.label);

for (const notExpectedLabel of notExpectedLabels) {
await PageObjects.svlCommonNavigation.search.searchFor(notExpectedLabel);
const [result] = await PageObjects.svlCommonNavigation.search.getDisplayedResults();
const label = result?.label;
expect(label).to.not.eql(
notExpectedLabel,
`First result should not be ${notExpectedLabel} (got matching items '${label}')`
);
}
await PageObjects.svlCommonNavigation.search.hideSearch();
});
});
for (const notExpectedLabel of notExpectedLabels) {
await PageObjects.svlCommonNavigation.search.searchFor(notExpectedLabel);
const [result] = await PageObjects.svlCommonNavigation.search.getDisplayedResults();
const label = result?.label;
expect(label).to.not.eql(
notExpectedLabel,
`First result should not be ${notExpectedLabel} (got matching items '${label}')`
);
}
await PageObjects.svlCommonNavigation.search.hideSearch();
});
});
});
}
);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('When the logs explorer loads', () => {
before(async () => {
await synthtrace.index(generateLogsData({ to }));
await PageObjects.svlCommonPage.login();
await PageObjects.svlCommonPage.loginWithRole('viewer');
await navigateToLogsExplorer();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('When the logs explorer loads', () => {
before(async () => {
await synthtrace.index(generateLogsData({ to }));
await PageObjects.svlCommonPage.login();
await PageObjects.svlCommonPage.loginWithRole('viewer');
await navigateToLogsExplorer();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('dataSourceSelection initialization and update', () => {
before(async () => {
await PageObjects.svlCommonPage.login();
await PageObjects.svlCommonPage.loginWithRole('viewer');
});

after(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
// TimeoutError: Waiting for element to be located By(css selector, [data-test-subj="dataSourceSelectorPopoverButton"])
this.tags(['failsOnMKI']);
before(async () => {
await PageObjects.svlCommonPage.login();
await PageObjects.svlCommonPage.loginWithRole('viewer');
await PageObjects.observabilityLogsExplorer.removeInstalledPackages();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('When virtual columns loads', () => {
before(async () => {
await synthtrace.index(generateLogsData({ from, to }));
await PageObjects.svlCommonPage.login();
await PageObjects.svlCommonPage.loginWithRole('viewer');
await navigateToLogsExplorer();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
describe('Filter controls customization', () => {
before('initialize tests', async () => {
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
await PageObjects.svlCommonPage.login();
await PageObjects.svlCommonPage.loginWithRole('viewer');
});

after('clean up archives', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
NAMESPACE
);
await PageObjects.observabilityLogsExplorer.ingestLogEntries(DATA_STREAM_NAME, docs);
await PageObjects.svlCommonPage.login();
await PageObjects.svlCommonPage.loginWithRole('viewer');
});

beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'x-pack/test/functional/es_archives/observability_logs_explorer/data_streams'
);
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');
await PageObjects.svlCommonPage.login();
await PageObjects.svlCommonPage.loginWithRole('viewer');
await PageObjects.observabilityLogsExplorer.navigateTo();
await PageObjects.header.waitUntilLoadingHasFinished();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
before(async () => {
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover');
await synthtrace.index(generateLogsData({ to }));
await PageObjects.svlCommonPage.login();
await PageObjects.svlCommonPage.loginWithRole('viewer');
await navigateToLogsExplorer();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => {
before(async () => {
roleAuthc = await svlUserManager.createApiKeyForRole('admin');
internalReqHeader = svlCommonApi.getInternalRequestHeader();
await svlCommonPage.login();
await svlCommonPage.loginWithRole('admin');
await svlObltNavigation.navigateToLandingPage();
await svlCommonNavigation.sidenav.clickLink({ text: 'Alerts' });
await testSubjects.click('manageRulesPageButton');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function ({ getPageObject, getPageObjects, getService }: FtrProvi
});

beforeEach(async () => {
await pageObjects.svlCommonPage.login();
await pageObjects.svlCommonPage.loginWithRole('admin');
});

it('cases list screenshot', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {

describe('server log connector', function () {
beforeEach(async () => {
await pageObjects.svlCommonPage.login();
await pageObjects.svlCommonPage.loginWithRole('admin');
});

after(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

describe('create window', function () {
beforeEach(async () => {
await pageObjects.svlCommonPage.login();
await pageObjects.svlCommonPage.loginWithRole('admin');
});

after(async () => {
Expand Down

0 comments on commit c7d6823

Please sign in to comment.