Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 17 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,15 @@ test-smoke: create-dirs ## Run reachability checks (web + APIs) and print a pass
# ---------------------------------------------------------------------
test-web: ## Run Playwright E2E (includes a11y)
@printf "$(BLUE)🌐 Web E2E (Playwright)$(NC)\n"
@cd tests/web && npm test 2>&1 | tee $(abspath $(WEB_LOG)) >/dev/null || { printf "$(RED)❌ Web failed$(NC)\n"; exit 1; }
@cd tests/web && \
if [ ! -x node_modules/.bin/playwright ]; then \
printf "$(YELLOW)⚠️ Playwright not found. Installing deps...$(NC)\n"; \
npm install && npx playwright install --with-deps || npx playwright install; \
fi
@cd tests/web && npm test 2>&1 | tee $(abspath $(WEB_LOG)) || { printf "$(RED)❌ Web failed$(NC)\n"; exit 1; }
@perl -i -pe 's/\e\[[0-9;]*[A-Za-z]//g' $(WEB_LOG) || true
@printf "$(GREEN)βœ… Web passed$(NC)\n"


# ---------------------------------------------------------------------
# πŸ”Œ API Tests (pytest)
# WHY:
Expand Down Expand Up @@ -273,34 +277,17 @@ test-api: ## Run pytest-based API tests with readable per-test summary
test-perf: ## Baseline performance check with real k6 status bar; writes logs & mirrors k6 exit
@printf "$(BLUE)⚑ Baseline Perf (k6) β€” $${K6_VUS:-1} VU β€’ $${K6_DURATION:-60s} run$(NC)\n"
@mkdir -p $(PERF_DIR)
@{ \
K6_LOG_LEVEL=$${K6_LOG_LEVEL:-error} \
K6_PROGRESS=$${K6_PROGRESS:-0} \
K6_VUS=$${K6_VUS:-1} \
K6_DURATION=$${K6_DURATION:-60s} \
K6_TARGET=$${K6_TARGET:-https://jsonplaceholder.typicode.com/posts/1} \
script -q /dev/null k6 run \
--console-output=$(PERF_OUT) \
--summary-export=$(PERF_JSON) \
tests/perf/baseline_perf.js \
2> $(PERF_WARN) | tee $(PERF_STD); \
rc=$${PIPESTATUS[0]}; \
if [ "$$rc" -eq 0 ]; then \
printf "$(GREEN)βœ… Perf passed$(NC)\n"; \
printf "PASS\n" > $(PERF_MARK); \
else \
printf "$(RED)❌ Perf failed (thresholds)$(NC)\n"; \
printf "$(YELLOW)β„Ή Saved warnings: $(PERF_WARN)$(NC)\n"; \
printf "FAIL\n" > $(PERF_MARK); \
if [ -s $(PERF_WARN) ]; then \
printf "\n$(YELLOW)--- warn.log (tail) ---$(NC)\n"; tail -n 20 $(PERF_WARN); \
fi; \
if [ -s $(PERF_OUT) ]; then \
printf "\n$(YELLOW)--- k6-output (tail) ---$(NC)\n"; tail -n 20 $(PERF_OUT); \
fi; \
fi; \
exit $$rc; \
}
@tests/perf/run_k6.sh $(PERF_DIR) || true
@if [ -f "$(PERF_MARK)" ] && grep -q "PASS" "$(PERF_MARK)"; then \
printf "$(GREEN)βœ… Perf passed$(NC)\n"; \
else \
printf "$(RED)❌ Perf failed (thresholds)$(NC)\n"; \
printf "$(YELLOW)β„Ή Saved warnings: $(PERF_WARN)$(NC)\n"; \
[ -s $(PERF_WARN) ] && printf "\n$(YELLOW)--- warn.log (tail) ---$(NC)\n" && tail -n 20 $(PERF_WARN); \
[ -s $(PERF_OUT) ] && printf "\n$(YELLOW)--- k6-output (tail) ---$(NC)\n" && tail -n 20 $(PERF_OUT); \
exit 1; \
fi




Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ testforge/
β”‚ └── smoke_integration.py # Reachability and smoke checks for services
β”œβ”€β”€ perf/ # Performance testing suite (k6)
β”‚ β”œβ”€β”€ baseline_perf.js # k6 micro-benchmark script
β”‚ β”œβ”€β”€ run_k6.sh # Cross-platform runner (macOS uses `script`, CI runs k6 directly)
β”‚ β”œβ”€β”€ perf_gate.py # Performance gate checker enforcing SLOs
β”‚ β”œβ”€β”€ PERF_PLAN.md # Performance testing plan and rationale
β”‚ └── results/ # Performance test results (generated)
β”‚ └── k6-summary.json # k6 test summary with metrics
β”‚ β”œβ”€β”€ k6-export.json # k6 summary exported via --summary-export
β”‚ β”œβ”€β”€ k6-stdout.txt # k6 console output (used by summary parser)
β”‚ β”œβ”€β”€ k6-output.txt # k6 --console-output sink (local runs)
β”‚ β”œβ”€β”€ k6-warn.log # stderr warnings/threshold failures
β”‚ └── .perf_status # PASS/FAIL marker written by runner
└── web/ # Web UI test suite (Playwright)
β”œβ”€β”€ a11y.spec.ts # Accessibility tests using axe-core
β”œβ”€β”€ cart.spec.ts # Cart and sorting behavior tests
Expand Down
Binary file modified sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions tests/perf/run_k6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -euo pipefail

PERF_DIR=${1:-tests/perf/results}
PERF_JSON="$PERF_DIR/k6-export.json"
PERF_OUT="$PERF_DIR/k6-output.txt"
PERF_STD="$PERF_DIR/k6-stdout.txt"
PERF_WARN="$PERF_DIR/k6-warn.log"
PERF_MARK="$PERF_DIR/.perf_status"

mkdir -p "$PERF_DIR"

# Defaults; allow env overrides from Makefile or CI
: "${K6_LOG_LEVEL:=error}"
: "${K6_PROGRESS:=0}"
: "${K6_VUS:=1}"
: "${K6_DURATION:=60s}"
: "${K6_TARGET:=https://jsonplaceholder.typicode.com/posts/1}"

rc=0
if [[ "${CI:-}" == "true" || -n "${GITHUB_ACTIONS:-}" ]]; then
# CI/Linux: run k6 directly (avoid 'script' incompat)
set +e
k6 run \
--summary-export="$PERF_JSON" \
tests/perf/baseline_perf.js \
2> "$PERF_WARN" | tee "$PERF_STD"
rc=${PIPESTATUS[0]}
set -e
else
# macOS/local: preserve live progress bar via BSD 'script'
set +e
script -q /dev/null k6 run \
--console-output="$PERF_OUT" \
--summary-export="$PERF_JSON" \
tests/perf/baseline_perf.js \
2> "$PERF_WARN" | tee "$PERF_STD"
rc=${PIPESTATUS[0]}
set -e
fi

# Mark and exit
if [[ $rc -eq 0 ]]; then
echo "PASS" > "$PERF_MARK"
exit 0
else
echo "FAIL" > "$PERF_MARK"
exit $rc
fi