Skip to content

Commit

Permalink
Merge branch '8.10' into backport/8.10/pr-164738
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Aug 25, 2023
2 parents 0ab67d0 + 093a7af commit 76ae7ea
Show file tree
Hide file tree
Showing 41 changed files with 27,286 additions and 33,115 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

describe('Differential Functions page', () => {
const rangeFrom = '2023-04-18T00:00:00.000Z';
const rangeTo = '2023-04-18T00:00:30.000Z';

const comparisonRangeFrom = '2023-04-18T00:01:00.000Z';
const comparisonRangeTo = '2023-04-18T00:01:30.000Z';

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

it('opens differential page', () => {
cy.visitKibana('/app/profiling/functions/differential', { rangeFrom, rangeTo });
cy.contains('Baseline functions');
cy.contains('Comparison functions');
});

describe('summary', () => {
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: '33.79 lbs / 15.33 kg' },
{ id: 'annualizedCost', value: '$318.32' },
{ id: 'totalNumberOfSamples', value: '513' },
].forEach((item) => {
cy.get(`[data-test-subj="${item.id}_value"]`).contains(item.value);
cy.get(`[data-test-subj="${item.id}_comparison_value"]`).should('not.exist');
});
});

it('shows empty baseline values when data is not available', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
cy.visitKibana('/app/profiling/functions/differential', {
comparisonRangeFrom: rangeFrom,
comparisonRangeTo: rangeTo,
});
cy.wait('@getTopNFunctions');
cy.wait('@getTopNFunctions');
[
{ id: 'overallPerformance', value: '0%' },
{ id: 'annualizedCo2', value: '0 lbs / 0 kg', comparisonValue: '33.79 lbs / 15.33 kg' },
{ id: 'annualizedCost', value: '$0', comparisonValue: '$318.32' },
{ id: 'totalNumberOfSamples', value: '0', comparisonValue: '15,390' },
].forEach((item) => {
cy.get(`[data-test-subj="${item.id}_value"]`).contains(item.value);
if (item.comparisonValue) {
cy.get(`[data-test-subj="${item.id}_comparison_value"]`).contains(item.comparisonValue);
}
});
});

it('show gained performance when comparison data has less samples than baseline', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
cy.visitKibana('/app/profiling/functions/differential', {
rangeFrom,
rangeTo,
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: '33.79 lbs / 15.33 kg',
comparisonValue: '11.53 lbs / 5.23 kg (65.89%)',
icon: 'comparison_sortUp_success',
},
{
id: 'annualizedCost',
value: '$318.32',
comparisonValue: '$108.59 (65.89%)',
icon: 'comparison_sortUp_success',
},
{
id: 'totalNumberOfSamples',
value: '513',
comparisonValue: '175 (65.89%)',
icon: 'comparison_sortUp_success',
},
].forEach((item) => {
cy.get(`[data-test-subj="${item.id}_value"]`).contains(item.value);
cy.get(`[data-test-subj="${item.id}_${item.icon}"]`).should('exist');
if (item.comparisonValue) {
cy.get(`[data-test-subj="${item.id}_comparison_value"]`).contains(item.comparisonValue);
}
});
});

it('show lost performance when comparison data has more samples than baseline', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
cy.visitKibana('/app/profiling/functions/differential', {
rangeFrom: comparisonRangeFrom,
rangeTo: comparisonRangeTo,
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: '11.53 lbs / 5.23 kg',
comparisonValue: '33.79 lbs / 15.33 kg (193.14%)',
icon: 'comparison_sortDown_danger',
},
{
id: 'annualizedCost',
value: '$108.59',
comparisonValue: '$318.32 (193.14%)',
icon: 'comparison_sortDown_danger',
},
{
id: 'totalNumberOfSamples',
value: '175',
comparisonValue: '513 (193.14%)',
icon: 'comparison_sortDown_danger',
},
].forEach((item) => {
cy.get(`[data-test-subj="${item.id}_value"]`).contains(item.value);
cy.get(`[data-test-subj="${item.id}_${item.icon}"]`).should('exist');
if (item.comparisonValue) {
cy.get(`[data-test-subj="${item.id}_comparison_value"]`).contains(item.comparisonValue);
}
});
});
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');
[
{ id: 'overallPerformance', value: '0%' },
{ id: 'annualizedCo2', value: '0 lbs / 0 kg' },
{ id: 'annualizedCost', value: '$0' },
{ id: 'totalNumberOfSamples', value: '0' },
].forEach((item) => {
cy.get(`[data-test-subj="${item.id}_value"]`).contains(item.value);
cy.get(`[data-test-subj="${item.id}_comparison_value"]`).should('not.exist');
});
});

