Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 All @@ -31,21 +30,25 @@ describe.skip('Functions page', () => {
});

it('validates values in the table', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
cy.intercept('GET', '/internal/profiling/topn/functions?*', {
fixture: 'topn_functions.json',
}).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(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(7).contains('28');
cy.get(firstRowSelector).eq(3).contains('13.45%');
cy.get(firstRowSelector).eq(4).contains('13.86%');
cy.get(firstRowSelector).eq(5).contains('10.58 lbs / 4.8 kg');
cy.get(firstRowSelector).eq(6).contains('$45.07');
cy.get(firstRowSelector).eq(7).contains('67');
});

it('shows function details when action button is clicked on the table ', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
cy.intercept('GET', '/internal/profiling/topn/functions?*', {
fixture: 'topn_functions.json',
}).as('getTopNFunctions');
cy.visitKibana('/app/profiling/functions', { rangeFrom, rangeTo });
cy.wait('@getTopNFunctions');
const firstRowSelector =
Expand All @@ -57,33 +60,39 @@ describe.skip('Functions page', () => {
{ parentKey: 'informationRows', key: 'executable', value: 'vmlinux' },
{ parentKey: 'informationRows', key: 'function', value: 'N/A' },
{ parentKey: 'informationRows', key: 'sourceFile', value: 'N/A' },
{ parentKey: 'impactEstimates', key: 'totalCPU', value: '5.46%' },
{ 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: 'totalCPU', value: '13.86%' },
{ parentKey: 'impactEstimates', key: 'selfCPU', value: '13.45%' },
{ parentKey: 'impactEstimates', key: 'samples', value: '69' },
{ parentKey: 'impactEstimates', key: 'selfSamples', value: '67' },
{ parentKey: 'impactEstimates', key: 'coreSeconds', value: '3.45 seconds' },
{ parentKey: 'impactEstimates', key: 'selfCoreSeconds', value: '3.35 seconds' },
{ parentKey: 'impactEstimates', key: 'annualizedCoreSeconds', value: '1.38 months' },
{ parentKey: 'impactEstimates', key: 'annualizedSelfCoreSeconds', value: '1.34 months' },
{ 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: '10.58 lbs / 4.8 kg' },
{
parentKey: 'impactEstimates',
key: 'annualizedSelfCo2Emission',
value: '3.97 lbs / 1.8 kg',
value: '10.14 lbs / 4.6 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: '$45.07' },
{ parentKey: 'impactEstimates', key: 'annualizedSelfDollarCost', value: '$43.76' },
].forEach(({ parentKey, key, value }) => {
cy.get(`[data-test-subj="${parentKey}_${key}"]`).contains(value);
});
});

it('adds kql filter', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
cy.intercept('GET', '/internal/profiling/topn/functions?*', (req) => {
if (req.url.includes('kuery=Stacktrace.id')) {
req.reply({ fixture: 'topn_functions_stacktrace_filtered.json' });
} else {
req.reply({ fixture: 'topn_functions.json' });
}
}).as('getTopNFunctions');
cy.visitKibana('/app/profiling/functions', { rangeFrom, rangeTo });
cy.wait('@getTopNFunctions');
const firstRowSelector = '[data-grid-row-index="0"] [data-test-subj="dataGridRowCell"]';
Expand Down Expand Up @@ -147,14 +156,20 @@ describe.skip('Functions page', () => {
lowValue: '$0.62',
},
].forEach(({ columnKey, columnIndex, highRank, highValue, lowRank, lowValue }) => {
cy.get(`[data-test-subj="dataGridHeaderCell-${columnKey}"]`).click();
cy.contains('Sort High-Low').click();
cy.get('[title="Sort High-Low"]').should('not.exist');
cy.get(`[data-test-subj="dataGridHeaderCell-${columnKey}"]`)
.focus()
.trigger('keydown', { key: 'Enter' });
cy.get('[title="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(`[data-test-subj="dataGridHeaderCell-${columnKey}"]`)
.focus()
.trigger('keydown', { key: 'Enter' });
cy.get('[title="Sort Low-High"]').click();
cy.get(firstRowSelector).eq(1).contains(lowRank);
if (lowValue !== undefined) {
cy.get(firstRowSelector).eq(columnIndex).contains(lowValue);
Expand All @@ -163,14 +178,18 @@ describe.skip('Functions page', () => {
}
});

cy.get(`[data-test-subj="dataGridHeaderCell-frame"]`).click();
cy.contains('Sort Z-A').click();
cy.get(`[data-test-subj="dataGridHeaderCell-frame"]`)
.focus()
.trigger('keydown', { key: 'Enter' });
cy.get('[title="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('[data-test-subj="dataGridHeaderCell-frame"]')
.focus()
.trigger('keydown', { key: 'Enter' });
cy.get('[title="Sort A-Z"]').click();
cy.get(firstRowSelector).eq(1).contains('88');
cy.get(firstRowSelector).eq(2).contains('/');
});
Expand All @@ -184,13 +203,22 @@ describe.skip('Functions page', () => {
});
});
it('changes CO2 settings and validate values in the table', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
let callCount = 0;
cy.intercept('GET', '/internal/profiling/topn/functions?*', (req) => {
callCount += 1;

if (callCount === 2) {
req.reply({ fixture: 'topn_functions_changed_settings.json' });
} else {
req.reply({ fixture: 'topn_functions.json' });
}
}).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('10.58 lbs / 4.8 kg');
cy.contains('Settings').click();
cy.contains('Advanced Settings');
cy.get(`[data-test-subj="management-settings-editField-${profilingCo2PerKWH}"]`)
Expand All @@ -209,7 +237,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('4.85 lbs / 2.2 kg');
const firstRowSelectorActionButton =
'[data-grid-row-index="0"] [data-test-subj="dataGridRowCell"] .euiButtonIcon';
cy.get(firstRowSelectorActionButton).click();
Expand All @@ -219,12 +247,12 @@ describe.skip('Functions page', () => {
{
parentKey: 'impactEstimates',
key: 'annualizedCo2Emission',
value: '1.87k lbs / 847.8 kg',
value: '4.85 lbs / 2.2 kg',
},
{
parentKey: 'impactEstimates',
key: 'annualizedSelfCo2Emission',
value: '1.87k lbs / 847.8 kg',
value: '5.73 lbs / 2.6 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
@@ -0,0 +1,102 @@
{
"TotalCount": 12540,
"totalCPU": 12540,
"selfCPU": 498,
"totalAnnualCO2Kgs": 34.5,
"totalAnnualCostUSD": 325.2726,
"SamplingRate": 1,
"TopN": [
{
"Id": "574807228",
"Rank": 1,
"CountExclusive": 67,
"CountInclusive": 69,
"selfAnnualCO2kgs": 4.6,
"selfAnnualCostUSD": 43.7616,
"totalAnnualCO2kgs": 4.8,
"totalAnnualCostUSD": 45.0679,
"subGroups": { "service.name": { "": { "count": 590 } } },
"Frame": {
"AddressOrLine": 12583051,
"ExeFileName": "vmlinux",
"FrameType": 4,
"FunctionName": "",
"Inline": false,
"SourceFilename": "",
"SourceLine": 0,
"FileID": "",
"FrameID": "",
"FunctionOffset": 0
}
},
{
"Id": "602913197",
"Rank": 2,
"CountExclusive": 36,
"CountInclusive": 324,
"selfAnnualCO2kgs": 2.5,
"selfAnnualCostUSD": 23.5137,
"totalAnnualCO2kgs": 22.5,
"totalAnnualCostUSD": 211.6232,
"subGroups": { "service.name": { "": { "count": 2114 } } },
"Frame": {
"AddressOrLine": 12941846,
"ExeFileName": "libjvm.so",
"FrameType": 3,
"FunctionName": "",
"Inline": false,
"SourceFilename": "",
"SourceLine": 0,
"FileID": "",
"FrameID": "",
"FunctionOffset": 0
}
},
{
"Id": "-610160251",
"Rank": 3,
"CountExclusive": 36,
"CountInclusive": 54,
"selfAnnualCO2kgs": 2.5,
"selfAnnualCostUSD": 23.5137,
"totalAnnualCO2kgs": 3.7,
"totalAnnualCostUSD": 35.2705,
"subGroups": { "service.name": { "": { "count": 795 } } },
"Frame": {
"AddressOrLine": 42414592,
"ExeFileName": "metricbeat",
"FrameType": 3,
"FunctionName": "",
"Inline": false,
"SourceFilename": "",
"SourceLine": 0,
"FileID": "",
"FrameID": "",
"FunctionOffset": 0
}
},
{
"Id": "574807228",
"Rank": 1,
"CountExclusive": 67,
"CountInclusive": 69,
"selfAnnualCO2kgs": 4.6,
"selfAnnualCostUSD": 43.7616,
"totalAnnualCO2kgs": 4.8,
"totalAnnualCostUSD": 45.0679,
"subGroups": { "service.name": { "": { "count": 590 } } },
"Frame": {
"AddressOrLine": 12583051,
"ExeFileName": "vmlinux",
"FrameType": 4,
"FunctionName": "",
"Inline": false,
"SourceFilename": "",
"SourceLine": 0,
"FileID": "",
"FrameID": "",
"FunctionOffset": 0
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"TotalCount": 12540,
"totalCPU": 12540,
"selfCPU": 498,
"totalAnnualCO2Kgs": 34.5,
"totalAnnualCostUSD": 325.2726,
"SamplingRate": 1,
"TopN": [
{
"Id": "574807228",
"Rank": 1,
"CountExclusive": 67,
"CountInclusive": 69,
"selfAnnualCO2kgs": 2.6,
"selfAnnualCostUSD": 23.7616,
"totalAnnualCO2kgs": 2.2,
"totalAnnualCostUSD": 25.0679,
"subGroups": { "service.name": { "": { "count": 590 } } },
"Frame": {
"AddressOrLine": 12583051,
"ExeFileName": "vmlinux",
"FrameType": 4,
"FunctionName": "",
"Inline": false,
"SourceFilename": "",
"SourceLine": 0,
"FileID": "",
"FrameID": "",
"FunctionOffset": 0
}
},
{
"Id": "602913197",
"Rank": 2,
"CountExclusive": 36,
"CountInclusive": 324,
"selfAnnualCO2kgs": 2.5,
"selfAnnualCostUSD": 23.5137,
"totalAnnualCO2kgs": 22.5,
"totalAnnualCostUSD": 211.6232,
"subGroups": { "service.name": { "": { "count": 2114 } } },
"Frame": {
"AddressOrLine": 12941846,
"ExeFileName": "libjvm.so",
"FrameType": 3,
"FunctionName": "",
"Inline": false,
"SourceFilename": "",
"SourceLine": 0,
"FileID": "",
"FrameID": "",
"FunctionOffset": 0
}
},
{
"Id": "-610160251",
"Rank": 3,
"CountExclusive": 36,
"CountInclusive": 54,
"selfAnnualCO2kgs": 2.5,
"selfAnnualCostUSD": 23.5137,
"totalAnnualCO2kgs": 3.7,
"totalAnnualCostUSD": 35.2705,
"subGroups": { "service.name": { "": { "count": 795 } } },
"Frame": {
"AddressOrLine": 42414592,
"ExeFileName": "metricbeat",
"FrameType": 3,
"FunctionName": "",
"Inline": false,
"SourceFilename": "",
"SourceLine": 0,
"FileID": "",
"FrameID": "",
"FunctionOffset": 0
}
}
]
}
Loading