[8.8] [Infrastructure UI] Fix hosts view flaky funcional test (#157913) (#158735)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Infrastructure UI] Fix hosts view flaky funcional test
(#157913)](https://github.com/elastic/kibana/pull/157913)

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

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

<!--BACKPORT [{"author":{"name":"Carlos
Crespo","email":"crespocarlos@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-05-31T14:17:08Z","message":"[Infrastructure
UI] Fix hosts view flaky funcional test (#157913)\n\nfixes:
https://github.com/elastic/kibana/issues/157718\r\nfixes:
https://github.com/elastic/kibana/issues/157719\r\nfixes:
https://github.com/elastic/kibana/issues/157720\r\nfixes:
https://github.com/elastic/kibana/issues/157721 \r\nfixes:
https://github.com/elastic/kibana/issues/157733\r\nfixes:
https://github.com/elastic/kibana/issues/157734\r\n\r\n##
Summary\r\n\r\nFixes hosts view flaky
tests\r\n\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2258\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"051ac85c07bd883550236e6ebca763ef64801507","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Metrics
UI","Team:Infra Monitoring
UI","release_note:skip","backport:prev-minor","Feature:ObsHosts","v8.9.0"],"number":157913,"url":"https://github.com/elastic/kibana/pull/157913","mergeCommit":{"message":"[Infrastructure
UI] Fix hosts view flaky funcional test (#157913)\n\nfixes:
https://github.com/elastic/kibana/issues/157718\r\nfixes:
https://github.com/elastic/kibana/issues/157719\r\nfixes:
https://github.com/elastic/kibana/issues/157720\r\nfixes:
https://github.com/elastic/kibana/issues/157721 \r\nfixes:
https://github.com/elastic/kibana/issues/157733\r\nfixes:
https://github.com/elastic/kibana/issues/157734\r\n\r\n##
Summary\r\n\r\nFixes hosts view flaky
tests\r\n\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2258\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"051ac85c07bd883550236e6ebca763ef64801507"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/157913","number":157913,"mergeCommit":{"message":"[Infrastructure
UI] Fix hosts view flaky funcional test (#157913)\n\nfixes:
https://github.com/elastic/kibana/issues/157718\r\nfixes:
https://github.com/elastic/kibana/issues/157719\r\nfixes:
https://github.com/elastic/kibana/issues/157720\r\nfixes:
https://github.com/elastic/kibana/issues/157721 \r\nfixes:
https://github.com/elastic/kibana/issues/157733\r\nfixes:
https://github.com/elastic/kibana/issues/157734\r\n\r\n##
Summary\r\n\r\nFixes hosts view flaky
tests\r\n\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2258\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"051ac85c07bd883550236e6ebca763ef64801507"}}]}]
BACKPORT-->

Co-authored-by: Carlos Crespo <crespocarlos@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2023-05-31 11:25:45 -04:00 committed by GitHub
parent caa8e8e695
commit f7c4269fec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 93 additions and 53 deletions

View file

@ -98,6 +98,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
'infraHostsView',
'security',
'settings',
'header',
]);
// Helpers
@ -105,7 +106,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
kibanaServer.uiSettings.update({ [enableInfrastructureHostsView]: value });
const loginWithReadOnlyUser = async () => {
const roleCreation = security.role.create('global_hosts_read_privileges_role', {
const roleCreation = await security.role.create('global_hosts_read_privileges_role', {
elasticsearch: {
indices: [{ names: ['metricbeat-*'], privileges: ['read', 'view_index_metadata'] }],
},
@ -126,10 +127,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
full_name: 'test user',
});
const logout = pageObjects.security.forceLogout();
await Promise.all([roleCreation, userCreation, logout]);
await Promise.all([roleCreation, userCreation]);
await pageObjects.security.forceLogout();
await pageObjects.security.login(
'global_hosts_read_privileges_user',
'global_hosts_read_privileges_user-password',
@ -146,11 +146,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
security.user.delete('global_hosts_read_privileges_user'),
]);
const enableHostView = () => pageObjects.infraHostsView.clickEnableHostViewButton();
describe('Hosts View', function () {
// Failing: See https://github.com/elastic/kibana/issues/157718
// this.tags('includeFirefox');
this.tags('includeFirefox');
before(async () => {
await Promise.all([
@ -171,6 +168,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
it('should be accessible from the Inventory page', async () => {
await pageObjects.common.navigateToApp('infraOps');
await pageObjects.infraHome.clickDismissKubernetesTourButton();
await pageObjects.infraHostsView.clickTryHostViewBadge();
@ -179,46 +177,62 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
expect(pageUrl).to.contain(HOSTS_VIEW_PATH);
});
// FLAKY: https://github.com/elastic/kibana/issues/157718
describe.skip('#Landing page', () => {
beforeEach(() => {
setHostViewEnabled(false);
describe('#Landing page', () => {
beforeEach(async () => {
await setHostViewEnabled(false);
});
it('as a user with read permission, should show hosts landing page with callout when the hosts view is disabled', async () => {
await loginWithReadOnlyUser();
await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH);
const landingPageDisabled = await pageObjects.infraHostsView.getHostsLandingPageDisabled();
const learnMoreDocsUrl = await pageObjects.infraHostsView.getHostsLandingPageDocsLink();
const parsedUrl = new URL(learnMoreDocsUrl);
expect(parsedUrl.host).to.be('www.elastic.co');
expect(parsedUrl.pathname).to.be('/guide/en/kibana/current/kibana-privileges.html');
expect(landingPageDisabled).to.contain(
'Your user role doesnt have sufficient privileges to enable this feature'
);
await logoutAndDeleteReadOnlyUser();
afterEach(async () => {
await setHostViewEnabled(true);
});
it('as an admin, should see an enable button when the hosts view is disabled', async () => {
await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH);
describe('User with read permission', () => {
beforeEach(async () => {
await loginWithReadOnlyUser();
});
const landingPageEnableButton =
await pageObjects.infraHostsView.getHostsLandingPageEnableButton();
const landingPageEnableButtonText = await landingPageEnableButton.getVisibleText();
expect(landingPageEnableButtonText).to.eql('Enable hosts view');
afterEach(async () => {
await logoutAndDeleteReadOnlyUser();
});
it('Should show hosts landing page with callout when the hosts view is disabled', async () => {
await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH);
await pageObjects.header.waitUntilLoadingHasFinished();
const landingPageDisabled =
await pageObjects.infraHostsView.getHostsLandingPageDisabled();
const learnMoreDocsUrl = await pageObjects.infraHostsView.getHostsLandingPageDocsLink();
const parsedUrl = new URL(learnMoreDocsUrl);
expect(parsedUrl.host).to.be('www.elastic.co');
expect(parsedUrl.pathname).to.be('/guide/en/kibana/current/kibana-privileges.html');
expect(landingPageDisabled).to.contain(
'Your user role doesnt have sufficient privileges to enable this feature'
);
});
});
it('as an admin, should be able to enable the hosts view feature', async () => {
await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH);
await enableHostView();
describe('Admin user', () => {
it('as an admin, should see an enable button when the hosts view is disabled', async () => {
await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH);
await pageObjects.header.waitUntilLoadingHasFinished();
const titleElement = await find.byCssSelector('h1');
const title = await titleElement.getVisibleText();
const landingPageEnableButton =
await pageObjects.infraHostsView.getHostsLandingPageEnableButton();
const landingPageEnableButtonText = await landingPageEnableButton.getVisibleText();
expect(landingPageEnableButtonText).to.eql('Enable hosts view');
});
expect(title).to.contain('Hosts');
it('as an admin, should be able to enable the hosts view feature', async () => {
await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH);
await pageObjects.header.waitUntilLoadingHasFinished();
await pageObjects.infraHostsView.clickEnableHostViewButton();
const titleElement = await find.byCssSelector('h1');
const title = await titleElement.getVisibleText();
expect(title).to.contain('Hosts');
});
});
});
@ -226,27 +240,35 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
// FLAKY: https://github.com/elastic/kibana/issues/157720
describe.skip('#Single host Flyout', () => {
before(async () => {
await setHostViewEnabled(true);
await loginWithReadOnlyUser();
await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH);
await pageObjects.header.waitUntilLoadingHasFinished();
await pageObjects.timePicker.setAbsoluteRange(
START_HOST_PROCESSES_DATE.format(timepickerFormat),
END_HOST_PROCESSES_DATE.format(timepickerFormat)
);
await pageObjects.infraHostsView.clickTableOpenFlyoutButton();
});
after(async () => {
await pageObjects.infraHostsView.clickCloseFlyoutButton();
await logoutAndDeleteReadOnlyUser();
});
beforeEach(async () => {
await pageObjects.infraHostsView.clickTableOpenFlyoutButton();
});
afterEach(async () => {
await retry.try(async () => {
await pageObjects.infraHostsView.clickCloseFlyoutButton();
});
});
it('should render metadata tab, add and remove filter', async () => {
const metadataTab = await pageObjects.infraHostsView.getMetadataTabName();
expect(metadataTab).to.contain('Metadata');
await pageObjects.infraHostsView.clickAddMetadataFilter();
await pageObjects.infraHome.waitForLoading();
await pageObjects.header.waitUntilLoadingHasFinished();
// Add Filter
const addedFilter = await pageObjects.infraHostsView.getAppliedFilter();
@ -256,29 +278,29 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
// Remove filter
await pageObjects.infraHostsView.clickRemoveMetadataFilter();
await pageObjects.infraHome.waitForLoading();
await pageObjects.header.waitUntilLoadingHasFinished();
const removeFilterShouldNotExist = await pageObjects.infraHostsView.getRemoveFilterExist();
expect(removeFilterShouldNotExist).to.be(false);
});
it('should navigate to Uptime after click', async () => {
await pageObjects.infraHostsView.clickFlyoutUptimeLink();
await pageObjects.infraHome.waitForLoading();
await pageObjects.header.waitUntilLoadingHasFinished();
const url = await browser.getCurrentUrl();
expect(url).to.contain(
'app/uptime/?search=host.name%3A%20%22Jennys-MBP.fritz.box%22%20OR%20host.ip%3A%20%22192.168.1.79%22'
);
await browser.goBack();
await pageObjects.infraHome.waitForLoading();
await pageObjects.header.waitUntilLoadingHasFinished();
});
it('should navigate to APM services after click', async () => {
await pageObjects.infraHostsView.clickFlyoutApmServicesLink();
await pageObjects.infraHome.waitForLoading();
await pageObjects.header.waitUntilLoadingHasFinished();
const url = await browser.getCurrentUrl();
expect(url).to.contain('app/apm/services?kuery=host.hostname%3A%22Jennys-MBP.fritz.box%22');
await browser.goBack();
await pageObjects.infraHome.waitForLoading();
await pageObjects.header.waitUntilLoadingHasFinished();
});
describe('should render processes tab', async () => {
@ -323,9 +345,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
// FLAKY: https://github.com/elastic/kibana/issues/157721
describe.skip('#Page Content', () => {
before(async () => {
await setHostViewEnabled(true);
await loginWithReadOnlyUser();
await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH);
await pageObjects.header.waitUntilLoadingHasFinished();
await pageObjects.timePicker.setAbsoluteRange(
START_DATE.format(timepickerFormat),
END_DATE.format(timepickerFormat)
@ -396,6 +418,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.infraHostsView.visitMetricsTab();
});
after(async () => {
await browser.scrollTop();
});
it('should load 8 lens metric charts', async () => {
const metricCharts = await pageObjects.infraHostsView.getAllMetricsCharts();
expect(metricCharts.length).to.equal(8);
@ -412,6 +438,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.infraHostsView.visitLogsTab();
});
after(async () => {
await browser.scrollTop();
});
it('should load the Logs tab section when clicking on it', async () => {
await testSubjects.existOrFail('hostsView-logs');
});
@ -428,6 +458,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.infraHostsView.visitAlertTab();
});
after(async () => {
await browser.scrollTop();
});
it('should correctly load the Alerts tab section when clicking on it', async () => {
testSubjects.existOrFail('hostsView-alerts');
});
@ -496,6 +530,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
after(async () => {
await browser.scrollTop();
await pageObjects.infraHostsView.submitQuery('');
});
@ -560,8 +595,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await browser.scrollTop();
});
after(async () => {
await browser.scrollTop();
});
beforeEach(async () => {
await pageObjects.infraHostsView.changePageSize(5);
await retry.try(async () => {
await pageObjects.infraHostsView.changePageSize(5);
});
});
it('should show 5 rows on the first page', async () => {

View file

@ -65,12 +65,11 @@ export function InfraHostsViewProvider({ getService }: FtrProviderContext) {
},
async getHostsLandingPageEnableButton() {
const container = await testSubjects.find('hostsView-enable-feature-button');
return container;
return testSubjects.find('hostsView-enable-feature-button');
},
async clickEnableHostViewButton() {
return await testSubjects.click('hostsView-enable-feature-button');
return testSubjects.click('hostsView-enable-feature-button');
},
async getHostsTable() {