fix: BusyBox-compatible timing and set -e safety in shell scripts
This commit is contained in:
@ -30,7 +30,7 @@ mv "$TEMP_CHANGELOG" debian/changelog
|
|||||||
echo "[2/5] debian/changelog: Added entry for $NEW_VERSION"
|
echo "[2/5] debian/changelog: Added entry for $NEW_VERSION"
|
||||||
|
|
||||||
# 3. debian/control - Update Version field
|
# 3. debian/control - Update Version field
|
||||||
if grep -q "^Version:" debian/control 2>/dev/null; then
|
if grep -q "^Version:" debian/control 2>/dev/null || true; then
|
||||||
sed -i "s/^Version: .*/Version: $NEW_VERSION-1/" debian/control
|
sed -i "s/^Version: .*/Version: $NEW_VERSION-1/" debian/control
|
||||||
echo "[3/5] debian/control: -> $NEW_VERSION-1"
|
echo "[3/5] debian/control: -> $NEW_VERSION-1"
|
||||||
else
|
else
|
||||||
@ -71,7 +71,7 @@ fi
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Stale references check:"
|
echo "Stale references check:"
|
||||||
grep -r "$OLD_VERSION" --include='*.toml' --include='*.sh' --include='*.json' --include='control' . 2>/dev/null | grep -v 'target/' | grep -v '.git/' | grep -v 'node_modules/' | grep -v 'bump-version.sh' || echo " No stale references found"
|
grep -r "$OLD_VERSION" --include='*.toml' --include='*.sh' --include='*.json' --include='control' . 2>/dev/null || true | grep -v 'target/' | grep -v '.git/' | grep -v 'node_modules/' | grep -v 'bump-version.sh' || echo " No stale references found"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Next steps:"
|
echo "Next steps:"
|
||||||
|
|||||||
@ -15,6 +15,13 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# BusyBox-compatible millisecond timing (_now_ms not available)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
_now_ms() {
|
||||||
|
python3 -c "import time; print(int(time.time()*1000))"
|
||||||
|
}
|
||||||
|
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
YELLOW='\033[1;33m'
|
YELLOW='\033[1;33m'
|
||||||
@ -72,10 +79,10 @@ api_call() {
|
|||||||
time_api_call() {
|
time_api_call() {
|
||||||
local method="$1" endpoint="$2" shift; shift
|
local method="$1" endpoint="$2" shift; shift
|
||||||
local start end elapsed
|
local start end elapsed
|
||||||
start=$(date +%s%N)
|
start=$(_now_ms)
|
||||||
api_call "${method}" "${endpoint}" -o /dev/null "$@" 2>/dev/null || true
|
api_call "${method}" "${endpoint}" -o /dev/null "$@" 2>/dev/null || true
|
||||||
end=$(date +%s%N)
|
end=$(_now_ms)
|
||||||
elapsed=$(( (end - start) / 1000000 )) # milliseconds
|
elapsed=$(( end - start )) # milliseconds
|
||||||
echo "$(echo "scale=3; ${elapsed}/1000" | bc)"
|
echo "$(echo "scale=3; ${elapsed}/1000" | bc)"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,10 +104,10 @@ test_dashboard_load() {
|
|||||||
|
|
||||||
# Also measure frontend static asset load
|
# Also measure frontend static asset load
|
||||||
info "Measuring frontend index.html load time..."
|
info "Measuring frontend index.html load time..."
|
||||||
start=$(date +%s%N)
|
start=$(_now_ms)
|
||||||
curl -sk -o /dev/null "${BASE_URL}/" 2>/dev/null || true
|
curl -sk -o /dev/null "${BASE_URL}/" 2>/dev/null || true
|
||||||
end=$(date +%s%N)
|
end=$(_now_ms)
|
||||||
elapsed=$(( (end - start) / 1000000 ))
|
elapsed=$(( end - start ))
|
||||||
FRONTEND_TIME=$(echo "scale=3; ${elapsed}/1000" | bc)
|
FRONTEND_TIME=$(echo "scale=3; ${elapsed}/1000" | bc)
|
||||||
info "Frontend load time: ${FRONTEND_TIME}s"
|
info "Frontend load time: ${FRONTEND_TIME}s"
|
||||||
pass "Frontend static load: ${FRONTEND_TIME}s"
|
pass "Frontend static load: ${FRONTEND_TIME}s"
|
||||||
@ -169,14 +176,14 @@ test_bulk_host_operations() {
|
|||||||
|
|
||||||
# 4.2 Sequential host creation (measure throughput)
|
# 4.2 Sequential host creation (measure throughput)
|
||||||
info "4.2 Sequential host creation (10 hosts)"
|
info "4.2 Sequential host creation (10 hosts)"
|
||||||
local start=$(date +%s%N)
|
local start=$(_now_ms)
|
||||||
for i in $(seq 1 10); do
|
for i in $(seq 1 10); do
|
||||||
api_call POST /api/v1/hosts \
|
api_call POST /api/v1/hosts \
|
||||||
-d "{\"fqdn\": \"perf-test-${i}.example.com\", \"ip_address\": \"10.99.0.${i}\"}" \
|
-d "{\"fqdn\": \"perf-test-${i}.example.com\", \"ip_address\": \"10.99.0.${i}\"}" \
|
||||||
-o /dev/null 2>/dev/null || true
|
-o /dev/null 2>/dev/null || true
|
||||||
done
|
done
|
||||||
local end=$(date +%s%N)
|
local end=$(_now_ms)
|
||||||
local total_ms=$(( (end - start) / 1000000 ))
|
local total_ms=$(( end - start ))
|
||||||
local total_s=$(echo "scale=3; ${total_ms}/1000" | bc)
|
local total_s=$(echo "scale=3; ${total_ms}/1000" | bc)
|
||||||
local per_host=$(echo "scale=3; ${total_s}/10" | bc)
|
local per_host=$(echo "scale=3; ${total_s}/10" | bc)
|
||||||
info "10 hosts created in ${total_s}s (${per_host}s per host)"
|
info "10 hosts created in ${total_s}s (${per_host}s per host)"
|
||||||
@ -199,11 +206,11 @@ test_cidr_scan() {
|
|||||||
# Note: This test initiates a real CIDR scan which may not complete quickly
|
# Note: This test initiates a real CIDR scan which may not complete quickly
|
||||||
# without reachable hosts. We measure the API response time for initiating.
|
# without reachable hosts. We measure the API response time for initiating.
|
||||||
info "5.1 CIDR scan initiation time"
|
info "5.1 CIDR scan initiation time"
|
||||||
local start=$(date +%s%N)
|
local start=$(_now_ms)
|
||||||
SCAN_RESP=$(api_call POST /api/v1/discovery/cidr \
|
SCAN_RESP=$(api_call POST /api/v1/discovery/cidr \
|
||||||
-d '{"cidr": "10.0.0.0/30", "timeout": 1.5}' 2>/dev/null || true)
|
-d '{"cidr": "10.0.0.0/30", "timeout": 1.5}' 2>/dev/null || true)
|
||||||
local end=$(date +%s%N)
|
local end=$(_now_ms)
|
||||||
local elapsed_ms=$(( (end - start) / 1000000 ))
|
local elapsed_ms=$(( end - start ))
|
||||||
local elapsed_s=$(echo "scale=3; ${elapsed_ms}/1000" | bc)
|
local elapsed_s=$(echo "scale=3; ${elapsed_ms}/1000" | bc)
|
||||||
|
|
||||||
info "CIDR scan initiation: ${elapsed_s}s"
|
info "CIDR scan initiation: ${elapsed_s}s"
|
||||||
@ -240,13 +247,13 @@ test_concurrent_load() {
|
|||||||
|
|
||||||
# Fire 20 concurrent requests and measure total time
|
# Fire 20 concurrent requests and measure total time
|
||||||
info "6.1 20 concurrent fleet status requests"
|
info "6.1 20 concurrent fleet status requests"
|
||||||
local start=$(date +%s%N)
|
local start=$(_now_ms)
|
||||||
for i in $(seq 1 20); do
|
for i in $(seq 1 20); do
|
||||||
api_call GET /api/v1/status/fleet -o /dev/null 2>/dev/null &
|
api_call GET /api/v1/status/fleet -o /dev/null 2>/dev/null &
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
local end=$(date +%s%N)
|
local end=$(_now_ms)
|
||||||
local total_ms=$(( (end - start) / 1000000 ))
|
local total_ms=$(( end - start ))
|
||||||
local total_s=$(echo "scale=3; ${total_ms}/1000" | bc)
|
local total_s=$(echo "scale=3; ${total_ms}/1000" | bc)
|
||||||
local per_req=$(echo "scale=3; ${total_s}/20" | bc)
|
local per_req=$(echo "scale=3; ${total_s}/20" | bc)
|
||||||
|
|
||||||
@ -259,7 +266,7 @@ test_concurrent_load() {
|
|||||||
|
|
||||||
# 6.2 Mixed endpoint concurrent load
|
# 6.2 Mixed endpoint concurrent load
|
||||||
info "6.2 20 concurrent mixed-endpoint requests"
|
info "6.2 20 concurrent mixed-endpoint requests"
|
||||||
start=$(date +%s%N)
|
start=$(_now_ms)
|
||||||
for i in $(seq 1 5); do
|
for i in $(seq 1 5); do
|
||||||
api_call GET /api/v1/hosts -o /dev/null 2>/dev/null &
|
api_call GET /api/v1/hosts -o /dev/null 2>/dev/null &
|
||||||
api_call GET /api/v1/groups -o /dev/null 2>/dev/null &
|
api_call GET /api/v1/groups -o /dev/null 2>/dev/null &
|
||||||
@ -267,8 +274,8 @@ test_concurrent_load() {
|
|||||||
api_call GET /api/v1/status/fleet -o /dev/null 2>/dev/null &
|
api_call GET /api/v1/status/fleet -o /dev/null 2>/dev/null &
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
end=$(date +%s%N)
|
end=$(_now_ms)
|
||||||
total_ms=$(( (end - start) / 1000000 ))
|
total_ms=$(( end - start ))
|
||||||
total_s=$(echo "scale=3; ${total_ms}/1000" | bc)
|
total_s=$(echo "scale=3; ${total_ms}/1000" | bc)
|
||||||
per_req=$(echo "scale=3; ${total_s}/20" | bc)
|
per_req=$(echo "scale=3; ${total_s}/20" | bc)
|
||||||
info "Mixed concurrent: ${total_s}s total, ${per_req}s avg"
|
info "Mixed concurrent: ${total_s}s total, ${per_req}s avg"
|
||||||
@ -282,12 +289,12 @@ test_ws_ticket_performance() {
|
|||||||
echo -e "\n${CYAN}=== Test 7: WebSocket Ticket Issuance ===${NC}"
|
echo -e "\n${CYAN}=== Test 7: WebSocket Ticket Issuance ===${NC}"
|
||||||
|
|
||||||
info "7.1 Sequential ticket creation (10 tickets)"
|
info "7.1 Sequential ticket creation (10 tickets)"
|
||||||
local start=$(date +%s%N)
|
local start=$(_now_ms)
|
||||||
for i in $(seq 1 10); do
|
for i in $(seq 1 10); do
|
||||||
api_call POST /api/v1/ws/ticket -o /dev/null 2>/dev/null || true
|
api_call POST /api/v1/ws/ticket -o /dev/null 2>/dev/null || true
|
||||||
done
|
done
|
||||||
local end=$(date +%s%N)
|
local end=$(_now_ms)
|
||||||
local total_ms=$(( (end - start) / 1000000 ))
|
local total_ms=$(( end - start ))
|
||||||
local total_s=$(echo "scale=3; ${total_ms}/1000" | bc)
|
local total_s=$(echo "scale=3; ${total_ms}/1000" | bc)
|
||||||
local per_ticket=$(echo "scale=3; ${total_s}/10" | bc)
|
local per_ticket=$(echo "scale=3; ${total_s}/10" | bc)
|
||||||
info "10 tickets in ${total_s}s (${per_ticket}s per ticket)"
|
info "10 tickets in ${total_s}s (${per_ticket}s per ticket)"
|
||||||
|
|||||||
Reference in New Issue
Block a user