Skip to content

Commit

Permalink
Add test on rate limiter max resource decrease update
Browse files Browse the repository at this point in the history
  • Loading branch information
kthui committed Jun 8, 2023
1 parent 1185555 commit 126b986
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
18 changes: 16 additions & 2 deletions qa/L0_model_update/instance_update_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ def test_infer_while_updating(self):
# Unload model
self.__unload_model()

# Test instance resource requirement increase
# Test instance resource requirement update
@unittest.skipUnless(os.environ["RATE_LIMIT_MODE"] == "execution_count",
"Rate limiter precondition not met for this test")
def test_instance_resource_increase(self):
def test_instance_resource_update(self):
# Load model
self.__load_model(
1,
Expand All @@ -365,6 +365,20 @@ def infer():
time.sleep(infer_count / 2) # each infer should take < 0.5 seconds
self.assertNotIn(False, infer_complete, "Infer possibly stuck")
infer_thread.result()
# Decrease the resource requirement
self.__update_instance_count(
1, 1,
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 6\n}\n]\n}\n}"
)
# Further decrease the resource requirement. The previous decrease
# should have lower the max resource in the rate limiter, which the
# error "Should not print this ..." should not be printed into the
# server log because the max resource is above the previously set limit
# and it will be checked by the main bash test script.
self.__update_instance_count(
1, 1,
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 4\n}\n]\n}\n}"
)
# Unload model
self.__unload_model()

Expand Down
9 changes: 9 additions & 0 deletions qa/L0_model_update/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ for RATE_LIMIT_MODE in "off" "execution_count"; do
kill $SERVER_PID
wait $SERVER_PID

set +e
grep "Should not print this" $SERVER_LOG
if [ $? -eq 0 ]; then
echo -e "\n***\n*** Found \"Should not print this\" on \"$SERVER_LOG\"\n***"
cat $SERVER_LOG
RET=1
fi
set -e

done

if [ $RET -eq 0 ]; then
Expand Down

0 comments on commit 126b986

Please sign in to comment.