Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Tests for Login and Home Pages by using Playwright #119681

Merged
merged 78 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
025c0d9
feat(performance tests for login and home pages): add performance tes…
Nov 24, 2021
ee2579a
Merge branch 'main' into 2021-11-25-synthetics-perf-test-login-and-ho…
kibanamachine Nov 26, 2021
ade404f
Merge branch 'main' of github.com:elastic/kibana into 2021-11-25-synt…
Nov 26, 2021
6eba35d
fix(functional_tests.js): add synthetics config import
Nov 26, 2021
d8e7a31
Merge branch '2021-11-25-synthetics-perf-test-login-and-home-page' of…
Nov 26, 2021
a441885
fix test start
Nov 26, 2021
3c0323b
fix test config
Nov 27, 2021
2518fd4
fix: increase timeout of Login to Kibana step
Nov 28, 2021
2954966
fix: change ftr config to let kibana server ask login
Nov 29, 2021
e0dbfe0
fix: ftr tests config fix
Nov 29, 2021
67d0d6c
refactor: remove labels, move test runner to separate file
Nov 30, 2021
b15fcb5
[Perf] move performance test scripts to own files
Dec 1, 2021
d2bb2cc
[Perf] add sleeps to server starts
Dec 1, 2021
aca36a8
[Perf] Fix run tests in parallel
Dec 1, 2021
93ebbc2
Merge branch 'main' of github.com:elastic/kibana into 2021-11-25-synt…
Dec 1, 2021
5704c08
Merge branch 'main' of github.com:elastic/kibana into 2021-11-25-synt…
Dec 2, 2021
f3e6cb7
ci(.buildkite/pipelines/performance/nightly.yml): swap queue ci-group…
Dec 2, 2021
f76fa49
fix: add c2-60 instance types to sub performance tests
Dec 3, 2021
c3f75da
Merge branch 'main' of github.com:elastic/kibana into 2021-11-25-synt…
Dec 3, 2021
0e57d0d
test: run tests multiple times in single instance with default machin…
Dec 3, 2021
72481c9
ci: add warmup phase to ES in performance tests
Dec 6, 2021
f5b7dfa
Merge branch 'main' of github.com:elastic/kibana into 2021-11-25-synt…
Dec 6, 2021
0e0db3f
fix: replace old config with new config
Dec 6, 2021
81aae99
fix: fix the filename of config
Dec 6, 2021
716f52d
fix: add port number to es start script
Dec 7, 2021
153461b
fix: add sleep before continuing
Dec 7, 2021
10a82e1
fix: move cd command after es script
Dec 7, 2021
9e6464f
remove network binding
Dec 7, 2021
e4d7a77
broken build
Dec 8, 2021
4446d0d
increase timeout of page selectors
Dec 8, 2021
b04a6f7
make ci jobs faster
Dec 8, 2021
3e3f721
fix performance tests
Dec 8, 2021
18dbca8
change agent queues to n2-4
Dec 9, 2021
94c1cd1
change performance test agents to n2-4
Dec 9, 2021
b663b80
change n2-4 queue to c2-16 for build kibana job
Dec 9, 2021
4ab0d20
increase concurrency of performance-test-group
Dec 9, 2021
89851cc
add performance phase global label & change queue
Dec 13, 2021
6d0c3a7
disable cache in webdriver using env variable
Dec 14, 2021
0dfba3d
add setCacheDisabled to webdriver
Dec 14, 2021
0119f20
Merge branch 'main' of github.com:elastic/kibana into 2021-11-25-synt…
Dec 15, 2021
05af355
replace current network profiles with new one
Dec 15, 2021
20f761c
log home page navigation time
Dec 15, 2021
6ca43be
increase timeouts in home page navigation
Dec 15, 2021
93b1e64
fix log statements in login method
Dec 15, 2021
bfe18af
add network throttling profile name to global labels
Dec 17, 2021
1d01d23
run synthetics tests with ES warmup
Dec 17, 2021
9ab68c0
rename reporters in performance tests(ftr)
Dec 17, 2021
bb86c46
run synthetics tests x10 times
Dec 17, 2021
df73226
add performancePhase,networkThrottlingProfile labels
Dec 17, 2021
1e374d6
increase concurrency of synthetics tests and change agents
Dec 17, 2021
0088a34
add network throttling and disable cache in synthetics tests
Dec 17, 2021
a7d18de
fix: add before hook to home.ts perf tests
Dec 20, 2021
635f9c2
Merge branch 'main' of github.com:elastic/kibana into 2021-11-25-synt…
Dec 20, 2021
b1c4831
accept cdpSession from param rather than creating in test context
Dec 21, 2021
40292e7
test with only one warmup
Dec 21, 2021
ac8960e
run tests inside a test phases only once
Dec 21, 2021
26746bf
reduce download/upload throughput 6 times
Dec 21, 2021
96ccf63
change before with beforeAll
Dec 21, 2021
9523fee
add cdp methods inside steps
Dec 21, 2021
e4fd740
playwright tests
Dec 27, 2021
3a3c65d
add slower network profile
Dec 27, 2021
ceeaf9c
remove wait for navigation
Dec 27, 2021
24caf56
clear browser cache in each run
Dec 27, 2021
10f20bc
add network profiles
Dec 27, 2021
52e95d8
add page.route() to disable http caching
Dec 28, 2021
2a81b1a
add sleeps before each user interaction
Dec 28, 2021
ccbf85f
make performance tests more user-centric
Dec 29, 2021
0bde91f
remove ftr and synthetics tests & scripts
Dec 29, 2021
f7ec8e9
revert performance benchmark of navigation to home
Dec 30, 2021
f5a443a
remove ftr and synthetics performance tests from functional tests
Dec 30, 2021
6d1460e
remove local notifications from tasks.ts
Dec 30, 2021
0f525ce
rename performance test related env vars
Dec 30, 2021
16032a0
Merge branch 'main' of github.com:elastic/kibana into 2021-11-25-synt…
Dec 30, 2021
4778a08
reduce the amount of env vars for playwright performance tests and ma…
Jan 4, 2022
2441674
Merge branch 'main' into 2021-11-25-synthetics-perf-test-login-and-ho…
kibanamachine Jan 11, 2022
8f334a0
[refactor] prefix environment variables with TEST
Jan 12, 2022
4470336
Merge branch '2021-11-25-synthetics-perf-test-login-and-home-page' of…
Jan 12, 2022
1730c8d
Merge branch 'main' into 2021-11-25-synthetics-perf-test-login-and-ho…
kibanamachine Jan 18, 2022
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
8 changes: 4 additions & 4 deletions .buildkite/pipelines/performance/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ steps:
key: "performance-test-iteration-count"
hint: "How many times you want to run tests? "
required: true
if: build.env('ITERATION_COUNT_ENV') == null
if: build.env('PERF_TEST_COUNT') == null

