aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/run_tests/python_utils
diff options
context:
space:
mode:
authorGravatar Yong Ni <yongni@google.com>2017-07-05 14:56:13 -0700
committerGravatar Yong Ni <yongni@google.com>2017-07-05 14:56:13 -0700
commitef698b60cd0dc121f0d8d50f972bbcca6743905f (patch)
treeb103d0b3c6fd128e141b7900f42bb094e52b191f /tools/run_tests/python_utils
parent5f32c517b1f9ac4854039af8d0e1bb2da04f5821 (diff)
parent0c009ba2b590618fdeade42bb7ebd3034f6fd045 (diff)
Merge branch 'master' of github.com:grpc/grpc into matrix
Diffstat (limited to 'tools/run_tests/python_utils')
-rwxr-xr-xtools/run_tests/python_utils/check_bazel_dir.py41
-rwxr-xr-xtools/run_tests/python_utils/jobset.py2
-rw-r--r--tools/run_tests/python_utils/upload_test_results.py19
3 files changed, 57 insertions, 5 deletions
diff --git a/tools/run_tests/python_utils/check_bazel_dir.py b/tools/run_tests/python_utils/check_bazel_dir.py
new file mode 100755
index 0000000000..1daf6ee595
--- /dev/null
+++ b/tools/run_tests/python_utils/check_bazel_dir.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+# Copyright 2017 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.
+
+"""This sends out a warning if any changes to the bazel dir are made."""
+
+from __future__ import print_function
+from subprocess import check_output
+
+import comment_on_pr
+import os
+
+_WARNING_MESSAGE = 'WARNING: You are making changes in the Bazel subdirectory. ' \
+ 'Please get explicit approval from @nicolasnoble before merging.'
+
+
+def _get_changed_files(base_branch):
+ """
+ Get list of changed files between current branch and base of target merge branch
+ """
+ # Get file changes between branch and merge-base of specified branch
+ base_commit = check_output(["git", "merge-base", base_branch, "HEAD"]).rstrip()
+ return check_output(["git", "diff", base_commit, "--name-only"]).splitlines()
+
+
+# ghprbTargetBranch environment variable only available during a Jenkins PR tests
+if 'ghprbTargetBranch' in os.environ:
+ changed_files = _get_changed_files('origin/%s' % os.environ['ghprbTargetBranch'])
+ if any(file.startswith('bazel/') for file in changed_files):
+ comment_on_pr.comment_on_pr(_WARNING_MESSAGE)
diff --git a/tools/run_tests/python_utils/jobset.py b/tools/run_tests/python_utils/jobset.py
index b56cce1a50..044c6f3aa4 100755
--- a/tools/run_tests/python_utils/jobset.py
+++ b/tools/run_tests/python_utils/jobset.py
@@ -473,6 +473,8 @@ class Jobset(object):
while self._running:
if self.cancelled(): pass # poll cancellation
self.reap()
+ if platform_string() != 'windows':
+ signal.alarm(0)
return not self.cancelled() and self._failures == 0
diff --git a/tools/run_tests/python_utils/upload_test_results.py b/tools/run_tests/python_utils/upload_test_results.py
index 2ed3283310..580e7f7d81 100644
--- a/tools/run_tests/python_utils/upload_test_results.py
+++ b/tools/run_tests/python_utils/upload_test_results.py
@@ -30,6 +30,9 @@ import big_query_utils
_DATASET_ID = 'jenkins_test_results'
_DESCRIPTION = 'Test results from master job run on Jenkins'
+# 90 days in milliseconds
+_EXPIRATION_MS = 90 * 24 * 60 * 60 * 1000
+_PARTITION_TYPE = 'DAY'
_PROJECT_ID = 'grpc-testing'
_RESULTS_SCHEMA = [
('job_name', 'STRING', 'Name of Jenkins job'),
@@ -46,14 +49,17 @@ _RESULTS_SCHEMA = [
('elapsed_time', 'FLOAT', 'How long test took to run'),
('cpu_estimated', 'FLOAT', 'Estimated CPU usage of test'),
('cpu_measured', 'FLOAT', 'Actual CPU usage of test'),
+ ('return_code', 'INTEGER', 'Exit code of test'),
]
def _get_build_metadata(test_results):
- """Add Jenkins build metadata to test_results based on environment variables set by Jenkins."""
- build_id = os.getenv('BUILD_ID')
- build_url = os.getenv('BUILD_URL')
- job_name = os.getenv('JOB_BASE_NAME')
+ """Add Jenkins/Kokoro build metadata to test_results based on environment
+ variables set by Jenkins/Kokoro.
+ """
+ build_id = os.getenv('BUILD_ID') or os.getenv('KOKORO_BUILD_NUMBER')
+ build_url = os.getenv('BUILD_URL') or os.getenv('KOKORO_BUILD_URL')
+ job_name = os.getenv('JOB_BASE_NAME') or os.getenv('KOKORO_JOB_NAME')
if build_id:
test_results['build_id'] = build_id
@@ -62,6 +68,7 @@ def _get_build_metadata(test_results):
if job_name:
test_results['job_name'] = job_name
+
def upload_results_to_bq(resultset, bq_table, args, platform):
"""Upload test results to a BQ table.
@@ -72,7 +79,8 @@ def upload_results_to_bq(resultset, bq_table, args, platform):
platform: string name of platform tests were run on
"""
bq = big_query_utils.create_big_query()
- big_query_utils.create_table(bq, _PROJECT_ID, _DATASET_ID, bq_table, _RESULTS_SCHEMA, _DESCRIPTION)
+ big_query_utils.create_partitioned_table(bq, _PROJECT_ID, _DATASET_ID, bq_table, _RESULTS_SCHEMA, _DESCRIPTION,
+ partition_type=_PARTITION_TYPE, expiration_ms= _EXPIRATION_MS)
for shortname, results in six.iteritems(resultset):
for result in results:
@@ -89,6 +97,7 @@ def upload_results_to_bq(resultset, bq_table, args, platform):
test_results['language'] = args.language[0]
test_results['platform'] = platform
test_results['result'] = result.state
+ test_results['return_code'] = result.returncode
test_results['test_name'] = shortname
test_results['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S')