Skip to content

Commit ae1150d

Browse files
committed
Update
1 parent 693b380 commit ae1150d

1 file changed

Lines changed: 78 additions & 114 deletions

File tree

qa/L0_vertex_ai/test.sh

Lines changed: 78 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ if [ "$SERVER_PID" == "0" ]; then
139139
exit 1
140140
fi
141141
kill $SERVER_PID
142-
wait $SERVE_PID
142+
wait $SERVER_PID
143143
set +e
144144
# Expect no message regarding Vertex AI as it is disabled
145145
grep "failed to start Vertex AI service" $SERVER_LOG
@@ -162,7 +162,7 @@ if [ "$SERVER_PID" == "0" ]; then
162162
exit 1
163163
fi
164164
kill $SERVER_PID
165-
wait $SERVE_PID
165+
wait $SERVER_PID
166166
set +e
167167
grep "Started Vertex AI HTTPService at" $SERVER_LOG
168168
if [ $? -ne 0 ]; then
@@ -191,7 +191,7 @@ if [ "$SERVER_PID" == "0" ]; then
191191
exit 1
192192
fi
193193
kill $SERVER_PID
194-
wait $SERVE_PID
194+
wait $SERVER_PID
195195
set +e
196196
grep "Started Vertex AI HTTPService at" $SERVER_LOG
197197
if [ $? -ne 0 ]; then
@@ -225,7 +225,7 @@ if [ "$SERVER_PID" == "0" ]; then
225225
exit 1
226226
fi
227227
kill $SERVER_PID
228-
wait $SERVE_PID
228+
wait $SERVER_PID
229229
set +e
230230
# Expect no message regarding Vertex AI as it is disabled
231231
grep "failed to start Vertex AI service" $SERVER_LOG
@@ -336,7 +336,7 @@ fi
336336
set -e
337337

338338
kill $SERVER_PID
339-
wait $SERVE_PID
339+
wait $SERVER_PID
340340

341341
#
342342
# AIP_STORAGE_URI / AIP_HTTP_PORT
@@ -375,7 +375,7 @@ fi
375375
set -e
376376

377377
kill $SERVER_PID
378-
wait $SERVE_PID
378+
wait $SERVER_PID
379379

380380
#
381381
# default model
@@ -458,7 +458,7 @@ else
458458
fi
459459
set -e
460460
kill $SERVER_PID
461-
wait $SERVE_PID
461+
wait $SERVER_PID
462462

463463
# Test default model as well as multi model
464464
SERVER_ARGS="--vertex-ai-default-model=addsub"
@@ -717,7 +717,7 @@ fi
717717
set -e
718718

719719
kill $SERVER_PID
720-
wait $SERVE_PID
720+
wait $SERVER_PID
721721

722722
#
723723
# Restricted API regression for Vertex redirect
@@ -761,124 +761,88 @@ set -e
761761

