From 398fd0f32326e40157900f7b30852ae0e33395d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cau=C3=AA=20Marcondes?=
<55978943+cauemarcondes@users.noreply.github.com>
Date: Wed, 4 Dec 2024 13:12:22 +0000
Subject: [PATCH] [Profiling] fixing broken tests (#202895)
closes https://github.com/elastic/kibana/issues/192697
---
.buildkite/pipelines/flaky_tests/groups.json | 4 +
.../differential_functions.cy.ts | 28 ++--
.../e2e/profiling_views/functions.cy.ts | 120 +++---------------
.../profiling_views/storage_explorer.cy.ts | 42 +-----
.../public/views/storage_explorer/index.tsx | 2 +
5 files changed, 43 insertions(+), 153 deletions(-)
diff --git a/.buildkite/pipelines/flaky_tests/groups.json b/.buildkite/pipelines/flaky_tests/groups.json
index 77c3d23714d6f..2e92f82a4d958 100644
--- a/.buildkite/pipelines/flaky_tests/groups.json
+++ b/.buildkite/pipelines/flaky_tests/groups.json
@@ -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"
diff --git a/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/differential_functions.cy.ts b/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/differential_functions.cy.ts
index 2b6d99b0207a4..4b6a2da0c2503 100644
--- a/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/differential_functions.cy.ts
+++ b/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/differential_functions.cy.ts
@@ -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);
@@ -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);
@@ -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',
},
{
@@ -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',
},
{
@@ -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');
[
diff --git a/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/functions.cy.ts b/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/functions.cy.ts
index 0f006e80bb940..c4350f574c2a8 100644
--- a/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/functions.cy.ts
+++ b/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/functions.cy.ts
@@ -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';
@@ -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');
});
@@ -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);
});
@@ -93,96 +92,17 @@ 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 });
@@ -190,7 +110,7 @@ describe.skip('Functions page', () => {
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}"]`)
@@ -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();
@@ -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);
diff --git a/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/storage_explorer.cy.ts b/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/storage_explorer.cy.ts
index db752969f14dd..2efb71201301e 100644
--- a/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/storage_explorer.cy.ts
+++ b/x-pack/plugins/observability_solution/profiling/e2e/cypress/e2e/profiling_views/storage_explorer.cy.ts
@@ -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' },
@@ -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);
- });
- });
});
});
diff --git a/x-pack/plugins/observability_solution/profiling/public/views/storage_explorer/index.tsx b/x-pack/plugins/observability_solution/profiling/public/views/storage_explorer/index.tsx
index ff111c4bebcd0..5603f19099c7e 100644
--- a/x-pack/plugins/observability_solution/profiling/public/views/storage_explorer/index.tsx
+++ b/x-pack/plugins/observability_solution/profiling/public/views/storage_explorer/index.tsx
@@ -97,6 +97,7 @@ export function StorageExplorerView() {
{
setSelectedTab('host_breakdown');
}}
@@ -107,6 +108,7 @@ export function StorageExplorerView() {
})}
{
setSelectedTab('data_breakdown');
}}