From be5c76cfc91ceaaed233022982c420809aa6df65 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 24 Jun 2026 12:00:31 +0200 Subject: [PATCH] :construction: Fix warnings --- performance/run.sh | 64 ++++++++++++------- performance/scripts/file-size-matrix.js | 8 --- performance/scripts/font-upload.js | 10 +-- performance/scripts/lifecycle.js | 12 +--- performance/scripts/media-upload.js | 10 +-- .../scripts/workspace-edit-concurrent.js | 8 --- performance/scripts/workspace-edit.js | 10 +-- performance/scripts/workspace-open.js | 8 --- 8 files changed, 46 insertions(+), 84 deletions(-) diff --git a/performance/run.sh b/performance/run.sh index 2b4dc2ac7c..0dd1fdc5f6 100755 --- a/performance/run.sh +++ b/performance/run.sh @@ -30,6 +30,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BASE_URL="${PENPOT_BASE_URL:-http://localhost:6060}" VUS="" ITER="" +DURATION="" REGISTER_MODE="${PENPOT_REGISTER_MODE:-demo}" K6="${K6:-k6}" EDIT_MODE="${PENPOT_EDIT_MODE:-same-file}" @@ -48,30 +49,31 @@ Usage: $(basename "$0") [options] Commands: - smoke 1 VU, 1 iteration smoke test of the lifecycle flow - lifecycle Full user lifecycle (register → CRUD → delete) - workspace-open Read-heavy: repeatedly open a file (get-file, libraries, thumbnails) - workspace-edit Write-heavy: repeatedly edit a file (get-file + update-file loop) - media-upload Upload images of varying sizes (direct + chunked) - font-upload Upload fonts via chunked upload + create-font-variant - concurrent-edit Concurrent editing: same-file or multi-file mode - file-size-matrix Measure latency vs file size (10, 100, 500, 1000 shapes) - compare Compare two k6 JSON results for regression - all Run all scenarios together (orchestrator) - clean Remove test results - help Show this help + smoke 1 VU, 1 iteration smoke test of the lifecycle flow + lifecycle Full user lifecycle (register → CRUD → delete) + workspace-open Read-heavy: repeatedly open a file (get-file, libraries, thumbnails) + workspace-edit Write-heavy: repeatedly edit a file (get-file + update-file loop) + media-upload Upload images of varying sizes (direct + chunked) + font-upload Upload fonts via chunked upload + create-font-variant + concurrent-edit Concurrent editing: same-file or multi-file mode + file-size-matrix Measure latency vs file size (10, 100, 500, 1000 shapes) + compare Compare two k6 JSON results for regression + all Run all scenarios together (orchestrator) + clean Remove test results + help Show this help Options: - -u URL Backend base URL (default: $BASE_URL) - -v NUM Number of virtual users (default: per-script defaults) - -n NUM Iterations per VU (default: per-script defaults) - -m MODE Register mode: 'demo' or 'register' (default: $REGISTER_MODE) - -k PATH Path to k6 binary (default: $K6) + -u URL Backend base URL (default: $BASE_URL) + -v NUM Number of virtual users (default: per-script defaults) + -n NUM Iterations per VU (default: per-script defaults) + -d DURATION Test duration (e.g. 30s, 5m, 2h; default: k6 default) + -m MODE Register mode: 'demo' or 'register' (default: $REGISTER_MODE) + -k PATH Path to k6 binary (default: $K6) Concurrent-edit options: - --mode MODE 'same-file' or 'multi-file' (default: $EDIT_MODE) - --files NUM Number of files for multi-file mode (default: $FILE_COUNT) - --vus-per-file NUM VUs per file for multi-file mode (default: $VUS_PER_FILE) + --mode MODE 'same-file' or 'multi-file' (default: $EDIT_MODE) + --files NUM Number of files for multi-file mode (default: $FILE_COUNT) + --vus-per-file NUM VUs per file for multi-file mode (default: $VUS_PER_FILE) Environment variables: PENPOT_BASE_URL Same as -u @@ -80,10 +82,11 @@ Environment variables: PENPOT_FILE_COUNT Same as --files PENPOT_VUS_PER_FILE Same as --vus-per-file K6 Same as -k + PENPOT_DURATION Same as -d Examples: $(basename "$0") smoke - $(basename "$0") lifecycle -v 10 -n 5 + $(basename "$0") lifecycle -v 5 -n 10 $(basename "$0") workspace-edit -v 20 -n 50 $(basename "$0") media-upload -u https://penpot.example.com $(basename "$0") concurrent-edit --mode same-file -v 5 -n 10 @@ -107,10 +110,16 @@ k6_env_flags() { if [[ -n "${PENPOT_TOTAL_VUS:-}" ]]; then flags="$flags --env PENPOT_TOTAL_VUS=$PENPOT_TOTAL_VUS" fi + if [[ -n "$VUS" ]]; then + flags="$flags --env K6_VUS=$VUS" + fi + if [[ -n "$ITER" ]]; then + flags="$flags --env K6_ITERATIONS=$ITER" + fi echo "$flags" } -# Build k6 VU/iteration flags (only if explicitly set) +# Build k6 VU/iteration/duration flags (only if explicitly set) k6_scale_flags() { local flags="" if [[ -n "$VUS" ]]; then @@ -119,6 +128,9 @@ k6_scale_flags() { if [[ -n "$ITER" ]]; then flags="$flags --iterations $ITER" fi + if [[ -n "$DURATION" ]]; then + flags="$flags --duration $DURATION" + fi echo "$flags" } @@ -362,14 +374,20 @@ parse_opts() { esac done + # Apply PENPOT_DURATION env var as default (before CLI parsing takes precedence) + if [[ -z "$DURATION" && -n "${PENPOT_DURATION:-}" ]]; then + DURATION="$PENPOT_DURATION" + fi + # Now parse short options with getopts set -- "${args[@]}" OPTIND=1 - while getopts "u:v:n:m:k:h" opt; do + while getopts "u:v:n:d:m:k:h" opt; do case "$opt" in u) BASE_URL="$OPTARG" ;; v) VUS="$OPTARG" ;; n) ITER="$OPTARG" ;; + d) DURATION="$OPTARG" ;; m) REGISTER_MODE="$OPTARG" ;; k) K6="$OPTARG" ;; h) usage; exit 0 ;; diff --git a/performance/scripts/file-size-matrix.js b/performance/scripts/file-size-matrix.js index b8903d9e4b..f976216962 100644 --- a/performance/scripts/file-size-matrix.js +++ b/performance/scripts/file-size-matrix.js @@ -30,14 +30,6 @@ const TIERS = [ ]; export const options = { - scenarios: { - file_size_matrix: { - executor: "per-vu-iterations", - vus: 1, - iterations: 1, - maxDuration: "30m", - }, - }, thresholds: { http_req_duration: ["p(95)<10000"], http_req_failed: ["rate<0.01"], diff --git a/performance/scripts/font-upload.js b/performance/scripts/font-upload.js index b8718cf3fa..cc15bed2c9 100644 --- a/performance/scripts/font-upload.js +++ b/performance/scripts/font-upload.js @@ -21,14 +21,6 @@ import { createClient } from "../lib/penpot-client.js"; const BASE_URL = __ENV.PENPOT_BASE_URL || "http://localhost:6060"; export const options = { - scenarios: { - font_upload: { - executor: "per-vu-iterations", - vus: 1, - iterations: 1, - maxDuration: "2m", - }, - }, thresholds: { http_req_duration: ["p(95)<15000"], http_req_failed: ["rate<0.01"], @@ -76,7 +68,7 @@ function assertOk(res, label) { // --------------------------------------------------------------------------- export function setup() { - const vuCount = (options.scenarios.font_upload && options.scenarios.font_upload.vus) || __ENV.K6_VUS || 1; + const vuCount = parseInt(__ENV.K6_VUS) || 1; console.log(`Penpot Font Upload Test`); console.log(` Base URL: ${BASE_URL}`); diff --git a/performance/scripts/lifecycle.js b/performance/scripts/lifecycle.js index de440cb94c..0345abbcf9 100644 --- a/performance/scripts/lifecycle.js +++ b/performance/scripts/lifecycle.js @@ -33,16 +33,8 @@ import { createClient } from "../lib/penpot-client.js"; const BASE_URL = __ENV.PENPOT_BASE_URL || "http://localhost:6060"; -// k6 options — smoke test defaults (1 VU, 1 iteration) +// k6 options — VUs and iterations set via run.sh (--vus, --iterations) export const options = { - scenarios: { - lifecycle: { - executor: "per-vu-iterations", - vus: 1, - iterations: 1, - maxDuration: "2m", - }, - }, thresholds: { http_req_duration: ["p(95)<5000"], http_req_failed: ["rate<0.01"], @@ -127,7 +119,7 @@ function assertOk(res, label) { export function setup() { // Resolve VU count from options or CLI --vus flag - const vuCount = (options.scenarios.lifecycle && options.scenarios.lifecycle.vus) || __ENV.K6_VUS || 1; + const vuCount = parseInt(__ENV.K6_VUS) || 1; console.log(`Penpot Lifecycle Test`); console.log(` Base URL: ${BASE_URL}`); diff --git a/performance/scripts/media-upload.js b/performance/scripts/media-upload.js index 2f26b537d4..b24f10172f 100644 --- a/performance/scripts/media-upload.js +++ b/performance/scripts/media-upload.js @@ -23,14 +23,6 @@ import { createClient } from "../lib/penpot-client.js"; const BASE_URL = __ENV.PENPOT_BASE_URL || "http://localhost:6060"; export const options = { - scenarios: { - media_upload: { - executor: "per-vu-iterations", - vus: 1, - iterations: 1, - maxDuration: "2m", - }, - }, thresholds: { http_req_duration: ["p(95)<10000"], http_req_failed: ["rate<0.01"], @@ -79,7 +71,7 @@ function assertOk(res, label) { // --------------------------------------------------------------------------- export function setup() { - const vuCount = (options.scenarios.media_upload && options.scenarios.media_upload.vus) || __ENV.K6_VUS || 1; + const vuCount = parseInt(__ENV.K6_VUS) || 1; console.log(`Penpot Media Upload Test`); console.log(` Base URL: ${BASE_URL}`); diff --git a/performance/scripts/workspace-edit-concurrent.js b/performance/scripts/workspace-edit-concurrent.js index a54ed4cabc..08adc82314 100644 --- a/performance/scripts/workspace-edit-concurrent.js +++ b/performance/scripts/workspace-edit-concurrent.js @@ -47,14 +47,6 @@ const TOTAL_VUS = EDIT_MODE === "multi-file" : parseInt(__ENV.PENPOT_TOTAL_VUS || "3"); export const options = { - scenarios: { - workspace_edit_concurrent: { - executor: "per-vu-iterations", - vus: TOTAL_VUS, - iterations: EDIT_ITERATIONS, - maxDuration: "10m", - }, - }, thresholds: { http_req_duration: ["p(95)<5000"], http_req_failed: ["rate<0.01"], diff --git a/performance/scripts/workspace-edit.js b/performance/scripts/workspace-edit.js index 19148439a1..95118c9329 100644 --- a/performance/scripts/workspace-edit.js +++ b/performance/scripts/workspace-edit.js @@ -26,14 +26,6 @@ const BASE_URL = __ENV.PENPOT_BASE_URL || "http://localhost:6060"; const EDIT_ITERATIONS = parseInt(__ENV.PENPOT_EDIT_ITERATIONS || "10"); export const options = { - scenarios: { - workspace_edit: { - executor: "per-vu-iterations", - vus: 1, - iterations: 1, - maxDuration: "5m", - }, - }, thresholds: { http_req_duration: ["p(95)<5000"], http_req_failed: ["rate<0.01"], @@ -102,7 +94,7 @@ function makeAddRectChange(pageId, index) { // --------------------------------------------------------------------------- export function setup() { - const vuCount = (options.scenarios.workspace_edit && options.scenarios.workspace_edit.vus) || __ENV.K6_VUS || 1; + const vuCount = parseInt(__ENV.K6_VUS) || 1; console.log(`Penpot Workspace Edit Test`); console.log(` Base URL: ${BASE_URL}`); diff --git a/performance/scripts/workspace-open.js b/performance/scripts/workspace-open.js index 7a2739eb47..2a1fc1ff56 100644 --- a/performance/scripts/workspace-open.js +++ b/performance/scripts/workspace-open.js @@ -28,14 +28,6 @@ const BASE_URL = __ENV.PENPOT_BASE_URL || "http://localhost:6060"; const OPEN_ITERATIONS = parseInt(__ENV.PENPOT_OPEN_ITERATIONS || "5"); export const options = { - scenarios: { - workspace_open: { - executor: "per-vu-iterations", - vus: 1, - iterations: 1, - maxDuration: "2m", - }, - }, thresholds: { http_req_duration: ["p(95)<5000"], http_req_failed: ["rate<0.01"],