762762
# Redirected management APIs should be blocked without restricted header
763763
set +e
764-
rm -f ./curl.out
765-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2" localhost:8080/predict`
766-
if [ "$code" != "403" ]; then
767-
cat ./curl.out
768-
echo -e "\n***\n*** Failed. Expected /v2 metadata is restricted\n***"
769-
RET=1
770-
else
771-
grep "This API is restricted" ./curl.out
772-
if [ $? -ne 0 ]; then
764+
for redirect_endpoint in \
765+
"v2" \
766+
"v2/models/identity_fp32/config" \
767+
"v2/repository/index" \
768+
"v2/systemsharedmemory/status" \
769+
"v2/cudasharedmemory/status" \
770+
"v2/systemsharedmemory/region/test/register"
771+
do
772+
rm -f ./curl.out
773+
if [ "$redirect_endpoint" != "v2/systemsharedmemory/region/test/register" ]; then
774+
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: ${redirect_endpoint}" localhost:8080/predict`
775+
else
776+
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: ${redirect_endpoint}" \
777+
-H "Content-Type: application/json" -d '{"key":"test_shm","byte_size":1024}' localhost:8080/predict`
778+
fi
779+
if [ "$code" != "403" ]; then
773780
cat ./curl.out
774-
echo -e "\n***\n*** Failed. Expected restriction error message\n***"
781+
echo -e "\n***\n*** Failed. Expected ${redirect_endpoint} is restricted\n***"
775782
RET=1
776783
fi
777-
fi
778-
779-
rm -f ./curl.out
780-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2/models/identity_fp32/config" localhost:8080/predict`
781-
if [ "$code" != "403" ]; then
782-
cat ./curl.out
783-
echo -e "\n***\n*** Failed. Expected model config is restricted\n***"
784-
RET=1
785-
fi
786-
787-
rm -f ./curl.out
788-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2/repository/index" localhost:8080/predict`
789-
if [ "$code" != "403" ]; then
790-
cat ./curl.out
791-
echo -e "\n***\n*** Failed. Expected repository index is restricted\n***"
792-
RET=1
793-
fi
794-
795-
rm -f ./curl.out
796-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2/systemsharedmemory/status" localhost:8080/predict`
797-
if [ "$code" != "403" ]; then
798-
cat ./curl.out
799-
echo -e "\n***\n*** Failed. Expected system shared memory status is restricted\n***"
800-
RET=1
801-
fi
802-
803-
rm -f ./curl.out
804-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2/cudasharedmemory/status" localhost:8080/predict`
805-
if [ "$code" != "403" ]; then
806-
cat ./curl.out
807-
echo -e "\n***\n*** Failed. Expected CUDA shared memory status is restricted\n***"
808-
RET=1
809-
fi
810-
811-
rm -f ./curl.out
812-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2/systemsharedmemory/region/test/register" -H "Content-Type: application/json" -d '{"key":"test_shm","byte_size":1024}' localhost:8080/predict`
813-
if [ "$code" != "403" ]; then
814-
cat ./curl.out
815-
echo -e "\n***\n*** Failed. Expected shared memory register operation is restricted\n***"
816-
RET=1
817-
fi
784+
done
818785
set -e
819786