it('adds kql filter', () => {
cy.intercept('GET', '/internal/profiling/topn/functions?*').as('getTopNFunctions');
cy.visitKibana('/app/profiling/functions/differential', {
rangeFrom: comparisonRangeFrom,
rangeTo: comparisonRangeTo,
comparisonRangeFrom: rangeFrom,
comparisonRangeTo: rangeTo,
});
cy.wait('@getTopNFunctions');
cy.wait('@getTopNFunctions');
cy.get('[data-test-subj="topNFunctionsGrid"] .euiDataGridRow').should('have.length.gt', 1);
cy.get('[data-test-subj="TopNFunctionsComparisonGrid"] .euiDataGridRow').should(
'have.length.gt',
1
);
cy.addKqlFilter({
key: 'process.thread.name',
value: '108795321966692',
});
cy.addKqlFilter({
key: 'Stacktrace.id',
value: '-7DvnP1mizQYw8mIIpgbMg',
dataTestSubj: 'profilingComparisonUnifiedSearchBar',
});
cy.wait('@getTopNFunctions');
cy.wait('@getTopNFunctions');
cy.get('[data-test-subj="topNFunctionsGrid"] .euiDataGridRow').should('have.length', 2);
cy.get('[data-test-subj="TopNFunctionsComparisonGrid"] .euiDataGridRow').should(
'have.length',
1
);
[
{ id: 'overallPerformance', value: '50.00%', icon: 'sortUp_success' },
{
id: 'annualizedCo2',
value: '0.13 lbs / 0.06 kg',
comparisonValue: '0.07 lbs / 0.03 kg (50.00%)',
icon: 'comparison_sortUp_success',
},
{
id: 'annualizedCost',
value: '$1.24',
comparisonValue: '$0.62 (50.00%)',
icon: 'comparison_sortUp_success',
},
{
id: 'totalNumberOfSamples',
value: '2',
comparisonValue: '1 (50.00%)',
icon: 'comparison_sortUp_success',
},
].forEach((item) => {
cy.get(`[data-test-subj="${item.id}_value"]`).contains(item.value);
cy.get(`[data-test-subj="${item.id}_${item.icon}"]`).should('exist');
if (item.comparisonValue) {
cy.get(`[data-test-subj="${item.id}_comparison_value"]`).contains(item.comparisonValue);
}
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

describe('Functions page', () => {
const rangeFrom = '2023-04-18T00:00:00.000Z';
const rangeTo = '2023-04-18T00:00:30.000Z';

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

it('opens /topN page when navigating to /functions page', () => {
cy.visitKibana('/app/profiling/functions', { rangeFrom, rangeTo });
cy.url().should('include', '/app/profiling/functions/topn');
});

it('shows TopN functions and Differential TopN functions', () => {
cy.visitKibana('/app/profiling/functions', { rangeFrom, rangeTo });
cy.contains('TopN functions');
cy.contains('Differential TopN functions');
});

it('validates 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(3).contains('5.46%');
cy.get(firstRowSelector).eq(4).contains('5.46%');
cy.get(firstRowSelector).eq(5).contains('1.84 lbs / 0.84 kg');
cy.get(firstRowSelector).eq(6).contains('$17.37');
cy.get(firstRowSelector).eq(7).contains('28');
});

it('shows function details when action button is clicked on 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"] .euiButtonIcon';
cy.get(firstRowSelector).click();
cy.contains('Frame information');
cy.contains('Impact estimates');
[
{ 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: 'co2Emission', value: '~0.00 lbs / ~0.00 kg' },
{ parentKey: 'impactEstimates', key: 'selfCo2Emission', value: '~0.00 lbs / ~0.00 kg' },
{ parentKey: 'impactEstimates', key: 'annualizedCo2Emission', value: '1.84 lbs / 0.84 kg' },
{
parentKey: 'impactEstimates',
key: 'annualizedSelfCo2Emission',
value: '1.84 lbs / 0.84 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' },
].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.visitKibana('/app/profiling/functions', { rangeFrom, rangeTo });
cy.wait('@getTopNFunctions');
cy.get('.euiDataGridRow').should('have.length.gt', 1);
cy.addKqlFilter({ key: 'Stacktrace.id', value: '-7DvnP1mizQYw8mIIpgbMg' });
cy.wait('@getTopNFunctions');
cy.get('.euiDataGridRow').should('have.length', 1);
const firstRowSelector = '[data-grid-row-index="0"] [data-test-subj="dataGridRowCell"]';
cy.get(firstRowSelector).eq(2).contains('libjvm.so');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
* 2.0.
*/

const start = '2023-03-17T01:00:00.000Z';
const end = '2023-03-17T01:05:00.000Z';

describe('Home page', () => {
const rangeFrom = '2023-04-18T00:00:00.000Z';
const rangeTo = '2023-04-18T00:05:00.000Z';

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

it('navigates through the tabs', () => {
cy.visitKibana('/app/profiling', start, end);
cy.visitKibana('/app/profiling', { rangeFrom, rangeTo });
cy.url().should('include', '/app/profiling/stacktraces/threads');
cy.get('[role="tablist"]').within(() => {
cy.contains('Traces').click();
Expand Down
Loading

0 comments on commit 76ae7ea

Please sign in to comment.