forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* object store k6 * update script * refactor * rename scripts * fix paths * fixes * fix client - check connected state * add teardown timeout * rename to grpc object store client * fail if health check fails * abort rather than fail * stale import * create `run.sh` * adjust for dummy server * fix mkdir * clean up dependencies * remove name and version * bring back name and version! * remove clean webpackk plugin * remove copy plugin * update yarn lock * remove stale import * update yarn lock * move perf tests to devenv/docker/loadtest-ts * add codeownres
- Loading branch information
1 parent
10fdfa8
commit 616db7f
Showing
14 changed files
with
3,849 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"presets": [ | ||
"@babel/env", | ||
"@babel/typescript" | ||
], | ||
"plugins": [ | ||
"@babel/proposal-class-properties", | ||
"@babel/proposal-object-rest-spread" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
scripts/tmp | ||
dist/ | ||
.yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Grafana load tests written in typescript - EXPERIMENTAL | ||
|
||
Runs load tests written in typescript and checks Grafana's performance using [k6](https://k6.io/) | ||
|
||
This is **experimental** - please consider adding new tests to devenv/docker/loadtest while we are testing the typescript approach! | ||
|
||
|
||
|
||
# How to run | ||
|
||
``` | ||
yarn install | ||
GRPC_TOKEN={REPLACE_WITH_SERVICE_ACCOUNT_ADMIN_TOKEN} ./run.sh test=object-store-test grpcAddress=127.0.0.1:10000 execution=local | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"private": true, | ||
"license": "Apache-2.0", | ||
"name": "@grafana/perf-tests", | ||
"version": "9.3.0-pre", | ||
"devDependencies": { | ||
"@babel/core": "7.19.0", | ||
"@babel/plugin-proposal-class-properties": "7.18.6", | ||
"@babel/plugin-proposal-object-rest-spread": "7.18.9", | ||
"@babel/preset-env": "7.19.0", | ||
"@babel/preset-typescript": "7.18.6", | ||
"@types/k6": "0.39.0", | ||
"@types/shortid": "0.0.29", | ||
"@types/webpack": "5.28.0", | ||
"babel-loader": "8.2.5", | ||
"shortid": "2.2.16", | ||
"ts-node": "10.9.1", | ||
"typescript": "4.8.2", | ||
"webpack": "5.74.0", | ||
"webpack-cli": "4.10.0", | ||
"webpack-glob-entries": "1.0.1" | ||
}, | ||
"scripts": { | ||
"build": "webpack", | ||
"prepare-testdata": "yarn run prepare-testdata:object-store-test", | ||
"prepare-testdata:object-store-test": "ts-node scripts/prepareDashboardFileNames.ts ../../dev-dashboards ./scripts/tmp/filenames.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env bash | ||
|
||
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 | ||
|
||
declare -A cfg=( | ||
[grpcToken]=$GRPC_TOKEN | ||
[grpcAddress]="127.0.0.1:10000" | ||
[execution]="local" | ||
[test]="object-store-test" | ||
[k6CloudToken]=$K6_CLOUD_TOKEN | ||
) | ||
|
||
for ARGUMENT in "$@" | ||
do | ||
KEY=$(echo $ARGUMENT | cut -f1 -d=) | ||
|
||
KEY_LENGTH=${#KEY} | ||
VALUE="${ARGUMENT:$KEY_LENGTH+1}" | ||
cfg["$KEY"]="$VALUE" | ||
done | ||
|
||
function usage() { | ||
echo "$0 grpcAddress= grpcToken= execution= k6CloudToken= test= | ||
- 'grpcAddress' is the address of Grafana gRPC server. 127.0.0.1:10000 is the default. | ||
- 'grpcToken' is the service account admin token used for Grafana gRPC server authentication. | ||
- 'execution' is the test execution mode; one of 'local', 'cloud-output', 'cloud'. 'local' is the default. | ||
- 'k6CloudToken' is the k6 cloud token required for 'cloud-output' and 'cloud' execution modes. | ||
- 'test' is the filepath of the test to execute relative to ./src, without the extension. example 'object-store-test'" | ||
exit 0 | ||
} | ||
|
||
if [ "${cfg[grpcToken]}" == "" ]; then | ||
usage | ||
fi | ||
|
||
|
||
if [ "${cfg[execution]}" == "cloud" ]; then | ||
echo "cloud execution mode is not yet implemented" | ||
exit 0 | ||
elif [ "${cfg[execution]}" == "cloud-output" ]; then | ||
if [ "${cfg[k6CloudToken]}" == "" ]; then | ||
usage | ||
fi | ||
elif [ "${cfg[execution]}" != "local" ]; then | ||
usage | ||
fi | ||
|
||
yarn run build | ||
yarn run prepare-testdata | ||
|
||
TEST_PATH="./dist/${cfg[test]}.js" | ||
echo "$(date '+%Y-%m-%d %H:%M:%S'): Executing test ${TEST_PATH} in ${cfg[execution]} mode" | ||
|
||
if [ "${cfg[execution]}" == "cloud-output" ]; then | ||
GRPC_TOKEN="${cfg[grpcToken]}" GRPC_ADDRESS="${cfg[grpcAddress]}" K6_CLOUD_TOKEN="${cfg[k6CloudToken]}" k6 run --out cloud "$TEST_PATH" | ||
elif [ "${cfg[execution]}" == "local" ]; then | ||
GRPC_TOKEN="${cfg[grpcToken]}" GRPC_ADDRESS="${cfg[grpcAddress]}" k6 run "$TEST_PATH" | ||
fi | ||
|
||
|
24 changes: 24 additions & 0 deletions
24
devenv/docker/loadtest-ts/scripts/prepareDashboardFileNames.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { readdirSync, writeFileSync, mkdirSync } from 'fs'; | ||
import { dirname, resolve } from 'path'; | ||
|
||
const args = process.argv.slice(2); | ||
|
||
if (args.length !== 2) { | ||
throw new Error('expected dev dashboards dir and the output file path'); | ||
} | ||
|
||
const devDashboardsDir = args[0]; | ||
const outputFilePath = args[1]; | ||
|
||
const getFiles = (dirPath: string, ext?: string): string[] => | ||
readdirSync(dirPath, { withFileTypes: true }) | ||
.flatMap((dirEntry) => { | ||
const res = resolve(dirPath, dirEntry.name); | ||
return dirEntry.isDirectory() ? getFiles(res) : res; | ||
}) | ||
.filter((path) => (ext?.length ? path.endsWith(ext) : true)); | ||
|
||
const files = getFiles(devDashboardsDir, '.json'); | ||
|
||
mkdirSync(dirname(outputFilePath), { recursive: true }); | ||
writeFileSync(outputFilePath, JSON.stringify(files, null, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
const testDash = { | ||
annotations: { list: [] }, | ||
editable: true, | ||
fiscalYearStartMonth: 0, | ||
graphTooltip: 0, | ||
id: 100, | ||
links: [], | ||
liveNow: false, | ||
panels: [ | ||
{ | ||
datasource: { | ||
type: 'testdata', | ||
uid: 'testdata', | ||
}, | ||
fieldConfig: { | ||
defaults: { | ||
color: { | ||
mode: 'thresholds', | ||
}, | ||
custom: { | ||
align: 'auto', | ||
displayMode: 'auto', | ||
inspect: false, | ||
}, | ||
mappings: [], | ||
thresholds: { | ||
mode: 'absolute', | ||
steps: [ | ||
{ | ||
color: 'green', | ||
value: null, | ||
}, | ||
{ | ||
color: 'red', | ||
value: 80, | ||
}, | ||
], | ||
}, | ||
}, | ||
overrides: [], | ||
}, | ||
gridPos: { | ||
h: 9, | ||
w: 12, | ||
x: 0, | ||
y: 0, | ||
}, | ||
id: 2, | ||
options: { | ||
footer: { | ||
fields: '', | ||
reducer: ['sum'], | ||
show: false, | ||
}, | ||
showHeader: true, | ||
}, | ||
pluginVersion: '9.3.0-pre', | ||
targets: [ | ||
{ | ||
csvContent: '', | ||
datasource: { | ||
type: 'testdata', | ||
uid: 'PD8C576611E62080A', | ||
}, | ||
refId: 'A', | ||
scenarioId: 'csv_content', | ||
}, | ||
], | ||
title: 'Panel Title', | ||
type: 'table', | ||
}, | ||
], | ||
schemaVersion: 37, | ||
style: 'dark', | ||
tags: [], | ||
templating: { | ||
list: [], | ||
}, | ||
time: { | ||
from: 'now-6h', | ||
to: 'now', | ||
}, | ||
timepicker: {}, | ||
timezone: '', | ||
title: 'New dashboard', | ||
uid: '5v6e5VH4z', | ||
version: 1, | ||
weekStart: '', | ||
} as const; | ||
|
||
const getCsvContent = (lengthInKb: number): string => { | ||
const lines: string[] = ['id,name']; | ||
for (let i = 0; i < lengthInKb; i++) { | ||
const prefix = `${i},`; | ||
lines.push(prefix + 'a'.repeat(1024 - prefix.length)); | ||
} | ||
return lines.join('\n'); | ||
}; | ||
|
||
export const prepareDashboard = (lengthInKb: number): Record<string, unknown> => { | ||
const firstPanel = testDash.panels[0]; | ||
return { | ||
...testDash, | ||
panels: [ | ||
{ | ||
...firstPanel, | ||
targets: [ | ||
{ | ||
...firstPanel.targets[0], | ||
csvContent: getCsvContent(lengthInKb), | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
}; |
Oops, something went wrong.