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

[APM] Fix broken e2e tests #129475

Merged
merged 29 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d254c06
Fix e2e tests
gbamparop Apr 5, 2022
1821899
Add expectation for the infrastructure tab
gbamparop Apr 5, 2022
6fc2c9f
Add option to run APM cypress tests in the flaky test runner
gbamparop Apr 5, 2022
0c64e2b
Fix time comparison tests
gbamparop Apr 5, 2022
fe4bde6
Get opbeans-rum text to navigate to service overview
gbamparop Apr 5, 2022
fe56bfe
Fix time comparison tests
gbamparop Apr 6, 2022
62a841a
Fix service inventory tests
gbamparop Apr 6, 2022
89cbc62
Remove apisToIntercept from home spec
gbamparop Apr 6, 2022
5996469
Add another exception to uncaught:exception skip list
gbamparop Apr 6, 2022
5608bf4
Add requestTimeout of 10s when waiting for API calls in service inven…
gbamparop Apr 6, 2022
cf5b9de
Add 3s wait before clicking opbeans-rum
gbamparop Apr 6, 2022
ce1e888
Move check for opbeans-java after waiting for the APIs
gbamparop Apr 6, 2022
db4c363
Add 2 retries when cypress is in run mode
gbamparop Apr 6, 2022
a4a280d
Swallow uncaught exceptions from cypress tests
gbamparop Apr 7, 2022
761dc8e
Increase request timeout to 30s
gbamparop Apr 7, 2022
714435a
Revert infrastructureView advanced setting to default setting after r…
gbamparop Apr 7, 2022
7147d07
Use realClick on home spec
gbamparop Apr 7, 2022
c357e4a
fixing service overview test
cauemarcondes Apr 7, 2022
b3bfe0a
Remove cypress-pipe
gbamparop Apr 11, 2022
4bb24eb
Enable cypress retries
gbamparop Apr 11, 2022
12cbeae
Skip service inventory API call tests
gbamparop Apr 11, 2022
9bd1f3a
Force click the link in home spec
gbamparop Apr 11, 2022
cbd4d32
Merge branch 'main' into apm-fix-flaky-tests
kibanamachine Apr 11, 2022
87c5ecc
Remove cypress retries
gbamparop Apr 11, 2022
10280e9
Skip home and time comparison tests
gbamparop Apr 11, 2022
29bb6f7
fixing headers filters
cauemarcondes Apr 11, 2022
0245846
Merge branch 'apm-fix-flaky-tests' of github.com:gbamparop/kibana int…
cauemarcondes Apr 11, 2022
7127d67
Merge branch 'main' into apm-fix-flaky-tests
kibanamachine Apr 12, 2022
17e1265
Merge branch 'main' into apm-fix-flaky-tests
kibanamachine Apr 14, 2022
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
4 changes: 4 additions & 0 deletions .buildkite/pipelines/flaky_tests/groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"key": "xpack/cypress/fleet_cypress",
"name": "Fleet - Cypress"
},
{
"key": "xpack/cypress/apm_cypress",
gbamparop marked this conversation as resolved.
Show resolved Hide resolved
"name": "APM - Cypress"
},
{
"key": "xpack/cigroup",
"name": "Default CI Group",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ describe('Infrastracture feature flag', () => {
cy.loginAsPowerUser();
});

describe('when infrastracture feature is enabled', () => {
it('shows the flag as enabled in kibana advanced settings', () => {
describe('when infrastracture feature is disabled', () => {
it('shows the flag as disabled in kibana advanced settings', () => {
cy.visit(settingsPath);

cy.get(infraToggle)
Expand All @@ -50,8 +50,16 @@ describe('Infrastracture feature flag', () => {
});
});

describe('when infrastracture feature is disabled', () => {
it('shows the flag as disabled in kibana advanced settings', () => {
describe('when infrastracture feature is enabled', () => {
after(() => {
// Reverts to default state, which is infrastructureView disabled
cy.visit(settingsPath);
cy.get(infraToggle).click();
cy.contains('Save changes').should('not.be.disabled');
cy.contains('Save changes').click();
});

it('shows the flag as enabled in kibana advanced settings', () => {
cy.visit(settingsPath);
cy.get(infraToggle).click();
cy.contains('Save changes').should('not.be.disabled');
Expand All @@ -65,6 +73,7 @@ describe('Infrastracture feature flag', () => {
it('shows infrastructure tab in service overview page', () => {
cy.visit(serviceOverviewPath);
cy.contains('a[role="tab"]', 'Infrastructure').click();
cy.contains('Infrastructure data coming soon');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

An expectation was added to be more explicit

});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,15 @@ const end = '2021-10-10T00:15:00.000Z';

const serviceInventoryHref = url.format({
pathname: '/app/apm/services',
query: { rangeFrom: start, rangeTo: end },
});

const apisToIntercept = [
{
endpoint: '/internal/apm/service?*',
name: 'servicesMainStatistics',
},
{
endpoint: '/internal/apm/services/detailed_statistics?*',
name: 'servicesDetailedStatistics',
query: {
comparisonEnabled: 'true',
environment: 'ENVIRONMENT_ALL',
rangeFrom: start,
rangeTo: end,
offset: '1d',
},
];
});

// flaky test
describe.skip('Home page', () => {
Copy link
Member

Choose a reason for hiding this comment

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

should we unskip this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is still flaky

before(async () => {
await synthtrace.index(
Expand All @@ -47,12 +41,12 @@ describe.skip('Home page', () => {
cy.loginAsReadOnlyUser();
});

it('Redirects to service page with environment, rangeFrom and rangeTo added to the URL', () => {
it('Redirects to service page with comparisonEnabled, environment, rangeFrom, rangeTo and offset added to the URL', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

More redirects have been added by #127812

cy.visit('/app/apm');

cy.url().should(
'include',
'app/apm/services?environment=ENVIRONMENT_ALL&rangeFrom=now-15m&rangeTo=now'
'app/apm/services?comparisonEnabled=true&environment=ENVIRONMENT_ALL&rangeFrom=now-15m&rangeTo=now&offset=1d'
);
});

Expand All @@ -66,17 +60,11 @@ describe.skip('Home page', () => {

describe('navigations', () => {
it('navigates to service overview page with transaction type', () => {
apisToIntercept.map(({ endpoint, name }) => {
cy.intercept('GET', endpoint).as(name);
});

cy.visit(serviceInventoryHref);

cy.contains('Services');
cy.contains('opbeans-rum').click({ force: true });

cy.get('[data-test-subj="serviceLink_rum-js"]').then((element) => {
element[0].click();
});
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'page-load'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const aliasNames = apiRequestsToIntercept.map(

describe('When navigating to the service inventory', () => {
before(async () => {
cy.loginAsReadOnlyUser();
cy.visit(serviceInventoryHref);
gbamparop marked this conversation as resolved.
Show resolved Hide resolved

const { rangeFrom, rangeTo } = timeRange;
await synthtrace.index(
opbeans({
Expand All @@ -50,11 +53,6 @@ describe('When navigating to the service inventory', () => {
await synthtrace.clean();
});

beforeEach(() => {
cy.loginAsReadOnlyUser();
cy.visit(serviceInventoryHref);
});

it('has no detectable a11y violations on load', () => {
cy.contains('h1', 'Services');
// set skipFailures to true to not fail the test when there are accessibility failures
Expand All @@ -77,11 +75,14 @@ describe('When navigating to the service inventory', () => {
cy.contains('h1', 'opbeans-node');
});

describe('Calls APIs', () => {
describe.skip('Calls APIs', () => {
Copy link
Member

Choose a reason for hiding this comment

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

can you leave a comment here to explain why it's skipped (and maybe reference an issue)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, it was failing while waiting for the API calls to finish

beforeEach(() => {
apiRequestsToIntercept.map(({ endpoint, aliasName }) => {
cy.intercept('GET', endpoint).as(aliasName);
});

cy.loginAsReadOnlyUser();
cy.visit(serviceInventoryHref);
});

it('with the correct environment when changing the environment', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ describe('Service overview - header filters', () => {
await synthtrace.clean();
});

beforeEach(() => {
cy.loginAsReadOnlyUser();
});

describe('Filtering by transaction type', () => {
beforeEach(() => {
Copy link
Member

Choose a reason for hiding this comment

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

what's the purpose of moving this into both child test suites? was this supposed to be a before()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@dgieselaar I noticed that once in a while a test fails because cypress logs kibana out, so to avoid such a thing I decided to move the login function to inside each describe.

cy.loginAsReadOnlyUser();
});
it('changes url when selecting different value', () => {
cy.visit(serviceOverviewHref);
cy.contains('opbeans-node');
Expand All @@ -95,7 +94,6 @@ describe('Service overview - header filters', () => {
cy.intercept('GET', endpoint).as(name);
});
cy.visit(serviceOverviewHref);
cy.contains('opbeans-node');
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'request'
Expand All @@ -120,6 +118,9 @@ describe('Service overview - header filters', () => {
});

describe('Filtering by kuerybar', () => {
beforeEach(() => {
cy.loginAsReadOnlyUser();
});
it('filters by transaction.name', () => {
cy.visit(
url.format({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ const aliasNamesWithComparison = apiRequestsToInterceptWithComparison.map(

const aliasNames = [...aliasNamesNoComparison, ...aliasNamesWithComparison];

// flaky test
describe.skip('Service Overview', () => {
describe('Service Overview', () => {
before(async () => {
await synthtrace.index(
opbeans({
Expand Down Expand Up @@ -127,6 +126,12 @@ describe.skip('Service Overview', () => {
});

it('persists transaction type selected when clicking on Transactions tab', () => {
cy.intercept(
'GET',
'/internal/apm/services/opbeans-node/transaction_types?*'
).as('transactionTypesRequest');
cy.wait('@transactionTypesRequest');

cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'request'
Expand All @@ -144,6 +149,11 @@ describe.skip('Service Overview', () => {
});

it('persists transaction type selected when clicking on View Transactions link', () => {
cy.intercept(
'GET',
'/internal/apm/services/opbeans-node/transaction_types?*'
).as('transactionTypesRequest');
cy.wait('@transactionTypesRequest');
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'request'
Expand Down Expand Up @@ -238,14 +248,11 @@ describe.skip('Service Overview', () => {
});

it('when selecting a different comparison window', () => {
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', 'day');
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', '1d');
gbamparop marked this conversation as resolved.
Show resolved Hide resolved

// selects another comparison type
cy.get('[data-test-subj="comparisonSelect"]').select('week');
cy.get('[data-test-subj="comparisonSelect"]').should(
'have.value',
'week'
);
cy.get('[data-test-subj="comparisonSelect"]').select('1w');
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', '1w');
cy.expectAPIsToHaveBeenCalledWith({
apisIntercepted: aliasNamesWithComparison,
value: 'offset',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const apisToIntercept = [
},
];

// Skipping tests since it's flaky.
describe.skip('Service overview: Time Comparison', () => {
before(async () => {
await synthtrace.index(
Expand All @@ -71,7 +70,8 @@ describe.skip('Service overview: Time Comparison', () => {

it('enables by default the time comparison feature with Last 24 hours selected', () => {
cy.visit(serviceOverviewPath);
cy.url().should('include', 'comparisonEnabled=true&offset=1d');
cy.url().should('include', 'comparisonEnabled=true');
cy.url().should('include', 'offset=1d');
});

describe('when comparison is toggled off', () => {
Expand All @@ -92,7 +92,6 @@ describe.skip('Service overview: Time Comparison', () => {
cy.intercept('GET', endpoint).as(name);
});
cy.visit(serviceOverviewHref);
cy.contains('opbeans-java');

cy.get('[data-test-subj="comparisonSelect"]').should('be.enabled');
const offset = `offset=1d`;
Expand All @@ -106,6 +105,8 @@ describe.skip('Service overview: Time Comparison', () => {
}
);

cy.contains('opbeans-java');

// toggles off comparison
cy.contains('Comparison').click();
cy.get('[data-test-subj="comparisonSelect"]').should('be.disabled');
Expand All @@ -127,32 +128,52 @@ describe.skip('Service overview: Time Comparison', () => {
cy.visit(serviceOverviewPath);
cy.contains('opbeans-java');
// opens the page with "Day before" selected
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', 'day');
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', '1d');

// selects another comparison type
cy.get('[data-test-subj="comparisonSelect"]').select('week');
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', 'week');
cy.get('[data-test-subj="comparisonSelect"]').select('1w');
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', '1w');
});

it('changes comparison type when a new time range is selected', () => {
cy.visit(serviceOverviewPath);
cy.visit(serviceOverviewHref);
cy.contains('opbeans-java');
// Time comparison default value
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', 'day');
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', '1d');
cy.contains('Day before');
cy.contains('Week before');

cy.selectAbsoluteTimeRange(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this to use absolute dates to calculate the period consistently.

'2021-10-10T00:00:00.000Z',
'2021-10-20T00:00:00.000Z'
);

cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();

cy.get('[data-test-subj="comparisonSelect"]').should(
'have.value',
'864000000ms'
);
cy.get('[data-test-subj="comparisonSelect"]').should(
'not.contain.text',
'Day before'
);
cy.get('[data-test-subj="comparisonSelect"]').should(
'not.contain.text',
'Week before'
);

cy.changeTimeRange('Today');
cy.contains('Day before');
cy.contains('Week before');

cy.changeTimeRange('Last 24 hours');
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', 'day');
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', '1d');
cy.contains('Day before');
cy.contains('Week before');

cy.changeTimeRange('Last 7 days');
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', 'week');
cy.get('[data-test-subj="comparisonSelect"]').should('have.value', '1w');
cy.get('[data-test-subj="comparisonSelect"]').should(
'contain.text',
'Week before'
Expand All @@ -162,20 +183,6 @@ describe.skip('Service overview: Time Comparison', () => {
'Day before'
);
cy.contains('Week before');

cy.changeTimeRange('Last 30 days');
cy.get('[data-test-subj="comparisonSelect"]').should(
'have.value',
'period'
);
cy.get('[data-test-subj="comparisonSelect"]').should(
'not.contain.text',
'Day before'
);
cy.get('[data-test-subj="comparisonSelect"]').should(
'not.contain.text',
'Week before'
);
});

it('hovers over throughput chart shows previous and current period', () => {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/apm/ftr_e2e/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ Cypress.Commands.add(
cy.get('[data-test-subj="superDatePickerstartDatePopoverButton"]').click();
cy.get('[data-test-subj="superDatePickerAbsoluteDateInput"]')
.eq(0)
.clear()
.clear({ force: true })
.type(moment(start).format(format), { force: true });
cy.get('[data-test-subj="superDatePickerendDatePopoverButton"]').click();
cy.get('[data-test-subj="superDatePickerAbsoluteDateInput"]')
.eq(1)
.clear()
.clear({ force: true })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This element is not visible and the type below results in invalid date

.type(moment(end).format(format), { force: true });
}
);
Expand Down
6 changes: 1 addition & 5 deletions x-pack/plugins/apm/ftr_e2e/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
*/

Cypress.on('uncaught:exception', (err, runnable) => {
// @see https://stackoverflow.com/a/50387233/434980
// ResizeObserver error can be safely ignored
if (err.message.includes('ResizeObserver loop limit exceeded')) {
return false;
}
return false;
});

import './commands';