avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kojirom...@apache.org
Subject [avro] branch master updated: AVRO-2661: Fixup Test RPC Interop (#748)
Date Thu, 19 Dec 2019 23:57:48 GMT
This is an automated email from the ASF dual-hosted git repository.

kojiromike pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new 5cca39d  AVRO-2661: Fixup Test RPC Interop (#748)
5cca39d is described below

commit 5cca39d955e831be4ca4bfcc016a7da37e158aeb
Author: Michael A. Smith <michael@smith-li.com>
AuthorDate: Thu Dec 19 18:57:38 2019 -0500

    AVRO-2661: Fixup Test RPC Interop (#748)
    
    Allow the interop rpc tests to exit gracefully.
---
 share/test/interop/bin/test_rpc_interop.sh | 70 ++++++++++++++----------------
 1 file changed, 33 insertions(+), 37 deletions(-)

diff --git a/share/test/interop/bin/test_rpc_interop.sh b/share/test/interop/bin/test_rpc_interop.sh
index 283aff1..f80437f 100755
--- a/share/test/interop/bin/test_rpc_interop.sh
+++ b/share/test/interop/bin/test_rpc_interop.sh
@@ -17,64 +17,60 @@
 
 set -ex
 
-cd `dirname "$0"`/../../../..   # connect to root
+cd "${0%/*}/../../../.."
 
-VERSION=`cat share/VERSION.txt`
+VERSION=$(<share/VERSION.txt)
 
-java_client="java -jar lang/java/tools/target/avro-tools-$VERSION.jar rpcsend"
-java_server="java -jar lang/java/tools/target/avro-tools-$VERSION.jar rpcreceive"
-
-py_client="env PYTHONPATH=lang/py python -m avro.tool rpcsend"
-py_server="env PYTHONPATH=lang/py python -m avro.tool rpcreceive"
+java_tool() {
+  java -jar "lang/java/tools/target/avro-tools-$VERSION.jar" "$@"
+}
 
-py3_client="env PYTHONPATH=lang/py3 python3 -m avro.tool rpcsend"
-py3_server="env PYTHONPATH=lang/py3 python3 -m avro.tool rpcreceive"
+py_tool() {
+  PYTHONPATH=lang/py python2 -m avro.tool "$@"
+}
 
-ruby_client="ruby -rubygems -Ilang/ruby/lib lang/ruby/test/tool.rb rpcsend"
-ruby_server="ruby -rubygems -Ilang/ruby/lib lang/ruby/test/tool.rb rpcreceive"
+py3_tool() {
+  PYTHONPATH=lang/py3 python3 -m avro.tool "$@"
+}
 
-clients=("$java_client" "$py_client" "$py3_client" "$ruby_client")
-servers=("$java_server" "$py_server" "$py3_server" "$ruby_server")
+ruby_tool() {
+  ruby -rubygems -Ilang/ruby/lib lang/ruby/test/tool.rb "$@"
+}
 
 proto=share/test/schemas/simple.avpr
 
-portfile=/tmp/interop_$$
+portfile="/tmp/interop_$$"
 
 cleanup() {
   rm -rf "$portfile"
-  for job in `jobs -p` ; do
-    kill $(jobs -p) 2>/dev/null || true;
+  for job in $(jobs -p); do
+    kill "$job" 2>/dev/null || true;
   done
 }
 
 trap 'cleanup' EXIT
 
-for server in "${servers[@]}"
-do
-  for msgDir in share/test/interop/rpc/*
-  do
-    msg=`basename "$msgDir"`
-    for c in ${msgDir}/*
-    do
-      echo TEST: $c
-      for client in "${clients[@]}"
-      do
+for server in {java,py,py3,ruby}_tool; do
+  for msgDir in share/test/interop/rpc/*; do
+    msg="${msgDir##*/}"
+    for c in "$msgDir/"*; do
+      echo "TEST: $c"
+      for client in {java,py,py3,ruby}_tool; do
         rm -rf "$portfile"
-        $server http://127.0.0.1:0/ $proto $msg -file $c/response.avro > $portfile &
+        "$server" rpcreceive 'http://127.0.0.1:0/' "$proto" "$msg" \
+          -file "$c/response.avro" > "$portfile" &
         count=0
-        while [ ! -s $portfile ]
-        do
+        until [[ -s "$portfile" ]]; do
           sleep 1
-          if [ $count -ge 10 ]
-          then
-            echo $server did not start.
+          if (( count++ >= 10 )); then
+            echo "$server did not start." >&2
             exit 1
           fi
-          count=`expr $count + 1`
-        done
-        read ignore port < $portfile
-        $client http://127.0.0.1:$port $proto $msg -file $c/request.avro
         done
+        read -r _ port < "$portfile"
+        "$client" rpcsend "http://127.0.0.1:$port" "$proto" "$msg" \
+          -file "$c/request.avro"
+      done
     done
-    done
+  done
 done


Mime
View raw message