Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Monitoring] Use a basic monitoring user for tests #47865

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

export const getLifecycleMethods = (getService, getPageObjects) => {
const esArchiver = getService('esArchiver');
const PageObjects = getPageObjects(['monitoring', 'timePicker']);
const security = getService('security');
const PageObjects = getPageObjects(['monitoring', 'timePicker', 'security']);
const noData = getService('monitoringNoData');
let _archive;

Expand All @@ -33,7 +34,9 @@ export const getLifecycleMethods = (getService, getPageObjects) => {
await PageObjects.timePicker.setAbsoluteRange(from, to);
},

tearDown() {
async tearDown() {
await PageObjects.security.logout();
await security.user.delete('basic_monitoring_user');
return esArchiver.unload(_archive);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function ({ getService, getPageObjects }) {
before(async () => {
const browser = getService('browser');
await browser.setWindowSize(1600, 1000);
await PageObjects.monitoring.navigateTo();
await PageObjects.monitoring.navigateTo(true);
await noData.isOnNoDataPage();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
const appsMenu = getService('appsMenu');
const PageObjects = getPageObjects(['common', 'security']);

describe('securty', () => {
describe('security', () => {
before(async () => {
await esArchiver.load('empty_kibana');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export default function({ getPageObjects, getService }: FtrProviderContext) {
await esArchiver.load('empty_kibana');
});

after(async () => {
await esArchiver.unload('empty_kibana');
await PageObjects.common.navigateToApp('home');
await PageObjects.security.logout();
});

describe('space with no features disabled', () => {
before(async () => {
await spacesService.create({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/monitoring/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default function ({ loadTestFile }) {
loadTestFile(require.resolve('./cluster/list'));
loadTestFile(require.resolve('./cluster/overview'));
loadTestFile(require.resolve('./cluster/alerts'));
loadTestFile(require.resolve('./enable_monitoring'));
// loadTestFile(require.resolve('./cluster/license'));

loadTestFile(require.resolve('./elasticsearch/overview'));
Expand All @@ -40,5 +39,6 @@ export default function ({ loadTestFile }) {
loadTestFile(require.resolve('./beats/beat_detail'));

loadTestFile(require.resolve('./time_filter'));
loadTestFile(require.resolve('./enable_monitoring'));
});
}
19 changes: 17 additions & 2 deletions x-pack/test/functional/page_objects/monitoring_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,26 @@
*/

export function MonitoringPageProvider({ getPageObjects, getService }) {
const PageObjects = getPageObjects(['common', 'header']);
const PageObjects = getPageObjects(['common', 'header', 'shield', 'spaceSelector']);
const testSubjects = getService('testSubjects');
const security = getService('security');

return new class MonitoringPage {
async navigateTo() {
async navigateTo(useSuperUser = false) {
// always create this because our tear down tries to delete it
await security.user.create('basic_monitoring_user', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the comment:

// always create this because our tear down tries to delete it

Because we are always trying to remove it here: https://github.com/elastic/kibana/pull/47865/files#diff-328ca8d955b871223f4463b5a7ce9721R39

I guess I could try/catch that call and do nothing if it fails? I'm not sure the best way here, but at least this way gets the tests to pass (which was a challenge honestly)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see now, this makes sense

password: 'monitoring_user_password',
roles: ['monitoring_user', 'kibana_user'],
full_name: 'basic monitoring',
});

if (!useSuperUser) {
await PageObjects.common.navigateToApp('login');
await PageObjects.shield.login(
'basic_monitoring_user',
'monitoring_user_password'
);
}
await PageObjects.common.navigateToApp('monitoring');
}

Expand Down