diff --git a/test/functional/services/remote/network_profiles.ts b/test/functional/services/remote/network_profiles.ts new file mode 100644 index 00000000000000..c27bafa4f8dcb9 --- /dev/null +++ b/test/functional/services/remote/network_profiles.ts @@ -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 }, +}; diff --git a/test/functional/services/remote/webdriver.ts b/test/functional/services/remote/webdriver.ts index 2eb1609156db46..1f32a0ec414cfa 100644 --- a/test/functional/services/remote/webdriver.ts +++ b/test/functional/services/remote/webdriver.ts @@ -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; @@ -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, }); } diff --git a/x-pack/test/performance/tests/home.ts b/x-pack/test/performance/tests/home.ts new file mode 100644 index 00000000000000..eda690b9b0a19c --- /dev/null +++ b/x-pack/test/performance/tests/home.ts @@ -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 }); + }); + }); +} diff --git a/x-pack/test/performance/tests/index.ts b/x-pack/test/performance/tests/index.ts index b1023bde688e2e..d784fa3031739d 100644 --- a/x-pack/test/performance/tests/index.ts +++ b/x-pack/test/performance/tests/index.ts @@ -11,6 +11,6 @@ export default function ({ loadTestFile }: FtrProviderContext) { describe('performance', function () { this.tags('ciGroup8'); - loadTestFile(require.resolve('./reporting_dashboard')); + loadTestFile(require.resolve('./home')); }); } diff --git a/x-pack/test/performance/tests/reporting_dashboard.ts b/x-pack/test/performance/tests/reporting_dashboard.ts index f363f8449df96b..93b4010ab27a8e 100644 --- a/x-pack/test/performance/tests/reporting_dashboard.ts +++ b/x-pack/test/performance/tests/reporting_dashboard.ts @@ -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'