64 lines
2.0 KiB
Bash
Executable File
64 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Test graceful termination of signal-aware Buildah container
|
|
set -e
|
|
|
|
NAMESPACE="apps--droneio--prd"
|
|
DEPLOYMENT="buildah-external"
|
|
|
|
echo "🧪 Testing Graceful Termination"
|
|
echo "==============================="
|
|
|
|
# Scale up to create a pod
|
|
echo "🔼 Scaling up deployment..."
|
|
kubectl scale deployment $DEPLOYMENT --replicas=1 -n $NAMESPACE
|
|
|
|
echo "⏳ Waiting for pod to be ready..."
|
|
kubectl wait --for=condition=ready pod -l app=buildah-external -n $NAMESPACE --timeout=60s
|
|
|
|
POD_NAME=$(kubectl get pods -l app=buildah-external -n $NAMESPACE -o jsonpath='{.items[0].metadata.name}')
|
|
echo "📦 Testing pod: $POD_NAME"
|
|
|
|
# Test that the container is responsive
|
|
echo "🔍 Testing container responsiveness..."
|
|
kubectl exec $POD_NAME -n $NAMESPACE -- buildah --version
|
|
|
|
# Test graceful termination timing
|
|
echo "⏱️ Testing termination speed..."
|
|
START_TIME=$(date +%s)
|
|
|
|
echo "📤 Sending termination signal (scaling down)..."
|
|
kubectl scale deployment $DEPLOYMENT --replicas=0 -n $NAMESPACE
|
|
|
|
echo "⏳ Waiting for pod to terminate..."
|
|
kubectl wait --for=delete pod -l app=buildah-external -n $NAMESPACE --timeout=30s
|
|
|
|
END_TIME=$(date +%s)
|
|
TERMINATION_TIME=$((END_TIME - START_TIME))
|
|
|
|
echo "✅ Pod terminated in ${TERMINATION_TIME} seconds"
|
|
|
|
if [ $TERMINATION_TIME -le 10 ]; then
|
|
echo "🎉 Excellent! Graceful termination completed quickly (≤10s)"
|
|
elif [ $TERMINATION_TIME -le 30 ]; then
|
|
echo "✅ Good! Termination within acceptable time (≤30s)"
|
|
else
|
|
echo "⚠️ Slow termination (>30s) - may need optimization"
|
|
fi
|
|
|
|
echo ""
|
|
echo "🔍 Final deployment status:"
|
|
kubectl get deployment $DEPLOYMENT -n $NAMESPACE
|
|
|
|
echo ""
|
|
echo "📊 Termination Analysis:"
|
|
echo " ⏱️ Time: ${TERMINATION_TIME}s"
|
|
echo " 🎯 Target: <10s (excellent), <30s (good)"
|
|
echo " 📝 Method: Signal-aware bash loop with trap"
|
|
echo ""
|
|
|
|
if [ $TERMINATION_TIME -le 10 ]; then
|
|
echo "✅ Signal handling is working optimally!"
|
|
else
|
|
echo "💡 Consider further optimization if needed"
|
|
fi |