From b1fe4818b46b4623b678b531d17d539c4c58099b Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Wed, 8 Jun 2022 15:29:36 +0900 Subject: [PATCH] test/query: wait for server launching, not 5 sec. 1. With busy CI servers, you don't know how much time it takes to launch tensor-query-server instances. Thus, wait for the pipeline launching, not a constant time. Besides, you can use "wait" command for server exit. 2. Do not use & for ssat apis. Signed-off-by: MyungJoo Ham --- tests/nnstreamer_query/runTest.sh | 93 +++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 27 deletions(-) diff --git a/tests/nnstreamer_query/runTest.sh b/tests/nnstreamer_query/runTest.sh index 009cc41..e4316e5 100644 --- a/tests/nnstreamer_query/runTest.sh +++ b/tests/nnstreamer_query/runTest.sh @@ -41,46 +41,75 @@ if [[ ! $check_query ]]; then exit fi +function waitformarker { + for i in $(seq 1 ${TIMEOUT_SEC}) + do + if [ -f 'marker.log' ]; then + markersize=$(stat -c%s marker.log) + if [ $markersize -ge 48 ]; then + testResult 1 $1 "$2" 0 0 + return 0 + fi + fi + sleep 1 + done + testResult 0 $1 "$2" 0 0 + exit +} +WAIT4MARKER=" videotestsrc num-buffers=1 ! video/x-raw,format=RGB,height=4,width=4 ! filesink location=marker.log " +PORT1=$(expr $RANDOM % 1000 \* 2 + 5000) +PORT2=$(expr $PORT1 + 1) + # Run tensor query server as echo server with default address option. -gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc num-buffers=3 ! other/tensors,num_tensors=1,dimensions=3:300:300:1,types=uint8 ! tensor_query_serversink" 1-1 0 0 $PERFORMANCE $TIMEOUT_SEC & -sleep $SLEEPTIME_SEC +rm -f marker.log +gst-launch-1.0 --gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc num-buffers=3 ! other/tensors,num_tensors=1,dimensions=3:300:300:1,types=uint8 ! tensor_query_serversink async=false ${WAIT4MARKER} & +pid=$! +waitformarker 1-1-T "query-server launching" gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=3 ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tensor_converter ! tee name = t t. ! queue ! multifilesink location= raw1_%1d.log t. ! queue ! tensor_query_client ! multifilesink location=result1_%1d.log" 1-2 0 0 $PERFORMANCE callCompareTest raw1_0.log result1_0.log 1-3 "Compare 1-3" 1 0 callCompareTest raw1_1.log result1_1.log 1-4 "Compare 1-4" 1 0 callCompareTest raw1_2.log result1_2.log 1-5 "Compare 1-5" 1 0 - # Since the server operates in the background, wait for the server to stop before starting the next test. -sleep $SLEEPTIME_SEC +kill -9 $pid &> /dev/null +wait $pid + # Run tensor query server as echo server with given address option. (multi clients) -gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc host=127.0.0.1 port=5001 num-buffers=6 ! other/tensors,num_tensors=1,dimensions=3:300:300:1,types=uint8 ! tensor_query_serversink host=127.0.0.1 port=5002" 2-1 0 0 $PERFORMANCE $TIMEOUT_SEC & -sleep $SLEEPTIME_SEC -gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=3 ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tensor_converter ! tee name = t t. ! queue ! multifilesink location= raw2_%1d.log t. ! queue ! tensor_query_client src-host=127.0.0.1 src-port=5001 sink-host=127.0.0.1 sink-port=5002 ! multifilesink location=result2_%1d.log" 2-2 0 0 $PERFORMANCE & -gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=3 ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tensor_converter ! tee name = t t. ! queue ! multifilesink location= raw2_2_%1d.log t. ! queue ! tensor_query_client src-host=127.0.0.1 src-port=5001 sink-host=127.0.0.1 sink-port=5002 ! multifilesink location=result2_2_%1d.log" 2-3 0 0 $PERFORMANCE +rm marker.log +gst-launch-1.0 --gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc host=127.0.0.1 port=${PORT1} num-buffers=6 ! other/tensors,num_tensors=1,dimensions=3:300:300:1,types=uint8 ! tensor_query_serversink async=false host=127.0.0.1 port=${PORT2} ${WAIT4MARKER} & +pid=$! +waitformarker 2-1-T "query-server launching" +gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=3 ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tensor_converter ! tee name = t t. ! queue ! multifilesink location= raw2_%1d.log t. ! queue ! tensor_query_client src-host=127.0.0.1 src-port=${PORT1} sink-host=127.0.0.1 sink-port=${PORT2} ! multifilesink location=result2_%1d.log" 2-2 0 0 $PERFORMANCE & +gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=3 ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tensor_converter ! tee name = t t. ! queue ! multifilesink location= raw2_2_%1d.log t. ! queue ! tensor_query_client src-host=127.0.0.1 src-port=${PORT1} sink-host=127.0.0.1 sink-port=${PORT2} ! multifilesink location=result2_2_%1d.log" 2-3 0 0 $PERFORMANCE callCompareTest raw2_0.log result2_0.log 2-4 "Compare 2-4" 1 0 callCompareTest raw2_1.log result2_1.log 2-5 "Compare 2-5" 1 0 callCompareTest raw2_2.log result2_2.log 2-6 "Compare 2-6" 1 0 callCompareTest raw2_2_0.log result2_2_0.log 2-7 "Compare 2-7" 1 0 callCompareTest raw2_2_1.log result2_2_1.log 2-8 "Compare 2-8" 1 0 callCompareTest raw2_2_2.log result2_2_2.log 2-9 "Compare 2-9" 1 0 +kill -9 $pid &> /dev/null +wait $pid -sleep $SLEEPTIME_SEC # Test flexible tensors -gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc num-buffers=3 ! other/tensors,format=flexible ! tensor_query_serversink" 3-1 0 0 $PERFORMANCE $TIMEOUT_SEC & -sleep $SLEEPTIME_SEC +rm marker.log +gst-launch-1.0 --gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc num-buffers=3 ! other/tensors,format=flexible ! tensor_query_serversink async=false ${WAIT4MARKER} & +pid=$! +waitformarker 3-1-T "query-server launching" gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=3 ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tensor_converter ! other/tensors,format=flexible ! tee name = t t. ! queue ! multifilesink location= raw3_%1d.log t. ! queue ! tensor_query_client ! multifilesink location=result3_%1d.log" 3-2 0 0 $PERFORMANCE callCompareTest raw3_0.log result3_0.log 3-3 "Compare 3-3" 1 0 callCompareTest raw3_1.log result3_1.log 3-4 "Compare 3-4" 1 0 callCompareTest raw3_2.log result3_2.log 3-5 "Compare 3-5" 1 0 - -sleep $SLEEPTIME_SEC +kill -9 $pid &> /dev/null +wait $pid # Test multiple query server src and sink. -gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \ +rm marker.log +gst-launch-1.0 --gst-plugin-path=${PATH_TO_PLUGIN} \ tensor_query_serversrc id=0 num-buffers=3 ! other/tensors,format=flexible ! tensor_query_serversink id=0 async=false \ - tensor_query_serversrc id=1 port=5000 num-buffers=3 ! other/tensors,format=flexible ! tensor_query_serversink id=1 port=5001 async=false" 5-1 0 0 $PERFORMANCE $TIMEOUT_SEC & -sleep $SLEEPTIME_SEC + tensor_query_serversrc id=1 port=${PORT1} num-buffers=3 ! other/tensors,format=flexible ! tensor_query_serversink id=1 port=${PORT2} async=false ${WAIT4MARKER} & +pid=$! +waitformarker 5-1-T "query-server launching" # Client pipeline 5-2 is connected to server ID 0. gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \ videotestsrc num-buffers=3 ! videoconvert ! videoscale ! video/x-raw,width=640,height=480,format=RGB ! \ @@ -92,45 +121,55 @@ gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \ videotestsrc pattern=13 num-buffers=3 ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! \ tensor_converter ! other/tensors,format=flexible ! tee name=t \ t. ! queue ! multifilesink location= raw5_3_%1d.log \ - t. ! queue ! tensor_query_client src-port=5000 sink-port=5001 ! multifilesink location=result5_3_%1d.log" 5-3 0 0 $PERFORMANCE + t. ! queue ! tensor_query_client src-port=${PORT1} sink-port=${PORT2} ! multifilesink location=result5_3_%1d.log" 5-3 0 0 $PERFORMANCE callCompareTest raw5_2_0.log result5_2_0.log 5-4 "Compare 5-4" 1 0 callCompareTest raw5_2_1.log result5_2_1.log 5-5 "Compare 5-5" 1 0 callCompareTest raw5_2_2.log result5_2_2.log 5-6 "Compare 5-6" 1 0 callCompareTest raw5_3_0.log result5_3_0.log 5-7 "Compare 5-7" 1 0 callCompareTest raw5_3_1.log result5_3_1.log 5-8 "Compare 5-8" 1 0 callCompareTest raw5_3_2.log result5_3_2.log 5-9 "Compare 5-9" 1 0 +kill -9 $pid &> /dev/null +wait $pid -sleep $SLEEPTIME_SEC # Sever src cap: Video, Server sink cap: Viedo test -gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc num-buffers=3 ! video/x-raw,width=300,height=300,format=RGB,framerate=0/1 ! tensor_query_serversink" 6-1 0 0 $PERFORMANCE $TIMEOUT_SEC & -sleep $SLEEPTIME_SEC +rm marker.log +gst-launch-1.0 --gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc num-buffers=3 ! video/x-raw,width=300,height=300,format=RGB,framerate=0/1 ! tensor_query_serversink async=false ${WAIT4MARKER} & +pid=$! +waitformarker 6-1-T "query-server launching" gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=3 ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tee name = t t. ! queue ! multifilesink location= raw6_%1d.log t. ! queue ! tensor_query_client ! multifilesink location=result6_%1d.log" 6-2 0 0 $PERFORMANCE callCompareTest raw6_0.log result6_0.log 6-3 "Compare 6-3" 1 0 callCompareTest raw6_1.log result6_1.log 6-4 "Compare 6-4" 1 0 callCompareTest raw6_2.log result6_2.log 6-5 "Compare 6-5" 1 0 +kill -9 $pid &> /dev/null +wait $pid -sleep $SLEEPTIME_SEC # Sever src cap: Video, Server sink cap: Tensor test -gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc num-buffers=3 ! video/x-raw,width=300,height=300,format=RGB,framerate=0/1 ! tensor_converter ! tensor_query_serversink" 7-1 0 0 $PERFORMANCE $TIMEOUT_SEC & -sleep $SLEEPTIME_SEC +rm marker.log +gst-launch-1.0 --gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc num-buffers=3 ! video/x-raw,width=300,height=300,format=RGB,framerate=0/1 ! tensor_converter ! tensor_query_serversink async=false ${WAIT4MARKER} & +pid=$! +waitformarker 7-1-T "query-server launching" gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=3 ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tee name = t t. ! queue ! multifilesink location= raw7_%1d.log t. ! queue ! tensor_query_client ! multifilesink location=result7_%1d.log" 7-2 0 0 $PERFORMANCE callCompareTest raw7_0.log result7_0.log 7-3 "Compare 7-3" 1 0 callCompareTest raw7_1.log result7_1.log 7-4 "Compare 7-4" 1 0 callCompareTest raw7_2.log result7_2.log 7-5 "Compare 7-5" 1 0 +kill -9 $pid &> /dev/null +wait $pid -sleep $SLEEPTIME_SEC # Sever src cap: Tensor, Server sink cap: Video test -gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc num-buffers=3 ! other/tensors,num_tensors=1,dimensions=3:300:300:1,types=uint8,format=static,framerate=0/1 ! tensor_decoder mode=direct_video ! videoconvert ! tensor_query_serversink" 8-1 0 0 $PERFORMANCE $TIMEOUT_SEC & -sleep $SLEEPTIME_SEC +rm marker.log +gst-launch-1.0 --gst-plugin-path=${PATH_TO_PLUGIN} tensor_query_serversrc num-buffers=3 ! other/tensors,num_tensors=1,dimensions=3:300:300:1,types=uint8,format=static,framerate=0/1 ! tensor_decoder mode=direct_video ! videoconvert ! tensor_query_serversink async=false ${WAIT4MARKER} & +pid=$! +waitformarker 8-1-T "query-server launching" gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=3 ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tensor_converter ! tee name = t t. ! queue ! multifilesink location= raw8_%1d.log t. ! queue ! tensor_query_client ! multifilesink location=result8_%1d.log" 8-2 0 0 $PERFORMANCE callCompareTest raw8_0.log result8_0.log 8-3 "Compare 8-3" 1 0 callCompareTest raw8_1.log result8_1.log 8-4 "Compare 8-4" 1 0 callCompareTest raw8_2.log result8_2.log 8-5 "Compare 8-5" 1 0 +kill -9 $pid &> /dev/null +wait $pid -sleep $SLEEPTIME_SEC # TODO enable query-hybrid test # Now nnsquery library is not available. -- 2.7.4