aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/run_tests/python_utils
diff options
context:
space:
mode:
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.py13
-rw-r--r--tools/run_tests/python_utils/report_utils.py33
-rw-r--r--tools/run_tests/python_utils/upload_test_results.py2
4 files changed, 33 insertions, 56 deletions
diff --git a/tools/run_tests/python_utils/check_bazel_dir.py b/tools/run_tests/python_utils/check_bazel_dir.py
deleted file mode 100755
index 1daf6ee595..0000000000
--- a/tools/run_tests/python_utils/check_bazel_dir.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/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 044c6f3aa4..08d652ae3f 100755
--- a/tools/run_tests/python_utils/jobset.py
+++ b/tools/run_tests/python_utils/jobset.py
@@ -367,9 +367,10 @@ class Jobset(object):
"""Manages one run of jobs."""
def __init__(self, check_cancelled, maxjobs, newline_on_success, travis,
- stop_on_failure, add_env, quiet_success, max_time):
+ stop_on_failure, add_env, quiet_success, max_time, clear_alarms):
self._running = set()
self._check_cancelled = check_cancelled
+ self._clear_alarms = clear_alarms
self._cancelled = False
self._failures = 0
self._completed = 0
@@ -473,7 +474,10 @@ class Jobset(object):
while self._running:
if self.cancelled(): pass # poll cancellation
self.reap()
- if platform_string() != 'windows':
+ # Clear the alarms when finished to avoid a race condition causing job
+ # failures. Don't do this when running multi-VM tests because clearing
+ # the alarms causes the test to stall
+ if platform_string() != 'windows' and self._clear_alarms:
signal.alarm(0)
return not self.cancelled() and self._failures == 0
@@ -503,7 +507,8 @@ def run(cmdlines,
add_env={},
skip_jobs=False,
quiet_success=False,
- max_time=-1):
+ max_time=-1,
+ clear_alarms=True):
if skip_jobs:
resultset = {}
skipped_job_result = JobResult()
@@ -515,7 +520,7 @@ def run(cmdlines,
js = Jobset(check_cancelled,
maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS,
newline_on_success, travis, stop_on_failure, add_env,
- quiet_success, max_time)
+ quiet_success, max_time, clear_alarms)
for cmdline, remaining in tag_remaining(cmdlines):
if not js.start(cmdline):
break
diff --git a/tools/run_tests/python_utils/report_utils.py b/tools/run_tests/python_utils/report_utils.py
index 4b4c50a03e..a3867808b5 100644
--- a/tools/run_tests/python_utils/report_utils.py
+++ b/tools/run_tests/python_utils/report_utils.py
@@ -22,6 +22,7 @@ try:
from mako import exceptions
except (ImportError):
pass # Mako not installed but it is ok.
+import datetime
import os
import string
import xml.etree.cElementTree as ET
@@ -43,12 +44,29 @@ def _filter_msg(msg, output_format):
return msg
-def render_junit_xml_report(resultset, xml_report, suite_package='grpc',
+def new_junit_xml_tree():
+ return ET.ElementTree(ET.Element('testsuites'))
+
+def render_junit_xml_report(resultset, report_file, suite_package='grpc',
suite_name='tests'):
"""Generate JUnit-like XML report."""
- root = ET.Element('testsuites')
- testsuite = ET.SubElement(root, 'testsuite', id='1', package=suite_package,
- name=suite_name)
+ tree = new_junit_xml_tree()
+ append_junit_xml_results(tree, resultset, suite_package, suite_name, '1')
+ create_xml_report_file(tree, report_file)
+
+def create_xml_report_file(tree, report_file):
+ """Generate JUnit-like report file from xml tree ."""
+ # ensure the report directory exists
+ report_dir = os.path.dirname(os.path.abspath(report_file))
+ if not os.path.exists(report_dir):
+ os.makedirs(report_dir)
+ tree.write(report_file, encoding='UTF-8')
+
+def append_junit_xml_results(tree, resultset, suite_package, suite_name, id):
+ """Append a JUnit-like XML report tree with test results as a new suite."""
+ testsuite = ET.SubElement(tree.getroot(), 'testsuite',
+ id=id, package=suite_package, name=suite_name,
+ timestamp=datetime.datetime.now().isoformat())
failure_count = 0
error_count = 0
for shortname, results in six.iteritems(resultset):
@@ -67,13 +85,6 @@ def render_junit_xml_report(resultset, xml_report, suite_package='grpc',
ET.SubElement(xml_test, 'skipped', message='Skipped')
testsuite.set('failures', str(failure_count))
testsuite.set('errors', str(error_count))
- # ensure the report directory exists
- report_dir = os.path.dirname(os.path.abspath(xml_report))
- if not os.path.exists(report_dir):
- os.makedirs(report_dir)
- tree = ET.ElementTree(root)
- tree.write(xml_report, encoding='UTF-8')
-
def render_interop_html_report(
client_langs, server_langs, test_cases, auth_test_cases, http2_cases,
diff --git a/tools/run_tests/python_utils/upload_test_results.py b/tools/run_tests/python_utils/upload_test_results.py
index 24c3ec94ae..580e7f7d81 100644
--- a/tools/run_tests/python_utils/upload_test_results.py
+++ b/tools/run_tests/python_utils/upload_test_results.py
@@ -49,6 +49,7 @@ _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'),
]
@@ -96,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')