- الرئيسية
- خادم المصدر
- التحقق
التحقق
اختبارات الدخان
Section titled “اختبارات الدخان”قم بتشغيل هذه الفحوصات بعد الانتظار من 5 إلى 10 دقائق لإكمال cloud-init.
نقطة نهاية الصحة
Section titled “نقطة نهاية الصحة”ORIGIN_IP=$(terraform output -raw public_ip)
curl -sf "http://${ORIGIN_IP}/health" | jq .المتوقع:
{ "status": "healthy", "component": "origin-server", "applications": ["juice-shop", "dvwa", "vampi", "httpbin", "whoami", "csd-demo", "dvga", "restaurant", "crapi"]}نقاط نهاية التطبيقات
Section titled “نقاط نهاية التطبيقات”# Default landing pagecurl -sf "http://${ORIGIN_IP}/" -o /dev/null -w "Landing: %{http_code}\n"
# Juice Shopcurl -sf "http://${ORIGIN_IP}/juice-shop/" -o /dev/null -w "Juice Shop: %{http_code}\n"
# DVWAcurl -sf "http://${ORIGIN_IP}/dvwa/" -o /dev/null -w "DVWA: %{http_code}\n"
# VAmPIcurl -sf "http://${ORIGIN_IP}/vampi/" -o /dev/null -w "VAmPI: %{http_code}\n"
# httpbincurl -sf "http://${ORIGIN_IP}/httpbin/get" -o /dev/null -w "httpbin: %{http_code}\n"
# whoamicurl -sf "http://${ORIGIN_IP}/whoami/" -o /dev/null -w "whoami: %{http_code}\n"
# DVGAcurl -sf "http://${ORIGIN_IP}/dvga/" -o /dev/null -w "DVGA: %{http_code}\n"
# RESTaurantcurl -sf "http://${ORIGIN_IP}/restaurant/docs" -o /dev/null -w "RESTaurant: %{http_code}\n"
# crAPI (port 8888)curl -sf "http://${ORIGIN_IP}:8888" -o /dev/null -w "crAPI: %{http_code}\n"يجب أن تُرجع جميعها 200 (تُرجع DVWA 302 إعادة توجيه إلى تسجيل الدخول).
اختبار الدخان الآلي
Section titled “اختبار الدخان الآلي”يتضمن المستودع مجموعة اختبارات دخان مكونة من 39 نقطة:
./tests/smoke-test.sh ${ORIGIN_IP}يتحقق هذا من جميع التطبيقات التسعة، ونقاط نهاية الصحة، وتسجيل VAmPI/تسجيل الدخول، ورحلة CSD Demo للنقل والعودة، وDVGA GraphQL، وRESTaurant Swagger، وcrAPI على المنفذ 8888، وضغط nginx gzip، وإخفاء الإصدار.
حالة حاوية Docker
Section titled “حالة حاوية Docker”سجّل الدخول عبر SSH إلى الجهاز الافتراضي وتحقق من تشغيل جميع الـ 41 حاوية:
ssh azureuser@${ORIGIN_IP} "sudo docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'" | sortالإخراج المتوقع (41 حاوية):
NAMES STATUS PORTScrapi-community Up X minutescrapi-identity Up X minutescrapi-mailhog Up X minutes 0.0.0.0:18025->8025/tcpcrapi-mongo Up X minutes 27017/tcpcrapi-postgres Up X minutes 5432/tcpcrapi-web Up X minutes 0.0.0.0:8888->80/tcpcrapi-workshop Up X minutescsd-demo-1 Up X minutes 127.0.0.1:5001->5001/tcpcsd-demo-2 Up X minutes 127.0.0.1:5002->5001/tcpcsd-demo-3 Up X minutes 127.0.0.1:5003->5001/tcpcsd-demo-4 Up X minutes 127.0.0.1:5004->5001/tcpdvga-1 Up X minutes 127.0.0.1:5201->5013/tcpdvga-2 Up X minutes 127.0.0.1:5202->5013/tcpdvga-3 Up X minutes 127.0.0.1:5203->5013/tcpdvga-4 Up X minutes 127.0.0.1:5204->5013/tcpdvwa-1 Up X minutes 127.0.0.1:8101->80/tcpdvwa-2 Up X minutes 127.0.0.1:8102->80/tcpdvwa-3 Up X minutes 127.0.0.1:8103->80/tcpdvwa-4 Up X minutes 127.0.0.1:8104->80/tcpdvwa-db Up X minutes 3306/tcphttpbin-1 Up X minutes 127.0.0.1:8201->80/tcphttpbin-2 Up X minutes 127.0.0.1:8202->80/tcphttpbin-3 Up X minutes 127.0.0.1:8203->80/tcphttpbin-4 Up X minutes 127.0.0.1:8204->80/tcpjuice-shop-1 Up X minutes 127.0.0.1:3001->3000/tcpjuice-shop-2 Up X minutes 127.0.0.1:3002->3000/tcpjuice-shop-3 Up X minutes 127.0.0.1:3003->3000/tcpjuice-shop-4 Up X minutes 127.0.0.1:3004->3000/tcprestaurant-1 Up X minutes 127.0.0.1:8301->8080/tcprestaurant-2 Up X minutes 127.0.0.1:8302->8080/tcprestaurant-3 Up X minutes 127.0.0.1:8303->8080/tcprestaurant-4 Up X minutes 127.0.0.1:8304->8080/tcprestaurant-db Up X minutes 5432/tcpvampi-1 Up X minutes 127.0.0.1:5101->5000/tcpvampi-2 Up X minutes 127.0.0.1:5102->5000/tcpvampi-3 Up X minutes 127.0.0.1:5103->5000/tcpvampi-4 Up X minutes 127.0.0.1:5104->5000/tcpwhoami-1 Up X minutes 127.0.0.1:8082->80/tcpwhoami-2 Up X minutes 127.0.0.1:8083->80/tcpwhoami-3 Up X minutes 127.0.0.1:8084->80/tcpwhoami-4 Up X minutes 127.0.0.1:8085->80/tcpحالة nginx
Section titled “حالة nginx”ssh azureuser@${ORIGIN_IP} "sudo nginx -t && sudo systemctl status nginx --no-pager"استكشاف الأخطاء وإصلاحها
Section titled “استكشاف الأخطاء وإصلاحها”cloud-init لا يزال قيد التشغيل
Section titled “cloud-init لا يزال قيد التشغيل”إذا أرجعت نقاط النهاية 502 أو رُفض الاتصال، فقد يكون cloud-init لا يزال في مرحلة التوفير:
ssh azureuser@${ORIGIN_IP} "cloud-init status"status: running— لا يزال في مرحلة التوفير، انتظر بضع دقائقstatus: done— اكتمل التوفير، تحقق من حاويات Dockerstatus: error— تحقق من السجلات أدناه
سجلات cloud-init
Section titled “سجلات cloud-init”ssh azureuser@${ORIGIN_IP} "sudo tail -100 /var/log/cloud-init-output.log"الحاوية لا تبدأ
Section titled “الحاوية لا تبدأ”# Check container logs (each app has 4 instances: -1 through -4)ssh azureuser@${ORIGIN_IP} "sudo docker logs juice-shop-1 2>&1 | tail -20"ssh azureuser@${ORIGIN_IP} "sudo docker logs dvwa-1 2>&1 | tail -20"ssh azureuser@${ORIGIN_IP} "sudo docker logs vampi-1 2>&1 | tail -20"ssh azureuser@${ORIGIN_IP} "sudo docker logs httpbin-1 2>&1 | tail -20"ssh azureuser@${ORIGIN_IP} "sudo docker logs csd-demo-1 2>&1 | tail -20"ssh azureuser@${ORIGIN_IP} "sudo docker logs dvga-1 2>&1 | tail -20"ssh azureuser@${ORIGIN_IP} "sudo docker logs restaurant-1 2>&1 | tail -20"ssh azureuser@${ORIGIN_IP} "sudo docker logs crapi-web 2>&1 | tail -20"nginx يُرجع 502
Section titled “nginx يُرجع 502”الحاوية الأمامية غير جاهزة أو تعطلت:
# Check nginx error logssh azureuser@${ORIGIN_IP} "sudo tail -20 /var/log/nginx/error.log"
# Restart all instances of a specific appssh azureuser@${ORIGIN_IP} "for i in 1 2 3 4; do sudo docker restart juice-shop-\$i; done"
# Rebuild and restart all containersssh azureuser@${ORIGIN_IP} "cd /opt/origin-server && sudo docker compose build && sudo docker compose up -d"مساحة القرص
Section titled “مساحة القرص”تستهلك صور Docker ما يقارب 4.7 جيجابايت. تم تعطيل تسجيل الوصول لمنع استنفاد القرص أثناء اختبار تحميل توصيل المحتوى. تم تهيئة Logrotate كدفاع متعمق (حد 500 ميجابايت). تحقق من استخدام القرص:
ssh azureuser@${ORIGIN_IP} "df -h / && sudo docker system df"ذاكرة الحاوية
Section titled “ذاكرة الحاوية”تحقق من الحاويات التي تقترب من حدود ذاكرتها (خطر OOM):
ssh azureuser@${ORIGIN_IP} "sudo docker stats --no-stream --format 'table {{.Name}}\t{{.MemUsage}}\t{{.MemPerc}}' | sort"إعادة تشغيل كل شيء
Section titled “إعادة تشغيل كل شيء”إذا لزم الأمر، أعد بناء وتشغيل جميع الخدمات:
ssh azureuser@${ORIGIN_IP} "cd /opt/origin-server && sudo docker compose down && sudo docker compose build && sudo docker compose up -d && sudo systemctl restart nginx"