820787
# Restricted header should allow handler invocation
821788
set +e
822-
rm -f ./curl.out
823-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2" -H "X-Vertex-Restricted: secret" localhost:8080/predict`
824-
if [ "$code" != "200" ]; then
825-
cat ./curl.out
826-
echo -e "\n***\n*** Failed. Expected /v2 metadata passes with restricted header\n***"
827-
RET=1
828-
fi
829-
830-
rm -f ./curl.out
831-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2/systemsharedmemory/status" -H "X-Vertex-Restricted: secret" localhost:8080/predict`
832-
if [ "$code" != "200" ]; then
833-
cat ./curl.out
834-
echo -e "\n***\n*** Failed. Expected shared memory status passes with restricted header\n***"
835-
RET=1
836-
fi
837-
838-
rm -f ./curl.out
839-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2/cudasharedmemory/status" -H "X-Vertex-Restricted: secret" localhost:8080/predict`
840-
if [ "$code" != "200" ]; then
841-
cat ./curl.out
842-
echo -e "\n***\n*** Failed. Expected CUDA shared memory status passes with restricted header\n***"
843-
RET=1
844-
fi
845-
846-
rm -f ./curl.out
847-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2/models/identity_fp32/config" -H "X-Vertex-Restricted: secret" localhost:8080/predict`
848-
if [ "$code" != "200" ]; then
849-
cat ./curl.out
850-
echo -e "\n***\n*** Failed. Expected model config passes with restricted header\n***"
851-
RET=1
852-
fi
853-
854-
rm -f ./curl.out
855-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2/repository/index" -H "X-Vertex-Restricted: secret" localhost:8080/predict`
856-
if [ "$code" != "200" ]; then
857-
cat ./curl.out
858-
echo -e "\n***\n*** Failed. Expected repository index passes with restricted header\n***"
859-
RET=1
860-
fi
861-
862-
rm -f ./curl.out
863-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2/systemsharedmemory/region/test/register" -H "X-Vertex-Restricted: secret" -H "Content-Type: application/json" -d '{"key":"test_shm","byte_size":1024}' localhost:8080/predict`
864-
if [ "$code" == "403" ]; then
865-
cat ./curl.out
866-
echo -e "\n***\n*** Failed. Expected valid restricted header to pass restriction check (request may still fail for non-auth reasons)\n***"
867-
RET=1
868-
fi
789+
for redirect_endpoint in \
790+
"v2" \
791+
"v2/models/identity_fp32/config" \
792+
"v2/repository/index" \
793+
"v2/systemsharedmemory/status" \
794+
"v2/cudasharedmemory/status" \
795+
"v2/systemsharedmemory/region/test/register"
796+
do
797+
rm -f ./curl.out
798+
if [ "$redirect_endpoint" != "v2/systemsharedmemory/region/test/register" ]; then
799+
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: ${redirect_endpoint}" \
800+
-H "X-Vertex-Restricted: secret" localhost:8080/predict`
801+
if [ "$code" != "200" ]; then
802+
cat ./curl.out
803+
echo -e "\n***\n*** Failed. Expected ${redirect_endpoint} passes with restricted header\n***"
804+
RET=1
805+
fi
806+
else
807+
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: ${redirect_endpoint}" \
808+
-H "X-Vertex-Restricted: secret" -H "Content-Type: application/json" -d '{"key":"test_shm","byte_size":1024}' localhost:8080/predict`
809+
# This request may fail with a different error: "Unable to open shared memory region: 'test_shm'"
810+
if [ "$code" == "403" ]; then
811+
cat ./curl.out
812+
echo -e "\n***\n*** Failed. Expected ${redirect_endpoint} passes with restricted header\n***"
813+
RET=1
814+
fi
815+
fi
816+
done
869817

870818
# Wrong restricted header should reject the request
871-
rm -f ./curl.out
872-
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: v2" -H "X-Vertex-Restricted: invalid" localhost:8080/predict`
873-
if [ "$code" != "403" ]; then
874-
cat ./curl.out
875-
echo -e "\n***\n*** Failed. Expected invalid restricted header value is rejected\n***"
876-
RET=1
877-
fi
819+
set +e
820+
for redirect_endpoint in \
821+
"v2" \
822+
"v2/models/identity_fp32/config" \
823+
"v2/repository/index" \
824+
"v2/systemsharedmemory/status" \
825+
"v2/cudasharedmemory/status" \
826+
"v2/systemsharedmemory/region/test/register"
827+
do
828+
rm -f ./curl.out
829+
if [ "$redirect_endpoint" != "v2/systemsharedmemory/region/test/register" ]; then
830+
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: ${redirect_endpoint}" \
831+
-H "X-Vertex-Restricted: invalid" localhost:8080/predict`
832+
else
833+
code=`curl -s -w %{http_code} -o ./curl.out -X POST -H "X-Vertex-Ai-Triton-Redirect: ${redirect_endpoint}" \
834+
-H "X-Vertex-Restricted: invalid" -H "Content-Type: application/json" -d '{"key":"test_shm","byte_size":1024}' localhost:8080/predict`
835+
fi
836+
if [ "$code" != "403" ]; then
837+
cat ./curl.out
838+
echo -e "\n***\n*** Failed. Expected invalid restricted header value is rejected for ${redirect_endpoint}\n***"
839+
RET=1
840+
fi
841+
done
878842
set -e
879843

880844
kill $SERVER_PID
881-
wait $SERVE_PID
845+
wait $SERVER_PID
882846

883847
if [ $RET -eq 0 ]; then
884848
echo -e "\n***\n*** Test Passed\n***"

0 commit comments

Comments
 (0)