- label: ":male-mechanic::skin-tone-2: Pre-Build"
command: .buildkite/scripts/lifecycle/pre_build.sh
Expand All @@ -19,10 +19,10 @@ steps:
queue: c2-16
key: build

- label: ":muscle: Performance Tests"
command: .buildkite/scripts/steps/functional/performance.sh
- label: ":muscle: Performance Tests with Playwright config"
command: .buildkite/scripts/steps/functional/performance_playwright.sh
agents:
queue: ci-group-6
queue: c2-16
depends_on: build

- wait: ~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

set -uo pipefail

if [ -z "${ITERATION_COUNT_ENV+x}" ]; then
ITERATION_COUNT="$(buildkite-agent meta-data get performance-test-iteration-count)"
if [ -z "${PERF_TEST_COUNT+x}" ]; then
TEST_COUNT="$(buildkite-agent meta-data get performance-test-iteration-count)"
else
ITERATION_COUNT=$ITERATION_COUNT_ENV
TEST_COUNT=$PERF_TEST_COUNT
fi

tput setab 2; tput setaf 0; echo "Performance test will be run at ${BUILDKITE_BRANCH} ${ITERATION_COUNT} times"
tput setab 2; tput setaf 0; echo "Performance test will be run at ${BUILDKITE_BRANCH} ${TEST_COUNT} times"

cat << EOF | buildkite-agent pipeline upload
steps:
tylersmalley marked this conversation as resolved.
Show resolved Hide resolved
- command: .buildkite/scripts/steps/functional/performance_sub.sh
parallelism: "$ITERATION_COUNT"
- command: .buildkite/scripts/steps/functional/performance_sub_playwright.sh
parallelism: "$TEST_COUNT"
concurrency: 20
concurrency_group: 'performance-test-group'
agents:
queue: c2-16
EOF


Expand Down
17 changes: 0 additions & 17 deletions .buildkite/scripts/steps/functional/performance_sub.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/common/util.sh

.buildkite/scripts/bootstrap.sh
.buildkite/scripts/download_build_artifacts.sh

echo --- Run Performance Tests with Playwright config

node scripts/es snapshot&

esPid=$!

export PERF_TEST_PHASE=WARMUP
export TEST_ES_URL=http://elastic:changeme@localhost:9200
export DONT_START_ES=true
export DISABLE_APM=true

sleep 120

cd "$XPACK_DIR"

