From 44d2cc794422c86ea79ac9cbe2e4d16abb400cae Mon Sep 17 00:00:00 2001
From: Jan Tattermusch <jtattermusch@google.com>
Date: Tue, 3 Mar 2015 14:13:35 -0800
Subject: [PATCH] adding C# support to gce_setup scripts

---
 tools/gce_setup/build_images.sh         |  2 +-
 tools/gce_setup/builder.sh              |  2 +-
 tools/gce_setup/cloud_prod_runner.sh    |  2 +-
 tools/gce_setup/grpc_docker.sh          | 43 ++++++++++++++++++++-----
 tools/gce_setup/interop_test_runner.sh  |  2 +-
 tools/gce_setup/shared_startup_funcs.sh |  7 ++--
 6 files changed, 44 insertions(+), 14 deletions(-)

diff --git a/tools/gce_setup/build_images.sh b/tools/gce_setup/build_images.sh
index ea58a98608..0b1c32b7d6 100755
--- a/tools/gce_setup/build_images.sh
+++ b/tools/gce_setup/build_images.sh
@@ -35,7 +35,7 @@ main() {
   cd ../../
 
   # build images for all languages
-  languages=(cxx java go ruby node python)
+  languages=(cxx java go ruby node python csharp_mono)
   for lan in "${languages[@]}"
   do
     grpc_update_image $lan
diff --git a/tools/gce_setup/builder.sh b/tools/gce_setup/builder.sh
index d4dbd75426..8815d082da 100755
--- a/tools/gce_setup/builder.sh
+++ b/tools/gce_setup/builder.sh
@@ -37,7 +37,7 @@ main() {
   sleep 3600
 
   # build images for all languages
-  languages=(cxx java go ruby node)
+  languages=(cxx java go ruby node python csharp_mono)
   for lan in "${languages[@]}"
   do
     grpc_update_image $lan
diff --git a/tools/gce_setup/cloud_prod_runner.sh b/tools/gce_setup/cloud_prod_runner.sh
index 3760ae4979..520dfcd998 100755
--- a/tools/gce_setup/cloud_prod_runner.sh
+++ b/tools/gce_setup/cloud_prod_runner.sh
@@ -34,7 +34,7 @@ main() {
   # temporarily remove ping_pong and cancel_after_first_response while investigating timeout
   test_cases=(large_unary empty_unary client_streaming server_streaming cancel_after_begin)
   auth_test_cases=(service_account_creds compute_engine_creds)
-  clients=(cxx java go ruby node)
+  clients=(cxx java go ruby node csharp_mono)
   for test_case in "${test_cases[@]}"
   do
     for client in "${clients[@]}"
diff --git a/tools/gce_setup/grpc_docker.sh b/tools/gce_setup/grpc_docker.sh
index 02039261a3..886385679b 100755
--- a/tools/gce_setup/grpc_docker.sh
+++ b/tools/gce_setup/grpc_docker.sh
@@ -383,7 +383,7 @@ grpc_interop_test_args() {
 
   [[ -n $1 ]] && {  # client_type
     case $1 in
-      cxx|go|java|node|php|python|ruby)
+      cxx|go|java|node|php|python|ruby|csharp_mono)
         grpc_gen_test_cmd="grpc_interop_gen_$1_cmd"
         declare -F $grpc_gen_test_cmd >> /dev/null || {
           echo "-f: test_func for $1 => $grpc_gen_test_cmd is not defined" 1>&2
@@ -411,12 +411,13 @@ grpc_interop_test_args() {
 
   [[ -n $1 ]] && {  # server_type
     case $1 in
-      cxx)    grpc_port=8010 ;;
-      go)     grpc_port=8020 ;;
-      java)   grpc_port=8030 ;;
-      node)   grpc_port=8040 ;;
-      python) grpc_port=8050 ;;
-      ruby)   grpc_port=8060 ;;
+      cxx)          grpc_port=8010 ;;
+      go)           grpc_port=8020 ;;
+      java)         grpc_port=8030 ;;
+      node)         grpc_port=8040 ;;
+      python)       grpc_port=8050 ;;
+      ruby)         grpc_port=8060 ;;
+      csharp_mono)  grpc_port=8070 ;;
       *) echo "bad server_type: $1" 1>&2; return 1 ;;
     esac
     shift
