Fix CI/CD: resolve integration test syntax errors and handle redirects
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
- Fixed shell arithmetic syntax: changed ((errors++)) to errors=$((errors + 1)) - Added -L flag to curl for following redirects automatically - Treat HTTP 301/302 redirects as successful responses - Improved error counting logic with proper if statements - Added zero division protection for success rate calculation This should resolve the '/bin/sh: errors++: not found' error and handle redirects properly.
This commit is contained in:
30
.drone.yml
30
.drone.yml
@@ -271,11 +271,14 @@ steps:
|
||||
local description="$2"
|
||||
echo "Testing $description ($url)..."
|
||||
|
||||
local status_code=$(curl -o /dev/null -s -w "%{http_code}" -m 10 "$url" 2>/dev/null || echo "000")
|
||||
local status_code=$(curl -L -o /dev/null -s -w "%{http_code}" -m 10 "$url" 2>/dev/null || echo "000")
|
||||
|
||||
if [ "$status_code" = "200" ]; then
|
||||
echo "✅ $description - OK (HTTP $status_code)"
|
||||
return 0
|
||||
elif [ "$status_code" = "301" ] || [ "$status_code" = "302" ]; then
|
||||
echo "✅ $description - Redirect (HTTP $status_code)"
|
||||
return 0
|
||||
elif [ "$status_code" = "404" ]; then
|
||||
echo "⚠️ $description - Not Found (HTTP $status_code)"
|
||||
return 1
|
||||
@@ -294,25 +297,38 @@ steps:
|
||||
|
||||
# Основные страницы
|
||||
total_tests=$((total_tests + 1))
|
||||
test_endpoint "$TEST_TARGET/" "Homepage" || ((errors++))
|
||||
if ! test_endpoint "$TEST_TARGET/" "Homepage"; then
|
||||
errors=$((errors + 1))
|
||||
fi
|
||||
|
||||
total_tests=$((total_tests + 1))
|
||||
test_endpoint "$TEST_TARGET/services/" "Services page" || ((errors++))
|
||||
if ! test_endpoint "$TEST_TARGET/services/" "Services page"; then
|
||||
errors=$((errors + 1))
|
||||
fi
|
||||
|
||||
total_tests=$((total_tests + 1))
|
||||
test_endpoint "$TEST_TARGET/career/" "Career page" || ((errors++))
|
||||
if ! test_endpoint "$TEST_TARGET/career/" "Career page"; then
|
||||
errors=$((errors + 1))
|
||||
fi
|
||||
|
||||
total_tests=$((total_tests + 1))
|
||||
test_endpoint "$TEST_TARGET/contact/" "Contact page" || ((errors++))
|
||||
if ! test_endpoint "$TEST_TARGET/contact/" "Contact page"; then
|
||||
errors=$((errors + 1))
|
||||
fi
|
||||
|
||||
total_tests=$((total_tests + 1))
|
||||
test_endpoint "$TEST_TARGET/admin/" "Admin panel" || echo "ℹ️ Admin panel test failed (expected for production)"
|
||||
if ! test_endpoint "$TEST_TARGET/admin/" "Admin panel"; then
|
||||
echo "ℹ️ Admin panel test failed (expected for production)"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📊 Integration Test Results:"
|
||||
echo " Total tests: $total_tests"
|
||||
echo " Failures: $errors"
|
||||
echo " Success rate: $(( (total_tests - errors) * 100 / total_tests ))%"
|
||||
if [ $total_tests -gt 0 ]; then
|
||||
success_rate=$(( (total_tests - errors) * 100 / total_tests ))
|
||||
echo " Success rate: ${success_rate}%"
|
||||
fi
|
||||
|
||||
if [ $errors -gt 2 ]; then
|
||||
echo "❌ Too many critical endpoint failures ($errors)"
|
||||
|
||||
Reference in New Issue
Block a user