# warmup round 1
checks-reporter-with-killswitch "Run Performance Tests with Playwright Config (Phase: WARMUP)" \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \
--config "test/performance/config.playwright.ts";

export DISABLE_APM=false
export PERF_TEST_PHASE=TEST

checks-reporter-with-killswitch "Run Performance Tests with Playwright Config (Phase: TEST)" \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \
--config "test/performance/config.playwright.ts";

kill "$esPid"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@
"pbf": "3.2.1",
"pirates": "^4.0.1",
"pixelmatch": "^5.1.0",
"playwright": "^1.17.1",
"postcss": "^7.0.32",
"postcss-loader": "^3.0.0",
"postcss-prefix-selector": "^1.7.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/kbn-test/src/functional_tests/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export async function runTests(options: RunTestsParams) {

let es;
try {
es = await runElasticsearch({ config, options: { ...options, log } });
if (process.env.DONT_START_ES !== 'true') {
suchcodemuchwow marked this conversation as resolved.
Show resolved Hide resolved
es = await runElasticsearch({ config, options: { ...options, log } });
}
await runKibanaServer({ procs, config, options });
await runFtr({ configPath, options: { ...options, log } });
} finally {
Expand Down
22 changes: 5 additions & 17 deletions test/functional/services/remote/network_profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,11 @@ interface NetworkOptions {
LATENCY: number;
}

const sec = 1_000;
const kB = 1024;
const sec = 10 ** 3;
const MBps = 10 ** 6 / 8; // megabyte per second (MB/s) (can be abbreviated as MBps)

// Download (kb/s) Upload (kb/s) Latency (ms)
// https://gist.github.com/theodorosploumis/fd4086ee58369b68aea6b0782dc96a2e
// Selenium uses B/s (bytes) for network throttling
// Download (B/s) Upload (B/s) Latency (ms)
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 },
CLOUD_USER: { DOWNLOAD: 6 * MBps, UPLOAD: 6 * MBps, LATENCY: 0.1 * sec },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone know why we removed these? I was looking for a way to throttle during a functional test to confirm a loading theory. Seems like this might have worked and I was about to add 3G_SLOW back. But maybe I shouldn't?

Copy link
Contributor

@spalger spalger Jun 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed them because they were inaccurate and finding information that accurately describes the speeds used by the browser profiles was really hard, so we punted on it and only worried about the profile that we actually use.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. #135103 has the snippet I ended up using instead (to slow a test down enough to fail). Maybe this sort of thing would be better as a helper rather than webdriver-init-time setting 🤔

};
19 changes: 16 additions & 3 deletions test/functional/services/remote/webdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const headlessBrowser: string = process.env.TEST_BROWSER_HEADLESS as string;
const browserBinaryPath: string = process.env.TEST_BROWSER_BINARY_PATH as string;
const remoteDebug: string = process.env.TEST_REMOTE_DEBUG as string;
const certValidation: string = process.env.NODE_TLS_REJECT_UNAUTHORIZED as string;
const noCache: string = process.env.DISABLE_CACHE as string;
suchcodemuchwow marked this conversation as resolved.
Show resolved Hide resolved
const SECOND = 1000;
const MINUTE = 60 * SECOND;
const NO_QUEUE_COMMANDS = ['getLog', 'getStatus', 'newSession', 'quit'];
Expand Down Expand Up @@ -118,6 +119,11 @@ function initChromiumOptions(browserType: Browsers, acceptInsecureCerts: boolean
options.setChromeBinaryPath(browserBinaryPath);
}

if (noCache === '1') {
options.addArguments('disk-cache-size', '0');
options.addArguments('disk-cache-dir', '/dev/null');
}