@@ -454,7 +455,7 @@ grpc_cloud_prod_test_args() {
 
   [[ -n $1 ]] && {  # client_type
     case $1 in
-      cxx|go|java|node|php|python|ruby)
+      cxx|go|java|node|php|python|ruby|csharp_mono)
         grpc_gen_test_cmd="grpc_cloud_prod_gen_$1_cmd"
         declare -F $grpc_gen_test_cmd >> /dev/null || {
           echo "-f: test_func for $1 => $grpc_gen_test_cmd is not defined" 1>&2
@@ -1162,6 +1163,32 @@ grpc_cloud_prod_auth_compute_engine_creds_gen_cxx_cmd() {
     echo $the_cmd
 }
 
+# constructs the full dockerized csharp-mono interop test cmd.
+#
+# call-seq:
+#   flags= .... # generic flags to include the command
+#   cmd=$($grpc_gen_test_cmd $flags)
+grpc_interop_gen_csharp_mono_cmd() {
+  local cmd_prefix="sudo docker run grpc/csharp_mono";
+  local test_script="mono /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/Grpc.IntegrationTesting.Client.exe --use_tls=true --use_test_ca=true";
+  local the_cmd="$cmd_prefix $test_script $@";
+  echo $the_cmd
+}
+
+# constructs the full dockerized csharp-mono gce=>prod interop test cmd.
+#
+# call-seq:
+#   flags= .... # generic flags to include the command
+#   cmd=$($grpc_gen_test_cmd $flags)
+grpc_cloud_prod_gen_csharp_mono_cmd() {
+  local env_flag="-e SSL_CERT_FILE=/cacerts/roots.pem "
+  local cmd_prefix="sudo docker run $env_flag grpc/csharp_mono";
+  local test_script="mono /var/local/git/grpc/src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/Grpc.IntegrationTesting.Client.exe --use_tls=true";
+  local gfe_flags=$(_grpc_prod_gfe_flags);
+  local the_cmd="$cmd_prefix $test_script $gfe_flags $@";
+  echo $the_cmd
+}
+
 # outputs the flags passed to gfe tests
 _grpc_prod_gfe_flags() {
   echo " --server_port=443 --server_host=grpc-test.sandbox.google.com --server_host_override=grpc-test.sandbox.google.com"
diff --git a/tools/gce_setup/interop_test_runner.sh b/tools/gce_setup/interop_test_runner.sh
index 5f8c0e7064..90a78b1264 100755
--- a/tools/gce_setup/interop_test_runner.sh
+++ b/tools/gce_setup/interop_test_runner.sh
@@ -36,7 +36,7 @@ echo $result_file_name
 main() {
   source grpc_docker.sh
   test_cases=(large_unary empty_unary ping_pong client_streaming server_streaming cancel_after_begin cancel_after_first_response)
-  clients=(cxx java go ruby node)
+  clients=(cxx java go ruby node csharp_mono)
   servers=(cxx java go ruby node python)
   for test_case in "${test_cases[@]}"
   do
diff --git a/tools/gce_setup/shared_startup_funcs.sh b/tools/gce_setup/shared_startup_funcs.sh
index 195f8f28a8..e6eecc56db 100755
--- a/tools/gce_setup/shared_startup_funcs.sh
+++ b/tools/gce_setup/shared_startup_funcs.sh
@@ -364,7 +364,7 @@ grpc_docker_launch_registry() {
 grpc_docker_pull_known() {
   local addr=$1
   [[ -n $addr ]] || addr="0.0.0.0:5000"
-  local known="base cxx php_base php ruby_base ruby java_base java go node_base node python_base python"
+  local known="base cxx php_base php ruby_base ruby java_base java go node_base node python_base python csharp_mono_base csharp_mono"
   echo "... pulling docker images for '$known'"
   for i in $known
   do
@@ -429,7 +429,10 @@ grpc_dockerfile_install() {
     grpc_docker_sync_roots_pem $dockerfile_dir/cacerts || return 1;
     grpc_docker_sync_service_account $dockerfile_dir/service_account || return 1;
   }
-
+  [[ $image_label == "grpc/csharp_mono" ]] && {
+    grpc_docker_sync_roots_pem $dockerfile_dir/cacerts || return 1;
+    grpc_docker_sync_service_account $dockerfile_dir/service_account || return 1;
+  }
 
   # TODO(temiola): maybe make cache/no-cache a func option?
   sudo docker build $cache_opt -t $image_label $dockerfile_dir || {
-- 
GitLab