Skip to content

Commit f4b7a32

Browse files
committed
fix rbn sqs test
1 parent e5ee98b commit f4b7a32

File tree

1 file changed

+4
-50
lines changed

1 file changed

+4
-50
lines changed

test/e2e/rebalance-recommendation-sqs-test

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,17 @@ for i in $(seq 1 $TAINT_CHECK_CYCLES); do
167167
tainted=1
168168
fi
169169

170-
if [[ $cordoned -eq 1 && $(kubectl get deployments regular-pod-test -o=jsonpath='{.status.unavailableReplicas}') -eq 1 ]]; then
170+
if [[ $tainted -eq 1 && $(kubectl get deployments regular-pod-test -o=jsonpath='{.status.unavailableReplicas}') -eq 1 ]]; then
171171
echo "✅ Verified the regular-pod-test pod was evicted!"
172172
evicted=1
173173
fi
174174

175-
if [[ ${tainted} -eq 1 && $(kubectl exec -i "${localstack_pod}" -- bash -c "${GET_ATTRS_SQS_CMD}" | jq '(.Attributes.ApproximateNumberOfMessagesNotVisible|tonumber) + (.Attributes.ApproximateNumberOfMessages|tonumber)' ) -eq 0 ]]; then
175+
if [[ ${evicted} -eq 1 && $(kubectl exec -i "${localstack_pod}" -- bash -c "${GET_ATTRS_SQS_CMD}" | jq '(.Attributes.ApproximateNumberOfMessagesNotVisible|tonumber) + (.Attributes.ApproximateNumberOfMessages|tonumber)' ) -eq 0 ]]; then
176176
kubectl exec -i "${localstack_pod}" -- bash -c "${GET_ATTRS_SQS_CMD}"
177177
echo "✅ Verified the message was deleted from the queue after processing!"
178178
message_deleted=1
179-
break
179+
echo "✅ Rebalance Recommendation SQS Test Passed $CLUSTER_NAME! ✅"
180+
exit 0
180181
fi
181182

182183
echo "Assertion Loop $i/$TAINT_CHECK_CYCLES, sleeping for $TAINT_CHECK_SLEEP seconds"
@@ -197,51 +198,4 @@ elif [[ $message_deleted -eq 0 ]]; then
197198
fail_and_exit 3
198199
fi
199200

200-
# Ensure pod is evicted following a spot itn
201-
SPOT_EVENT=$(cat <<EOF
202-
{
203-
"version": "0",
204-
"id": "1e5527d7-bb36-4607-3370-4164db56a40e",
205-
"detail-type": "EC2 Spot Instance Interruption Warning",
206-
"source": "aws.ec2",
207-
"account": "123456789012",
208-
"time": "$(date -u +"%Y-%m-%dT%TZ")",
209-
"region": "us-east-1",
210-
"resources": [
211-
"arn:aws:ec2:us-east-1b:instance/${instance_id}"
212-
],
213-
"detail": {
214-
"instance-id": "${instance_id}",
215-
"instance-action": "terminate"
216-
}
217-
}
218-
EOF
219-
)
220-
221-
SPOT_EVENT_ONE_LINE=$(echo "${SPOT_EVENT}" | tr -d '\n' |sed 's/\"/\\"/g')
222-
SEND_SQS_CMD="awslocal sqs send-message --queue-url ${queue_url} --message-body \"${SPOT_EVENT_ONE_LINE}\" --region ${AWS_REGION}"
223-
kubectl exec -i "${localstack_pod}" -- bash -c "${SEND_SQS_CMD}"
224-
echo "✅ Sent Spot Interruption Event to SQS queue: ${queue_url}"
225-
GET_ATTRS_SQS_CMD="awslocal sqs get-queue-attributes --queue-url ${queue_url} --attribute-names All --region ${AWS_REGION}"
226-
227-
echo "🥑 Waiting for Spot ITN..."
228-
evicted=0
229-
for i in $(seq 1 $TAINT_CHECK_CYCLES); do
230-
if [[ $(kubectl get deployments regular-pod-test -o=jsonpath='{.status.unavailableReplicas}') -eq 1 ]]; then
231-
echo "✅ Verified the regular-pod-test pod was evicted!"
232-
evicted=1
233-
fi
234-
235-
if [[ ${evicted} -eq 1 && $(kubectl exec -i "${localstack_pod}" -- bash -c "${GET_ATTRS_SQS_CMD}" | jq '(.Attributes.ApproximateNumberOfMessagesNotVisible|tonumber) + (.Attributes.ApproximateNumberOfMessages|tonumber)' ) -eq 0 ]]; then
236-
kubectl exec -i "${localstack_pod}" -- bash -c "${GET_ATTRS_SQS_CMD}"
237-
echo "✅ Verified the message was deleted from the queue after processing!"
238-
echo "✅ Rebalance Recommendation SQS Test Passed $CLUSTER_NAME! ✅"
239-
exit 0
240-
fi
241-
242-
echo "Assertion Loop $i/$TAINT_CHECK_CYCLES, sleeping for $TAINT_CHECK_SLEEP seconds"
243-
sleep $TAINT_CHECK_SLEEP
244-
done
245-
246-
echo "❌ Rebalance Recommendation SQS Test Failed $CLUSTER_NAME"
247201
fail_and_exit 1

0 commit comments

Comments
 (0)