const prefs = new logging.Preferences();
prefs.setLevel(logging.Type.BROWSER, logging.Level.ALL);
options.setUserPreferences(chromiumUserPrefs);
Expand Down Expand Up @@ -291,12 +297,12 @@ async function attemptToCreateCommand(
const { session, consoleLog$ } = await buildDriverInstance();

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

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

const {
DOWNLOAD: downloadThroughput,
Expand All @@ -306,9 +312,16 @@ async function attemptToCreateCommand(

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

if (noCache) {
// @ts-expect-error
await session.sendDevToolsCommand('Network.setCacheDisabled', {
cacheDisabled: true,
});
}

// @ts-expect-error
session.setNetworkConditions({
offline: false,
Expand Down
1 change: 0 additions & 1 deletion x-pack/scripts/functional_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ const onlyNotInCoverageTests = [
require.resolve('../test/saved_object_tagging/api_integration/security_and_spaces/config.ts'),
require.resolve('../test/saved_object_tagging/api_integration/tagging_api/config.ts'),
require.resolve('../test/examples/config.ts'),
require.resolve('../test/performance/config.ts'),
require.resolve('../test/functional_execution_context/config.ts'),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ import { FtrConfigProviderContext } from '@kbn/test';
import { services } from './services';
import { pageObjects } from './page_objects';

// These "secret" values are intentionally written in the source. We would make the APM server accept annonymous traffic if we could
// These "secret" values are intentionally written in the source. We would make the APM server accept anonymous traffic if we could
const APM_SERVER_URL = 'https://2fad4006bf784bb8a54e52f4a5862609.apm.us-west1.gcp.cloud.es.io:443';
const APM_PUBLIC_TOKEN = 'Q5q5rWQEw6tKeirBpw';

export default async function ({ readConfigFile }: FtrConfigProviderContext) {
const functionalConfig = await readConfigFile(require.resolve('../functional/config'));

const testFiles = [require.resolve('./tests/playwright/home.ts')];

return {
testFiles: [require.resolve('./tests/index.ts')],
testFiles,
services,
pageObjects,
servers: functionalConfig.get('servers'),
Expand All @@ -31,21 +33,15 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
kbnTestServer: {
...functionalConfig.get('kbnTestServer'),
env: {
ELASTIC_APM_ACTIVE: 'true',
ELASTIC_APM_ACTIVE: process.env.DISABLE_APM === 'true' ? 'false' : 'true',
suchcodemuchwow marked this conversation as resolved.
Show resolved Hide resolved
ELASTIC_APM_CONTEXT_PROPAGATION_ONLY: 'false',
ELASTIC_APM_ENVIRONMENT: process.env.CI ? 'ci' : 'development',
ELASTIC_APM_TRANSACTION_SAMPLE_RATE: '1.0',
ELASTIC_APM_SERVER_URL: APM_SERVER_URL,
ELASTIC_APM_SECRET_TOKEN: APM_PUBLIC_TOKEN,
ELASTIC_APM_GLOBAL_LABELS: Object.entries({
ftrConfig: `x-pack/test/performance`,
jenkinsJobName: process.env.JOB_NAME,
jenkinsBuildNumber: process.env.BUILD_NUMBER,
prId: process.env.PR_NUMBER,
branch: process.env.GIT_BRANCH,
commit: process.env.GIT_COMMIT,
mergeBase: process.env.PR_MERGE_BASE,
targetBranch: process.env.PR_TARGET_BRANCH,
ftrConfig: `x-pack/test/performance/tests/config.playwright`,
performancePhase: process.env.PERF_TEST_PHASE,
})
.filter(([, v]) => !!v)
.reduce((acc, [k, v]) => (acc ? `${acc},${k}=${v}` : `${k}=${v}`), ''),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

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

export default function ({ getService, getPageObject }: FtrProviderContext) {
const retry = getService('retry');
Expand Down
25 changes: 0 additions & 25 deletions x-pack/test/performance/tests/home.ts

This file was deleted.

16 changes: 0 additions & 16 deletions x-pack/test/performance/tests/index.ts

This file was deleted.

55 changes: 55 additions & 0 deletions x-pack/test/performance/tests/playwright/home.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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 Url from 'url';
import { ChromiumBrowser, Page } from 'playwright';
import testSetup from './setup';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService }: FtrProviderContext) {
describe('perf_login_and_home', () => {
const config = getService('config');
const kibanaUrl = Url.format({
protocol: config.get('servers.kibana.protocol'),
hostname: config.get('servers.kibana.hostname'),
port: config.get('servers.kibana.port'),
});

let page: Page | null = null;
let browser: ChromiumBrowser | null = null;

before(async () => {
const context = await testSetup();
page = context.page;
browser = context.browser;
});

after(async () => {
await browser?.close();
});

it('Go to Kibana login page', async () => {
await page?.goto(`${kibanaUrl}`);
});

it('Login to Kibana', async () => {
const usernameLocator = page?.locator('[data-test-subj=loginUsername]');
const passwordLocator = page?.locator('[data-test-subj=loginPassword]');
const submitButtonLocator = page?.locator('[data-test-subj=loginSubmit]');

await usernameLocator?.type('elastic', { delay: 500 });
await passwordLocator?.type('changeme', { delay: 500 });
await submitButtonLocator?.click({ delay: 1000 });
});

it('Dismiss Welcome Screen', async () => {
await page?.waitForLoadState();
const skipButtonLocator = page?.locator('[data-test-subj=skipWelcomeScreen]');
await skipButtonLocator?.click({ delay: 1000 });
await page?.waitForLoadState('networkidle');
});
});
}
Loading