Skip to content

Commit

Permalink
[Cypress Updates] Trace analytics updates (#2251)
Browse files Browse the repository at this point in the history
* updated cypress testing for traces

Signed-off-by: Ritvi Bhatt <[email protected]>

* update snapshots

Signed-off-by: Ritvi Bhatt <[email protected]>

* wait for page to load before checking rows

Signed-off-by: Ritvi Bhatt <[email protected]>

* remove forgetten comment

Signed-off-by: Ritvi Bhatt <[email protected]>

* centralize exapnding service view

Signed-off-by: Ritvi Bhatt <[email protected]>

---------

Signed-off-by: Ritvi Bhatt <[email protected]>
Co-authored-by: Ritvi Bhatt <[email protected]>
Co-authored-by: Adam Tackett <[email protected]>
(cherry picked from commit 58d58a7)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 12, 2024
1 parent eb74123 commit c778e55
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/// <reference types="cypress" />

import { testDataSet, delay, setTimeFilter, jaegerTestDataSet } from '../../utils/constants';
import { testDataSet, setTimeFilter, jaegerTestDataSet } from '../../utils/constants';
import { suppressResizeObserverIssue } from '../../utils/constants';

suppressResizeObserverIssue();//needs to be in file once
Expand Down Expand Up @@ -102,15 +102,15 @@ describe('Testing dashboard table', () => {
});

it('Adds the percentile filters', () => {
cy.contains(' >= 95 percentile').click({ force: true });
cy.contains(' >= 95 percentile').click({ force: true });

cy.get('[data-test-subj="dashboardTable"]').should('be.visible');
cy.get('[data-test-subj="dashboard-table-percentile-button-2"]').click();

cy.contains('Latency percentile within trace group: >= 95th').should('exist');
cy.contains(' (7)').should('exist');
cy.contains('318.69').should('exist');

cy.contains(' < 95 percentile').click({ force: true });
cy.contains(' < 95 percentile').click({ force: true });
cy.get('[data-test-subj="dashboard-table-percentile-button-1"]').click();

cy.contains('Latency percentile within trace group: < 95th').should('exist');
cy.contains(' (8)').should('exist');
Expand Down Expand Up @@ -148,6 +148,7 @@ describe('Testing plots', () => {

it('Renders service map', () => {
// plotly scale texts are in attribute "data-unformatted"
cy.get('.euiSideNavItemButton__label').contains('Services').click();
cy.get('text.ytitle[data-unformatted="Average duration (ms)"]').should('exist');
cy.get('text[data-unformatted="200"]').should('exist');
cy.get('.vis-network').should('exist');
Expand Down Expand Up @@ -218,7 +219,6 @@ describe('Latency by trace group table', () =>{
it('Verify Search engine on Trace dashboard', () => {
cy.get('.euiFieldSearch.euiFieldSearch--fullWidth').click().type('client_pay_order');
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
cy.wait(delay);//Fails without
cy.get('.euiTableCellContent.euiTableCellContent--alignRight.euiTableCellContent--overflowingContent').contains('211.04').should('exist');
cy.get('button[data-test-subj="dashboard-table-trace-group-name-button"]').eq(0).click();
cy.get('.euiBadge.euiBadge--hollow.euiBadge--iconRight.globalFilterItem').click();
Expand Down Expand Up @@ -250,25 +250,22 @@ describe('Testing filters on trace analytics page', { scrollBehavior: false }, (
});

it('Verify Change all filters', () =>{
cy.wait(delay);//Needed after removing waits from setTimeFilter()
cy.get('[data-test-subj="global-filter-button"]').click();
cy.get('.euiContextMenuPanelTitle').contains('Change all filters').should('exist');
cy.get('.euiContextMenuItem__text').eq(0).contains('Enable all');
cy.get('.euiContextMenuItem__text').eq(1).contains('Disable all');
cy.get('.euiContextMenuItem__text').eq(2).contains('Invert inclusion');
cy.get('.euiContextMenuItem__text').eq(3).contains('Invert enabled/disabled');
cy.get('.euiContextMenuItem__text').eq(4).contains('Remove all');
cy.get('.euiContextMenuItem__text').eq(1).contains('Enable all');
cy.get('.euiContextMenuItem__text').eq(2).contains('Disable all');
cy.get('.euiContextMenuItem__text').eq(3).contains('Invert inclusion');
cy.get('.euiContextMenuItem__text').eq(4).contains('Invert enabled/disabled');
cy.get('.euiContextMenuItem__text').eq(5).contains('Remove all');
})

it('Verify Add filter section', () => {
cy.wait(delay);//Needed after removing waits from setTimeFilter()
cy.get('[data-test-subj="addfilter"]').contains('+ Add filter').click();
cy.get('.euiPopoverTitle').contains('Add filter').should('exist');
cy.wait(delay);//drop down won't open without
cy.get('.euiComboBox__inputWrap.euiComboBox__inputWrap--noWrap').eq(0).trigger('mouseover').click();
cy.get('.euiComboBoxOption__content').eq(1).click();
cy.get('.euiComboBox__inputWrap.euiComboBox__inputWrap--noWrap').eq(1).trigger('mouseover').click();
cy.get('.euiComboBoxOption__content').eq(2).click();
cy.get('[data-test-subj="global-filter-button"]').click();
cy.get('.euiContextMenuItem__text').contains('Add filter').click();
cy.get('[data-test-subj="field-selector-filter-panel"]').click();
cy.get('[data-test-subj="field-selector-filter-panel"]').type('traceId{enter}');
cy.get('[data-test-subj="operator-selector-filter-panel"]').click();
cy.get('[data-test-subj="operator-selector-filter-panel"]').type('exists{enter}');
cy.get('.euiButton.euiButton--primary.euiButton--fill').contains('Save').click();
cy.get('.euiBadge__content').should('exist').click();
cy.get('.euiIcon.euiIcon--medium.euiContextMenu__arrow').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/// <reference types="cypress" />

import { delay, SERVICE_NAME, SERVICE_SPAN_ID, setTimeFilter, verify_traces_spans_data_grid_cols_exists, count_table_row, AUTH_SERVICE_SPAN_ID } from '../../utils/constants';
import { expandServiceView, SERVICE_NAME, SERVICE_SPAN_ID, setTimeFilter, verify_traces_spans_data_grid_cols_exists, count_table_row, AUTH_SERVICE_SPAN_ID } from '../../utils/constants';
import { suppressResizeObserverIssue } from '../../utils/constants';

suppressResizeObserverIssue();//needs to be in file once
Expand All @@ -32,6 +32,8 @@ describe('Testing services table', () => {
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
});

Expand All @@ -44,13 +46,13 @@ describe('Testing services table', () => {

it('Searches correctly', () => {
cy.get('input[type="search"]').first().focus().type(`${SERVICE_NAME}{enter}`);
cy.get('.euiButton__text').contains('Refresh').click();
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
cy.contains(' (1)').should('exist');
cy.contains('3.57%').should('exist');
});

it('Verify columns in Services table', () => {
cy.get('.euiFlexItem.euiFlexItem--flexGrow10 .panel-title').contains('Services').should('exist');
cy.get('.euiFlexItem.euiFlexItem--flexGrowZero .panel-title').contains('Services').should('exist');
cy.get('.euiTableCellContent__text[title="Name"]').should('exist');
cy.get('.euiTableCellContent__text[title="Average duration (ms)"]').should('exist');
cy.get('.euiTableCellContent__text[title="Error rate"]').should('exist');
Expand Down Expand Up @@ -95,23 +97,25 @@ describe('Testing service view', () => {
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
cy.get('input[type="search"]').first().focus().type(`${SERVICE_NAME}`);
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
cy.get('.euiTableRow').should('have.length.lessThan', 3);//Replaces wait
cy.get('[data-test-subj="service-link"]').eq(0).click();
expandServiceView(0);
});

it('Renders service view', () => {
cy.get('h2.euiTitle').contains(SERVICE_NAME).should('exist');
cy.get('h1.overview-content').contains(SERVICE_NAME).should('exist');
cy.contains('178.6').should('exist');
cy.contains('3.57%').should('exist');
cy.get('div.vis-network').should('exist');
});

it('Has working breadcrumbs', () => {
cy.get('.euiBreadcrumb').contains(SERVICE_NAME).click();
cy.get('h2.euiTitle').contains(SERVICE_NAME).should('exist');
cy.get('h1.overview-content').contains(SERVICE_NAME).should('exist');
cy.get('.euiBreadcrumb').contains('Services').click();
cy.get('.euiBreadcrumb').contains('Trace analytics').click();
cy.get('.euiBreadcrumb').contains('Observability').click();
Expand All @@ -138,6 +142,8 @@ describe('Testing Service map', () => {
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
});

Expand All @@ -149,7 +155,7 @@ describe('Testing Service map', () => {
cy.contains('60%');
cy.get('[data-text = "Duration"]').click();
cy.contains('100');
cy.get('.euiText.euiText--medium').contains('Focus on').should('exist');
cy.get('.euiFormLabel.euiFormControlLayout__prepend').contains('Focus on').should('exist');
cy.get('[placeholder="Service name"]').focus().type('database{enter}');
})
});
Expand All @@ -161,36 +167,43 @@ describe('Testing traces Spans table verify table headers functionality', () =>
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
});

it('Renders the spans table and verify columns headers', () => {
cy.contains(' (8)').should('exist');
cy.contains('analytics-service, frontend-client, recommendation').should('exist');
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click();
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist');
expandServiceView(1);
cy.get('.panel-title').contains('Spans').should('exist');
cy.get('.panel-title-count').contains('8').should('exist');
verify_traces_spans_data_grid_cols_exists();
});

it('Toggle columns and verify the columns hidden text verify rows', () => {
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click();
cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click();
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist');
expandServiceView(1);
cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click({ force: true });

Check warning on line 188 in .cypress/integration/trace_analytics_test/trace_analytics_services.spec.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
cy.get('.panel-title-count').contains('8').should('exist');
cy.get('.euiSwitch.euiSwitch--compressed.euiSwitch--mini .euiSwitch__button').eq(3).click();
cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click().should('have.text', '2 columns hidden');
count_table_row(8);
});

it('Show all button Spans table', () => {
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click();
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist');
expandServiceView(1);
cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click();
cy.get('.euiPopoverFooter .euiFlexItem.euiFlexItem--flexGrowZero').eq(0).should('have.text', 'Show all').click();
cy.get('.euiDataGrid__focusWrap').click().should('exist');
verify_traces_spans_data_grid_cols_exists();
});

it('Hide all button Spans table', () => {
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click();
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist');
expandServiceView(1);
cy.get('.euiTableRow').should('have.length.lessThan', 2);//Replace wait
cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click();
cy.get('.euiPopoverFooter .euiFlexItem.euiFlexItem--flexGrowZero').eq(1).should('have.text', 'Hide all').click();
Expand All @@ -199,7 +212,8 @@ describe('Testing traces Spans table verify table headers functionality', () =>
});

it('Render Spans table and change data table Density', () => {
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click();
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist');
expandServiceView(1);
verify_traces_spans_data_grid_cols_exists();
cy.get('.euiButtonEmpty__text').contains('Density').click();
cy.get('.euiButtonContent__icon').eq(5).click();
Expand All @@ -208,7 +222,8 @@ describe('Testing traces Spans table verify table headers functionality', () =>
});

it('Render Spans table and and click on sort', () => {
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click();
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist');
expandServiceView(1);
verify_traces_spans_data_grid_cols_exists();
cy.get('[data-test-subj="dataGridColumnSortingButton"]').contains('Sort fields').should('exist').click();
cy.get('[data-test-subj="dataGridColumnSortingPopoverColumnSelection"]').click();
Expand All @@ -233,14 +248,17 @@ describe('Testing traces Spans table and verify columns functionality', () => {
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
});

it('Renders the spans table and click on first span to verify details', () => {
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click();
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist');
expandServiceView(1);
verify_traces_spans_data_grid_cols_exists();
cy.contains(AUTH_SERVICE_SPAN_ID).click();
cy.get('[data-test-subj="spanDetailFlyout"] .euiTitle.euiTitle--medium').contains('Span detail').should('exist');
cy.get('[data-test-subj="spanDetailFlyout"]').contains('Span detail').should('exist');
cy.get('.euiFlyoutBody .panel-title').contains('Overview').should('exist');
cy.get('.euiTextColor.euiTextColor--subdued').contains('Span ID').should('exist');
cy.get('[data-test-subj="parentSpanId"]').contains('d03fecfa0f55b77c').should('exist');
Expand All @@ -251,11 +269,13 @@ describe('Testing traces Spans table and verify columns functionality', () => {
cy.get('.euiBadge__content .euiBadge__text').contains('spanId: 277a5934acf55dcf').should('exist');
count_table_row(1);
cy.get('[aria-label="remove current filter"]').click();
cy.get('.panel-title-count').contains('8').should('exist');
count_table_row(8);
});

it('Render Spans table and verify Column functionality', () => {
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click();
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist');
expandServiceView(1);
verify_traces_spans_data_grid_cols_exists();
cy.get('.euiDataGridHeaderCell__content').contains('Span ID').click();
cy.get('.euiListGroupItem__label').contains('Hide column').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ describe('Testing traces table', () => {
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
});

it('Renders the traces table', () => {
cy.contains(' (108)').should('exist');
cy.contains('03/25/2021 10:23:45').should('exist');
cy.contains('03f9c770db5ee2f1caac0...').should('exist');
cy.contains('03f9c770db5ee2f1caac0afc36db49ba').should('exist');
cy.contains('224.99').should('exist');

// test data contains output from data-prepper 0.8, which doesn't have fields denormalized
Expand All @@ -52,7 +54,7 @@ describe('Testing traces table', () => {

it('Searches correctly', () => {
cy.get('input[type="search"]').focus().type(`${TRACE_ID}{enter}`);
cy.get('.euiButton__text').contains('Refresh').click();
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
cy.contains(' (1)').should('exist');
cy.contains('03/25/2021 10:21:22').should('exist');
});
Expand All @@ -65,9 +67,11 @@ describe('Testing trace view', () => {
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
cy.get('input[type="search"]').focus().type(`${TRACE_ID}`);
cy.get('.euiButton__text').contains('Refresh').click();
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
cy.get('.euiTableRow').should('have.length.lessThan', 3);//Replaces wait
cy.get('[data-test-subj="trace-link"]').eq(0).click();
});
Expand All @@ -84,11 +88,10 @@ describe('Testing trace view', () => {
});

it('Has working breadcrumbs', () => {
cy.get(`.euiBreadcrumb[href="#/traces/${TRACE_ID}"]`).click();
cy.get('h2.euiTitle').contains(TRACE_ID).should('exist');
cy.get('.euiBreadcrumb[href="#/traces"]').click();
cy.get('.euiBreadcrumb[href="#/"]').click();
cy.get('.euiBreadcrumb[href="observability-logs#/"]').click();
cy.get('.euiBreadcrumb').contains(TRACE_ID).click();
cy.get('.euiBreadcrumb').contains('Traces').click();
cy.get('.euiBreadcrumb').contains('Trace analytics').click();
cy.get('.euiBreadcrumb').contains('Observability').click();
cy.get('.euiTitle').contains('Logs').should('exist');
});

Expand Down Expand Up @@ -117,6 +120,8 @@ describe('Testing traces table', () => {
win.sessionStorage.clear();
},
});
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='data_prepper-mode']").click();
setTimeFilter();
});

Expand All @@ -132,8 +137,8 @@ describe('Testing traces table', () => {
cy.get('[data-test-subj="pagination-button-previous"]').click();
cy.contains('224.99').should('exist');
cy.get('.euiButtonEmpty').contains('5').click();
cy.contains('690d3c7af1a78cf89c43e...').should('exist');
cy.contains('5be8370207cbb002a165d...').click();
cy.contains('690d3c7af1a78cf89c43e').should('exist');
cy.contains('5be8370207cbb002a165d').click();
cy.contains('client_create_order').should('exist');
cy.get('path[style*="rgb(116, 146, 231)"]').should('exist');
cy.go('back');
Expand Down
18 changes: 10 additions & 8 deletions .cypress/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const DATASOURCES_PATH = {
export const TRACE_ID = '8832ed6abbb2a83516461960c89af49d';
export const SPAN_ID = 'a673bc074b438374';
export const SERVICE_NAME = 'frontend-client';
export const SERVICE_SPAN_ID = '7df5609a6d104736';
export const SERVICE_SPAN_ID = 'e275ac9d21929e9b';
export const AUTH_SERVICE_SPAN_ID = '277a5934acf55dcf';

export const testDataSet = [
Expand Down Expand Up @@ -68,26 +68,27 @@ export const setTimeFilter = (setEndTime = false, refresh = true) => {
cy.get('button.euiButtonEmpty[aria-label="Date quick select"]').click();
cy.get('.euiQuickSelect__applyButton').click();
cy.get('.euiSuperDatePicker__prettyFormatLink').click();
cy.get(
'button.euiDatePopoverButton--start[data-test-subj="superDatePickerstartDatePopoverButton"]'
).click();
cy.get('.euiTab__content').contains('Absolute').click();
cy.get('input[data-test-subj="superDatePickerAbsoluteDateInput"]')
.focus()
.type('{selectall}' + startTime, { force: true });
if (setEndTime) {
cy.get(
'button.euiDatePopoverButton--end[data-test-subj="superDatePickerendDatePopoverButton"]'
).click();
cy.get('button.euiDatePopoverButton--end[data-test-subj="superDatePickerendDatePopoverButton"]').click();
cy.get('.euiTab__content').contains('Absolute').click();
cy.get('input[data-test-subj="superDatePickerAbsoluteDateInput"]')
.focus()
.type('{selectall}' + endTime, { force: true });
}
if (refresh) cy.get('.euiButton__text').contains('Refresh').click();
if (refresh) cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
cy.get('.euiTableRow').should('have.length.greaterThan', 3); //Replaces Wait
};

export const expandServiceView = (rowIndex = 0) => {
cy.get('*[data-test-subj^="service-flyout-action-btntrace_service"]').eq(rowIndex).click();
cy.get('[data-test-subj="ActionContextMenu"]').click();
cy.get('[data-test-subj="viewServiceButton"]').click();
};

// notebooks
export const TEST_NOTEBOOK = 'Test Notebook';
export const TEST_INTEGRATION_INSTANCE = 'nginx-test';
Expand Down Expand Up @@ -130,6 +131,7 @@ export const PPL_QUERY_TEXT = `%ppl
source=opensearch_dashboards_sample_data_flights {enter}
`;


export const suppressResizeObserverIssue = () => {
// exception is thrown on loading EuiDataGrid in cypress only, ignore for now
cy.on('uncaught:exception', (err, runnable) => {
Expand Down
Loading

0 comments on commit c778e55

Please sign in to comment.