Skip to content

Commit 10a486a

Browse files
committed
Add test with explicit resource
1 parent 126b986 commit 10a486a

File tree

2 files changed

+46
-14
lines changed

2 files changed

+46
-14
lines changed

qa/L0_model_update/instance_update_test.py

+38-11
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ def test_infer_while_updating(self):
338338
# Unload model
339339
self.__unload_model()
340340

341-
# Test instance resource requirement update
342-
@unittest.skipUnless(os.environ["RATE_LIMIT_MODE"] == "execution_count",
341+
# Test instance resource requirement increase
342+
@unittest.skipUnless("execution_count" in os.environ["RATE_LIMIT_MODE"],
343343
"Rate limiter precondition not met for this test")
344-
def test_instance_resource_update(self):
344+
def test_instance_resource_increase(self):
345345
# Load model
346346
self.__load_model(
347347
1,
@@ -365,19 +365,46 @@ def infer():
365365
time.sleep(infer_count / 2) # each infer should take < 0.5 seconds
366366
self.assertNotIn(False, infer_complete, "Infer possibly stuck")
367367
infer_thread.result()
368-
# Decrease the resource requirement
368+
# Unload model
369+
self.__unload_model()
370+
371+
# Test instance resource requirement increase above explicit resource
372+
@unittest.skipUnless(os.environ["RATE_LIMIT_MODE"] ==
373+
"execution_count_with_explicit_resource",
374+
"Rate limiter precondition not met for this test")
375+
def test_instance_resource_increase_above_explicit(self):
376+
# Load model
377+
self.__load_model(
378+
1,
379+
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 2\n}\n]\n}\n}"
380+
)
381+
# Increase resource requirement
382+
with self.assertRaises(InferenceServerException):
383+
self.__update_instance_count(
384+
0, 0,
385+
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 32\n}\n]\n}\n}"
386+
)
387+
# Correct the resource requirement to match the explicit resource
369388
self.__update_instance_count(
370389
1, 1,
371-
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 6\n}\n]\n}\n}"
390+
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 10\n}\n]\n}\n}"
372391
)
373-
# Further decrease the resource requirement. The previous decrease
374-
# should have lower the max resource in the rate limiter, which the
375-
# error "Should not print this ..." should not be printed into the
376-
# server log because the max resource is above the previously set limit
377-
# and it will be checked by the main bash test script.
392+
# Unload model
393+
self.__unload_model()
394+
395+
# Test instance resource requirement decrease
396+
@unittest.skipUnless("execution_count" in os.environ["RATE_LIMIT_MODE"],
397+
"Rate limiter precondition not met for this test")
398+
def test_instance_resource_decrease(self):
399+
# Load model
400+
self.__load_model(
401+
1,
402+
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 4\n}\n]\n}\n}"
403+
)
404+
# Decrease resource requirement
378405
self.__update_instance_count(
379406
1, 1,
380-
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 4\n}\n]\n}\n}"
407+
"{\ncount: 1\nkind: KIND_CPU\nrate_limiter {\nresources [\n{\nname: \"R1\"\ncount: 2\n}\n]\n}\n}"
381408
)
382409
# Unload model
383410
self.__unload_model()

qa/L0_model_update/test.sh

+8-3
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,20 @@ function setup_models() {
5555

5656
RET=0
5757

58-
# Test model instance update with and without rate limiting enabled
59-
for RATE_LIMIT_MODE in "off" "execution_count"; do
58+
# Test model instance update with rate limiting on/off and explicit resource
59+
for RATE_LIMIT_MODE in "off" "execution_count" "execution_count_with_explicit_resource"; do
60+
61+
RATE_LIMIT_ARGS="--rate-limit=$RATE_LIMIT_MODE"
62+
if [ "$RATE_LIMIT_MODE" == "execution_count_with_explicit_resource" ]; then
63+
RATE_LIMIT_ARGS="--rate-limit=execution_count --rate-limit-resource=R1:10"
64+
fi
6065

6166
export RATE_LIMIT_MODE=$RATE_LIMIT_MODE
6267
TEST_LOG="instance_update_test.rate_limit_$RATE_LIMIT_MODE.log"
6368
SERVER_LOG="./instance_update_test.rate_limit_$RATE_LIMIT_MODE.server.log"
6469

6570
setup_models
66-
SERVER_ARGS="--model-repository=models --model-control-mode=explicit --rate-limit=$RATE_LIMIT_MODE --log-verbose=2"
71+
SERVER_ARGS="--model-repository=models --model-control-mode=explicit $RATE_LIMIT_ARGS --log-verbose=2"
6772
run_server
6873
if [ "$SERVER_PID" == "0" ]; then
6974
echo -e "\n***\n*** Failed to start $SERVER\n***"

0 commit comments

Comments
 (0)