Live: performance tests e2e part (#43915)

* #41993: live perf tests e2e part

* #41993: added bash upgrade instructions

* #41993: remove custom feature toggle

* #41993: fix typo in 'integrationFolder'
This commit is contained in:
Artur Wierzbicki
2022-01-12 22:15:29 +04:00
committed by GitHub
parent 0c88b39162
commit e01ac44cfa
23 changed files with 1099 additions and 30 deletions
@@ -0,0 +1,399 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 82,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "grafana",
"uid": "grafana"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 10,
"maxDataPoints": 1500,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"channel": "plugin/testdata/random-20Hz-stream-5",
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"queryType": "measurements",
"refId": "A"
}
],
"title": "5",
"type": "timeseries"
},
{
"datasource": {
"type": "grafana",
"uid": "grafana"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 0
},
"id": 6,
"maxDataPoints": 1500,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"channel": "plugin/testdata/random-20Hz-stream-2",
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"queryType": "measurements",
"refId": "A"
}
],
"title": "2",
"type": "timeseries"
},
{
"datasource": {
"type": "grafana",
"uid": "grafana"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 8,
"maxDataPoints": 1500,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"channel": "plugin/testdata/random-20Hz-stream-4",
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"queryType": "measurements",
"refId": "A"
}
],
"title": "4",
"type": "timeseries"
},
{
"datasource": {
"type": "grafana",
"uid": "grafana"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 3,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 12,
"y": 8
},
"id": 2,
"maxDataPoints": 1500,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "none"
}
},
"targets": [
{
"buffer": 60000,
"channel": "plugin/testdata/random-20Hz-stream",
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"filter": {
"fields": []
},
"queryType": "measurements",
"refId": "A"
}
],
"title": "1",
"transparent": true,
"type": "timeseries"
}
],
"refresh": "",
"schemaVersion": 33,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-60s",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Grafana Live performance benchmarking",
"uid": "S4M5r9cnk",
"version": 9,
"weekStart": ""
}
+41
View File
@@ -0,0 +1,41 @@
import { e2e } from '@grafana/e2e';
type WithGrafanaRuntime<T> = T & {
grafanaRuntime: {
livePerformance: {
start: () => void;
getStats: () => Record<string, unknown>;
};
};
};
const hasGrafanaRuntime = <T>(obj: T): obj is WithGrafanaRuntime<T> => {
return typeof (obj as any)?.grafanaRuntime === 'object';
};
e2e.benchmark({
name: 'Live performance benchmarking - 4x20hz panels',
dashboard: {
folder: '/dashboards/live',
delayAfterOpening: 1000,
skipPanelValidation: true,
},
repeat: 10,
duration: 120000,
appStats: {
startCollecting: (window) => {
if (!hasGrafanaRuntime(window)) {
return;
}
return window.grafanaRuntime.livePerformance.start();
},
collect: (window) => {
if (!hasGrafanaRuntime(window)) {
return {};
}
return window.grafanaRuntime.livePerformance.getStats() ?? {};
},
},
});
+5
View File
@@ -0,0 +1,5 @@
{
"extends": "../../tsconfig.json",
"include": ["**/*.ts", "../../packages/grafana-e2e/cypress/support/index.d.ts"],
"resolveJsonModule": true
}
+2
View File
@@ -0,0 +1,2 @@
[feature_toggles]
enable =
+65 -11
View File
@@ -1,8 +1,14 @@
#!/bin/bash
#!/usr/bin/env bash
set -xeo pipefail
. e2e/variables
if ((BASH_VERSINFO[0] < 4)); then
echo "Bash ver >= 4 is needed to run this script"
echo "Please upgrade your bash - run 'brew install bash' if you use Homebrew on MacOS"
exit 1;
fi
HOST=${HOST:-$DEFAULT_HOST}
PORT=${PORT:-$DEFAULT_PORT}
@@ -12,31 +18,79 @@ args=("$@")
CMD="start"
PARAMS=""
SLOWMO=0
URL=${BASE_URL:-"http://$HOST:$PORT"}
integrationFolder=../../e2e
testFiles=*-suite/*spec.ts
declare -A env=(
[BASE_URL]=${BASE_URL:-"http://$HOST:$PORT"}
[SLOWMO]=0
)
testFilesForSingleSuite="*.spec.ts"
declare -A cypressConfig=(
[integrationFolder]=../../e2e
[screenshotsFolder]=../../e2e/"${args[0]}"/screenshots
[videosFolder]=../../e2e/"${args[0]}"/videos
[fileServerFolder]=./cypress
[testFiles]=*-suite/*spec.ts
[defaultCommandTimeout]=30000
[viewportWidth]=1920
[viewportHeight]=1080
[trashAssetsBeforeRuns]=false
[videoUploadOnPasses]=false
)
cd packages/grafana-e2e
case "$1" in
case "$1" in
"debug")
echo -e "Debug mode"
SLOWMO=1
env[SLOWMO]=1
PARAMS="--no-exit"
;;
"dev")
echo "Dev mode"
CMD="open"
;;
"benchmark")
echo "Benchmark"
PARAMS="--headed"
CMD="start-benchmark"
env[BENCHMARK_PLUGIN_ENABLED]=true
env[BENCHMARK_PLUGIN_RESULTS_FOLDER]=../../e2e/benchmarks/"${args[1]}"/results
cypressConfig[video]=false
cypressConfig[integrationFolder]=../../e2e/benchmarks/"${args[1]}"
cypressConfig[screenshotsFolder]=../../e2e/benchmarks/"${args[1]}"/screenshots
cypressConfig[testFiles]=$testFilesForSingleSuite
;;
"")
;;
*)
integrationFolder=../../e2e/"${args[0]}"
testFiles="*.spec.ts"
cypressConfig[integrationFolder]=../../e2e/"${args[0]}"
cypressConfig[testFiles]=$testFilesForSingleSuite
;;
esac
yarn $CMD --env BASE_URL=$URL,SLOWMO=$SLOWMO \
--config defaultCommandTimeout=30000,testFiles=$testFiles,integrationFolder=$integrationFolder,screenshotsFolder=../../e2e/"${args[0]}"/screenshots,videosFolder=../../e2e/"${args[0]}"/videos,fileServerFolder=./cypress,viewportWidth=1920,viewportHeight=1080,trashAssetsBeforeRuns=false,videoUploadOnPasses=false \
function join () {
local -n map=$1
local delimiter=","
local res=""
for key in "${!map[@]}"
do
value=${map[$key]}
if [ -z "${res}" ]; then
res=$key=$value
else
res=$res$delimiter$key=$value
fi
done
echo "$res"
}
yarn $CMD --env "$(join env)" \
--config "$(join cypressConfig)" \
$PARAMS
+1
View File
@@ -36,6 +36,7 @@ else
mkdir $PROV_DIR/datasources
mkdir $PROV_DIR/dashboards
cp ./e2e/custom.ini $RUNDIR/conf/custom.ini
cp ./conf/defaults.ini $RUNDIR/conf/defaults.ini
fi