From 17fc384b1ee595e9e2f10071b32ea58f029d581c Mon Sep 17 00:00:00 2001
From: Jan Tattermusch <jtattermusch@google.com>
Date: Fri, 4 Oct 2019 12:47:40 +0200
Subject: [PATCH] add job config for Windows RBE opt config, upload test
 results

---
 tools/internal_ci/windows/bazel_rbe.bat       |  8 +++-
 .../windows/grpc_bazel_rbe_dbg.cfg            |  7 +++-
 .../windows/grpc_bazel_rbe_opt.cfg            | 42 +++++++++++++++++++
 .../pull_request/grpc_bazel_rbe_dbg.cfg       |  2 +-
 .../pull_request/grpc_bazel_rbe_opt.cfg       | 38 +++++++++++++++++
 5 files changed, 93 insertions(+), 4 deletions(-)
 create mode 100644 tools/internal_ci/windows/grpc_bazel_rbe_opt.cfg
 create mode 100644 tools/internal_ci/windows/pull_request/grpc_bazel_rbe_opt.cfg

diff --git a/tools/internal_ci/windows/bazel_rbe.bat b/tools/internal_ci/windows/bazel_rbe.bat
index 6fe490c81e..fdc6279dd3 100644
--- a/tools/internal_ci/windows/bazel_rbe.bat
+++ b/tools/internal_ci/windows/bazel_rbe.bat
@@ -24,9 +24,13 @@ powershell -Command "[guid]::NewGuid().ToString()" >%KOKORO_ARTIFACTS_DIR%/bazel
 set /p BAZEL_INVOCATION_ID=<%KOKORO_ARTIFACTS_DIR%/bazel_invocation_ids
 
 @rem TODO(jtattermusch): windows RBE should be able to use the same credentials as Linux RBE.
-bazel --bazelrc=tools/remote_build/windows.bazelrc test --invocation_id="%BAZEL_INVOCATION_ID%" %RUN_TESTS_FLAGS% --workspace_status_command=tools/remote_build/workspace_status_kokoro.bat --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json //test/...
+bazel --bazelrc=tools/remote_build/windows.bazelrc test --invocation_id="%BAZEL_INVOCATION_ID%" %BAZEL_FLAGS% --workspace_status_command=tools/remote_build/workspace_status_kokoro.bat --google_credentials=%KOKORO_GFILE_DIR%/rbe-windows-credentials.json //test/...
 set BAZEL_EXITCODE=%errorlevel%
 
-@rem TODO(jtattermusch): upload results to bigquery
+if not "%UPLOAD_TEST_RESULTS%"=="" (
+  @rem Sleep to let ResultStore finish writing results before querying
+  timeout /t 60 /nobreak
+  python ./tools/run_tests/python_utils/upload_rbe_results.py
+)
 
 exit /b %BAZEL_EXITCODE%
diff --git a/tools/internal_ci/windows/grpc_bazel_rbe_dbg.cfg b/tools/internal_ci/windows/grpc_bazel_rbe_dbg.cfg
index 734e1f0e39..74e5ad6148 100644
--- a/tools/internal_ci/windows/grpc_bazel_rbe_dbg.cfg
+++ b/tools/internal_ci/windows/grpc_bazel_rbe_dbg.cfg
@@ -33,7 +33,12 @@ bazel_setting {
 
 env_vars {
   # flags will be passed to bazel invocation by bazel_rbe.bat
-  key: "RUN_TESTS_FLAGS"
+  key: "BAZEL_FLAGS"
   # TODO(jtattermusch): add --config=dbg once that works
   value: "--cache_test_results=no"
 }
+
+env_vars {
+  key: "UPLOAD_TEST_RESULTS"
+  value: "true"
+}
diff --git a/tools/internal_ci/windows/grpc_bazel_rbe_opt.cfg b/tools/internal_ci/windows/grpc_bazel_rbe_opt.cfg
new file mode 100644
index 0000000000..99b60c4c5a
--- /dev/null
+++ b/tools/internal_ci/windows/grpc_bazel_rbe_opt.cfg
@@ -0,0 +1,42 @@
+# Copyright 2019 The gRPC Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Config file for the internal CI (in protobuf text format)
+
+# Location of the continuous shell script in repository.
+build_file: "grpc/tools/internal_ci/windows/bazel_rbe.bat"
+
+timeout_mins: 60
+
+gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json"
+gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/resultstore_api_key"
+gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/rbe-windows-credentials.json"
+
+bazel_setting {
+  # In order for Kokoro to recognize this as a bazel build and publish the bazel resultstore link,
+  # the bazel_setting section needs to be present and "upsalite_frontend_address" needs to be
+  # set. The rest of configuration from bazel_setting is unused (we configure everything when bazel
+  # command is invoked).
+  upsalite_frontend_address: "https://source.cloud.google.com"
+}
+
+env_vars {
+  # flags will be passed to bazel invocation by bazel_rbe.bat
+  key: "BAZEL_FLAGS"
+  value: "--cache_test_results=no --config=opt"
+}
+env_vars {
+  key: "UPLOAD_TEST_RESULTS"
+  value: "true"
+}
diff --git a/tools/internal_ci/windows/pull_request/grpc_bazel_rbe_dbg.cfg b/tools/internal_ci/windows/pull_request/grpc_bazel_rbe_dbg.cfg
index 66b36018f2..a682888c7a 100644
--- a/tools/internal_ci/windows/pull_request/grpc_bazel_rbe_dbg.cfg
+++ b/tools/internal_ci/windows/pull_request/grpc_bazel_rbe_dbg.cfg
@@ -33,7 +33,7 @@ bazel_setting {
 
 env_vars {
   # flags will be passed to bazel invocation by bazel_rbe.bat
-  key: "RUN_TESTS_FLAGS"
+  key: "BAZEL_FLAGS"
   # TODO(jtattermusch): add --config=dbg once that works
   value: ""
 }
diff --git a/tools/internal_ci/windows/pull_request/grpc_bazel_rbe_opt.cfg b/tools/internal_ci/windows/pull_request/grpc_bazel_rbe_opt.cfg
new file mode 100644
index 0000000000..027670096f
--- /dev/null
+++ b/tools/internal_ci/windows/pull_request/grpc_bazel_rbe_opt.cfg
@@ -0,0 +1,38 @@
+# Copyright 2019 The gRPC Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Config file for the internal CI (in protobuf text format)
+
+# Location of the continuous shell script in repository.
+build_file: "grpc/tools/internal_ci/windows/bazel_rbe.bat"
+
+timeout_mins: 60
+
+gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/GrpcTesting-d0eeee2db331.json"
+gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/resultstore_api_key"
+gfile_resources: "/bigstore/grpc-testing-secrets/gcp_credentials/rbe-windows-credentials.json"
+
+bazel_setting {
+  # In order for Kokoro to recognize this as a bazel build and publish the bazel resultstore link,
+  # the bazel_setting section needs to be present and "upsalite_frontend_address" needs to be
+  # set. The rest of configuration from bazel_setting is unused (we configure everything when bazel
+  # command is invoked).
+  upsalite_frontend_address: "https://source.cloud.google.com"
+}
+
+env_vars {
+  # flags will be passed to bazel invocation by bazel_rbe.bat
+  key: "BAZEL_FLAGS"
+  value: "--config=opt"
+}
-- 
GitLab