File tree Expand file tree Collapse file tree 6 files changed +63
-4
lines changed
Expand file tree Collapse file tree 6 files changed +63
-4
lines changed Original file line number Diff line number Diff line change @@ -82,5 +82,5 @@ etc/.rosalution-db-backups
8282* .csv
8383
8484secrets.file
85-
86- profile.html
85+ profile.html
86+ ** benchmark-run ** /
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ services:
5959 - ./backend:/app
6060 environment :
6161 - MONGODB_HOST=rosalution-db
62+ - PROFILER_ENABLED=True
6263 command : ['./etc/entrypoint-init.sh', '--reload']
6364 networks :
6465 - rosalution-network
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # ./bundleBenchmark.sh
3+
4+ usage () {
5+ echo " "
6+ echo " usage: $0 "
7+ echo " "
8+ echo " -p Absolute File Path to Rosalution Backend Service PyInstrument profiling"
9+ echo " -b Absolute File Path to K6 Metrics Summary JSON"
10+ echo " -o Output Directory"
11+ echo " -h Prints usage"
12+ echo " "
13+ echo " "
14+ echo " "
15+ exit
16+ }
17+
18+ while getopts " :p:b:h" opt; do
19+ case $opt in
20+ p) pyinstrument_profiling_summary=" $OPTARG " ;;
21+ b) k6_metrics_summary_json=" $OPTARG " ;;
22+ h) usage;;
23+ \? ) echo " Invalid option -$OPTARG " && exit 127;;
24+ esac
25+ done
26+
27+ if [ ! -f " $pyinstrument_profiling_summary " ]; then
28+ echo " Missing pyinstrument profiling summary"
29+ exit 1
30+ fi
31+
32+ if [ ! -f " $k6_metrics_summary_json " ]; then
33+ echo " Missing k6 benchmark metrics summary"
34+ exit 1
35+ fi
36+
37+ date_stamp=$( date +" %Y-%m-%d-%s" )
38+ output_path=" ./benchmark-run-$date_stamp "
39+
40+ mkdir -p " $output_path "
41+ mv " $pyinstrument_profiling_summary " " $output_path "
42+ mv " $k6_metrics_summary_json " " $output_path "
Original file line number Diff line number Diff line change 1+
2+ export function json_metrics_summary ( data ) {
3+ return JSON . stringify ( data ) ;
4+ }
Original file line number Diff line number Diff line change 44 "description" : " Simple Rosalution REST API benchmarking" ,
55 "license" : " MIT" ,
66 "scripts" : {
7- "benchmark:local:api" : " docker run -v .:/scripts -w /scripts -e BASE_URL=http://backend:8000 --network=rosalution-network --rm grafana/k6:1.5.0 run --secret-source=file=/scripts/secrets.file"
7+ "benchmark:local:api" : " docker run -v .:/scripts -w /scripts -e BASE_URL=http://backend:8000 --network=rosalution-network --rm grafana/k6:1.5.0 run --secret-source=file=/scripts/secrets.file" ,
8+ "bundle:benchmark" : " ./bundleBenchmark.sh -p '../../backend/profile.html' -b './summary.json'"
89 }
910}
Original file line number Diff line number Diff line change @@ -2,13 +2,17 @@ import http from 'k6/http';
22import secrets from 'k6/secrets' ;
33import { sleep , check } from 'k6' ;
44
5+ import { textSummary } from 'https://jslib.k6.io/k6-summary/0.1.0/index.js' ;
6+
7+
58import { rosalutionAuth } from '../config/auth.js' ;
9+ import { json_metrics_summary } from '../config/summary.js' ;
610
711const BASE_URL = __ENV . BASE_URL || 'http://backend:8000'
812
913export const options = {
1014 vus : 10 ,
11- duration : '30s ' ,
15+ duration : '5s ' ,
1216 thresholds : {
1317 http_req_failed : [ 'rate<0.01' ] , // http errors should be less than 1%
1418 http_req_duration : [ 'p(95)<200' ] // 95% of requests should be below 200ms
@@ -26,6 +30,13 @@ export async function setup() {
2630 }
2731}
2832
33+ export function handleSummary ( data ) {
34+ return {
35+ 'summary.json' : json_metrics_summary ( data . metrics ) ,
36+ stdout : textSummary ( data )
37+ } ;
38+ }
39+
2940export default async function ( data ) {
3041 const authHeader = {
3142 headers : {
You canβt perform that action at this time.
0 commit comments