fix: test script

This commit is contained in:
Innei
2022-01-12 19:28:11 +08:00
parent bb59143482
commit ecbce848fa
2 changed files with 41 additions and 9 deletions

View File

@@ -28,19 +28,36 @@ if [[ $? -ne 0 ]]; then
fi
RETRY=0
curl -m 10 localhost:2333/api/v2
do_request() {
curl -f -m 10 localhost:2333/api/v2 -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36'
}
do_request
while [[ $? -ne 0 ]] && [[ $RETRY -lt $MAX_RETRIES ]]; do
sleep 5
((RETRY++))
echo "RETRY: ${RETRY}"
curl -m 10 localhost:2333/api/v2
echo -e "RETRY: ${RETRY}\n"
do_request
done
request_exit_code=$?
echo -e "\nrequest code: ${request_exit_code}\n"
if [[ $RETRY -gt $MAX_RETRIES ]]; then
echo "Unable to run, aborted"
echo -n "Unable to run, aborted"
kill -9 $p
exit 1
elif [[ $request_exit_code -ne 0 ]]; then
echo -n "Request error"
kill -9 $p
exit 1
else
echo -e "\nSuccessfully acquire homepage, passing"
kill -9 $p
exit 0
fi

View File

@@ -1,6 +1,6 @@
#!/bin/bash
MAX_RETRIES=20
MAX_RETRIES=10
node -v
@@ -19,19 +19,34 @@ if [[ $? -ne 0 ]]; then
fi
RETRY=0
curl -m 10 localhost:2333/api/v2
do_request() {
curl -f -m 10 localhost:2333/api/v2 -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36'
}
do_request
while [[ $? -ne 0 ]] && [[ $RETRY -lt $MAX_RETRIES ]]; do
sleep 5
((RETRY++))
echo "RETRY: ${RETRY}"
curl -m 10 localhost:2333/api/v2
echo -e "RETRY: ${RETRY}\n"
do_request
done
request_exit_code=$?
echo -e "\nrequest code: ${request_exit_code}\n"
if [[ $RETRY -gt $MAX_RETRIES ]]; then
echo "Unable to run, aborted"
echo -n "Unable to run, aborted"
kill -9 $p
exit 1
elif [[ $request_exit_code -ne 0 ]]; then
echo -n "Request error"
kill -9 $p
exit 1
else
echo -e "\nSuccessfully acquire homepage, passing"
kill -9 $p