Skip to content

Commit

Permalink
Performance test for login and home page (#117861) (#119089)
Browse files Browse the repository at this point in the history
- Remove reporting-dashboard test from performance tests and add login page and home page tests to get
performance metrics.
- Set network latency (KBN_TEST_NETWORK_LATENCY), download throughput (KBN_TEST_DOWNLOAD_THROUGHPUT) and upload throughput (KBN_TEST_UPLOAD_THROUGHPUT) through environment variables and fallback to default 100ms latency for network latency, 5MB for download throughput and 1MB for upload throughput.

Co-authored-by: Baturalp Gurdin <9674241+suchcodemuchwow@users.noreply.github.com>
  • Loading branch information
kibanamachine and suchcodemuchwow authored Nov 18, 2021
1 parent 9770e80 commit 9764f01
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 7 deletions.
34 changes: 34 additions & 0 deletions test/functional/services/remote/network_profiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

interface NetworkOptions {
DOWNLOAD: number;
UPLOAD: number;
LATENCY: number;
}

const sec = 1_000;
const kB = 1024;

// Download (kb/s) Upload (kb/s) Latency (ms)
// https://gist.github.com/theodorosploumis/fd4086ee58369b68aea6b0782dc96a2e
export const NETWORK_PROFILES: { [key: string]: NetworkOptions } = {
DEFAULT: { DOWNLOAD: 5 * kB * sec, UPLOAD: 1 * kB * sec, LATENCY: 0.1 * sec },
GPRS: { DOWNLOAD: 0.05 * kB * sec, UPLOAD: 0.02 * kB * sec, LATENCY: 0.5 * sec },
MOBILE_EDGE: { DOWNLOAD: 0.24 * kB * sec, UPLOAD: 0.2 * kB * sec, LATENCY: 0.84 * sec },
'2G_REGULAR': { DOWNLOAD: 0.25 * kB * sec, UPLOAD: 0.05 * kB * sec, LATENCY: 0.3 * sec },
'2G_GOOD': { DOWNLOAD: 0.45 * kB * sec, UPLOAD: 0.15 * kB * sec, LATENCY: 0.15 * sec },
'3G_SLOW': { DOWNLOAD: 0.78 * kB * sec, UPLOAD: 0.33 * kB * sec, LATENCY: 0.2 * sec },
'3G_REGULAR': { DOWNLOAD: 0.75 * kB * sec, UPLOAD: 0.25 * kB * sec, LATENCY: 0.1 * sec },
'3G_GOOD': { DOWNLOAD: 1.5 * kB * sec, UPLOAD: 0.75 * kB * sec, LATENCY: 0.04 * sec },
'4G_REGULAR': { DOWNLOAD: 4 * kB * sec, UPLOAD: 3 * kB * sec, LATENCY: 0.02 * sec },
DSL: { DOWNLOAD: 2 * kB * sec, UPLOAD: 1 * kB * sec, LATENCY: 0.005 * sec },
CABLE_5MBPS: { DOWNLOAD: 5 * kB * sec, UPLOAD: 1 * kB * sec, LATENCY: 0.28 * sec },
CABLE_8MBPS: { DOWNLOAD: 8 * kB * sec, UPLOAD: 2 * kB * sec, LATENCY: 0.1 * sec },
WIFI: { DOWNLOAD: 30 * kB * sec, UPLOAD: 15 * kB * sec, LATENCY: 0.002 * sec },
};
27 changes: 22 additions & 5 deletions test/functional/services/remote/webdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { createStdoutSocket } from './create_stdout_stream';
import { preventParallelCalls } from './prevent_parallel_calls';

import { Browsers } from './browsers';
import { NETWORK_PROFILES } from './network_profiles';

const throttleOption: string = process.env.TEST_THROTTLE_NETWORK as string;
const headlessBrowser: string = process.env.TEST_BROWSER_HEADLESS as string;
Expand Down Expand Up @@ -280,14 +281,30 @@ async function attemptToCreateCommand(
const { session, consoleLog$ } = await buildDriverInstance();

if (throttleOption === '1' && browserType === 'chrome') {
const { KBN_NETWORK_TEST_PROFILE = 'DEFAULT' } = process.env;

const profile =
KBN_NETWORK_TEST_PROFILE in Object.keys(NETWORK_PROFILES)
? KBN_NETWORK_TEST_PROFILE
: 'DEFAULT';

const {
DOWNLOAD: downloadThroughput,
UPLOAD: uploadThroughput,
LATENCY: latency,
} = NETWORK_PROFILES[`${profile}`];

// Only chrome supports this option.
log.debug('NETWORK THROTTLED: 768k down, 256k up, 100ms latency.');
log.debug(
`NETWORK THROTTLED with profile ${profile}: ${downloadThroughput}kbps down, ${uploadThroughput}kbps up, ${latency} ms latency.`
);

(session as any).setNetworkConditions({
// @ts-expect-error
session.setNetworkConditions({
offline: false,
latency: 100, // Additional latency (ms).
download_throughput: 768 * 1024, // These speeds are in bites per second, not kilobytes.
upload_throughput: 256 * 1024,
latency,
download_throughput: downloadThroughput,
upload_throughput: uploadThroughput,
});
}

Expand Down
25 changes: 25 additions & 0 deletions x-pack/test/performance/tests/home.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.
*/

import { FtrProviderContext } from '../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'security']);
const testSubjects = getService('testSubjects');

describe('Login', () => {
it('login and navigate to homepage', async () => {
await PageObjects.common.navigateToApp('login');

await testSubjects.existOrFail('loginSubmit', { timeout: 2000 });

await PageObjects.security.login();

await testSubjects.existOrFail('homeApp', { timeout: 2000 });
});
});
}
2 changes: 1 addition & 1 deletion x-pack/test/performance/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export default function ({ loadTestFile }: FtrProviderContext) {
describe('performance', function () {
this.tags('ciGroup8');

loadTestFile(require.resolve('./reporting_dashboard'));
loadTestFile(require.resolve('./home'));
});
}
2 changes: 1 addition & 1 deletion x-pack/test/performance/tests/reporting_dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function ({ getService, getPageObject }: FtrProviderContext) {
const dashboard = getPageObject('dashboard');
const reporting = getPageObject('reporting');

describe('reporting dashbaord', () => {
describe('Reporting Dashboard', () => {
before(async () => {
await kibanaServer.importExport.load(
'x-pack/test/performance/kbn_archives/reporting_dashboard'
Expand Down

0 comments on commit 9764f01

Please sign in to comment.