aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/run_tests
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-07-14 13:58:42 -0700
committerGravatar Mark D. Roth <roth@google.com>2016-07-14 13:58:42 -0700
commitef31ba1e03ad55b0c46b5dd8b5ed38eec555412b (patch)
treeb9d4138c26b66621a003ee7552af01ee8e5d237e /tools/run_tests
parentdba5d2708c6d59a73b65d378440dc64b3af2b873 (diff)
parent1198da0b5c95b8444e4f282349f5d1f47db76525 (diff)
Merge remote-tracking branch 'upstream/master' into handshake_api
Diffstat (limited to 'tools/run_tests')
-rw-r--r--tools/run_tests/artifact_targets.py2
-rw-r--r--tools/run_tests/build_artifact_python.bat23
-rwxr-xr-xtools/run_tests/build_python.sh13
-rw-r--r--tools/run_tests/distribtest_targets.py2
-rwxr-xr-xtools/run_tests/dockerjob.py4
-rwxr-xr-xtools/run_tests/jobset.py8
-rw-r--r--tools/run_tests/package_targets.py2
-rwxr-xr-xtools/run_tests/port_server.py12
-rw-r--r--tools/run_tests/report_utils.py8
-rwxr-xr-xtools/run_tests/run_interop_tests.py28
-rwxr-xr-xtools/run_tests/run_performance_tests.py12
-rwxr-xr-xtools/run_tests/run_stress_tests.py16
-rwxr-xr-xtools/run_tests/run_tests.py97
-rwxr-xr-xtools/run_tests/task_runner.py4
14 files changed, 111 insertions, 120 deletions
diff --git a/tools/run_tests/artifact_targets.py b/tools/run_tests/artifact_targets.py
index bd1269ceb7..e9267be58b 100644
--- a/tools/run_tests/artifact_targets.py
+++ b/tools/run_tests/artifact_targets.py
@@ -40,7 +40,7 @@ def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={},
environ['RUN_COMMAND'] = shell_command
docker_args=[]
- for k,v in environ.iteritems():
+ for k,v in environ.items():
docker_args += ['-e', '%s=%s' % (k, v)]
docker_env = {'DOCKERFILE_DIR': dockerfile_dir,
'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh',
diff --git a/tools/run_tests/build_artifact_python.bat b/tools/run_tests/build_artifact_python.bat
index 7c8c2aa12d..a7b1a58284 100644
--- a/tools/run_tests/build_artifact_python.bat
+++ b/tools/run_tests/build_artifact_python.bat
@@ -34,29 +34,6 @@ pip install --upgrade six
pip install --upgrade setuptools
pip install -rrequirements.txt
-@rem Because this is windows and *everything seems to hate Windows* we have to
-@rem set all of these flags ourselves because Python won't help us (see the
-@rem setup.py of the grpcio_tools project).
-set GRPC_PYTHON_CFLAGS=-fno-wrapv -frtti -std=c++11
-
-@rem See https://sourceforge.net/p/mingw-w64/bugs/363/
-if %2 == 32 (
- set GRPC_PYTHON_CFLAGS=%GRPC_PYTHON_CFLAGS% -D_ftime=_ftime32 -D_timeb=__timeb32 -D_ftime_s=_ftime32_s
-) else (
- set GRPC_PYTHON_CFLAGS=%GRPC_PYTHON_CFLAGS% -D_ftime=_ftime64 -D_timeb=__timeb64
-)
-
-@rem Further confusing things, MSYS2's mingw64 tries to dynamically link
-@rem libgcc, libstdc++, and winpthreads. We have to override this or our
-@rem extensions end up linking to MSYS2 DLLs, which the normal Python on
-@rem Windows user won't have... and ON TOP OF THIS, there's MinGW's GCC default
-@rem behavior of linking msvcrt.dll as the C runtime library, which we need to
-@rem override so that Python's distutils doesn't link us against multiple C
-@rem runtimes.
-python -c "from distutils.cygwinccompiler import get_msvcr; print(get_msvcr()[0])" > temp.txt
-set /p PYTHON_MSVCR=<temp.txt
-set GRPC_PYTHON_LDFLAGS=-static-libgcc -static-libstdc++ -mcrtdll=%PYTHON_MSVCR% -static -lpthread
-
set GRPC_PYTHON_BUILD_WITH_CYTHON=1
diff --git a/tools/run_tests/build_python.sh b/tools/run_tests/build_python.sh
index a3fa8200d5..9cb3cb12a9 100755
--- a/tools/run_tests/build_python.sh
+++ b/tools/run_tests/build_python.sh
@@ -127,19 +127,6 @@ if [ $(is_linux) ]; then
fi
fi
fi
-# TODO(atash) consider conceptualizing MinGW as a first-class platform and move
-# these flags into our `setup.py`s
-if [ $(is_mingw) ]; then
- # We're on MinGW, and our CFLAGS and LDFLAGS will be eaten by the void. Use
- # our work-around environment variables instead.
- PYTHON_MSVCR=`$PYTHON -c "from distutils.cygwinccompiler import get_msvcr; print(get_msvcr()[0])"`
- export GRPC_PYTHON_LDFLAGS="-static-libgcc -static-libstdc++ -mcrtdll=$PYTHON_MSVCR -static -lpthread"
- # See https://sourceforge.net/p/mingw-w64/bugs/363/
- export GRPC_PYTHON_CFLAGS="-D_ftime=_ftime64 -D_timeb=__timeb64"
- # TODO(atash) set these flags for only grpcio-tools (they don't do any harm to
- # grpcio, but they result in noisy warnings).
- export GRPC_PYTHON_CFLAGS="-frtti -std=c++11 $GRPC_PYTHON_CFLAGS"
-fi
############################
# Perform build operations #
diff --git a/tools/run_tests/distribtest_targets.py b/tools/run_tests/distribtest_targets.py
index 1a7aa0bfc8..7930f2a0a4 100644
--- a/tools/run_tests/distribtest_targets.py
+++ b/tools/run_tests/distribtest_targets.py
@@ -41,7 +41,7 @@ def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={},
environ['RELATIVE_COPY_PATH'] = 'test/distrib'
docker_args=[]
- for k,v in environ.iteritems():
+ for k,v in environ.items():
docker_args += ['-e', '%s=%s' % (k, v)]
docker_env = {'DOCKERFILE_DIR': dockerfile_dir,
'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh'}
diff --git a/tools/run_tests/dockerjob.py b/tools/run_tests/dockerjob.py
index e4ca3b7faa..4a7e61b3c4 100755
--- a/tools/run_tests/dockerjob.py
+++ b/tools/run_tests/dockerjob.py
@@ -29,6 +29,8 @@
"""Helpers to run docker instances as jobs."""
+from __future__ import print_function
+
import jobset
import tempfile
import time
@@ -95,7 +97,7 @@ def remove_image(image, skip_nonexistent=False, max_retries=10):
stderr=subprocess.STDOUT) == 0:
return True
time.sleep(2)
- print 'Failed to remove docker image %s' % image
+ print('Failed to remove docker image %s' % image)
return False
diff --git a/tools/run_tests/jobset.py b/tools/run_tests/jobset.py
index 3999537c40..b6fb6318e0 100755
--- a/tools/run_tests/jobset.py
+++ b/tools/run_tests/jobset.py
@@ -29,6 +29,8 @@
"""Run a group of subprocesses and then finish."""
+from __future__ import print_function
+
import multiprocessing
import os
import platform
@@ -123,8 +125,8 @@ def message(tag, msg, explanatory_text=None, do_newline=False):
try:
if platform_string() == 'windows' or not sys.stdout.isatty():
if explanatory_text:
- print explanatory_text
- print '%s: %s' % (tag, msg)
+ print(explanatory_text)
+ print('%s: %s' % (tag, msg))
return
sys.stdout.write('%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' % (
_BEGINNING_OF_LINE,
@@ -368,7 +370,7 @@ class Jobset(object):
self._travis,
self._add_env)
self._running.add(job)
- if not self.resultset.has_key(job.GetSpec().shortname):
+ if job.GetSpec().shortname not in self.resultset:
self.resultset[job.GetSpec().shortname] = []
return True
diff --git a/tools/run_tests/package_targets.py b/tools/run_tests/package_targets.py
index 39a11a243d..ce3f08dfbc 100644
--- a/tools/run_tests/package_targets.py
+++ b/tools/run_tests/package_targets.py
@@ -39,7 +39,7 @@ def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={},
environ['RUN_COMMAND'] = shell_command
docker_args=[]
- for k,v in environ.iteritems():
+ for k,v in environ.items():
docker_args += ['-e', '%s=%s' % (k, v)]
docker_env = {'DOCKERFILE_DIR': dockerfile_dir,
'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh',
diff --git a/tools/run_tests/port_server.py b/tools/run_tests/port_server.py
index 83f8e6cd35..e9b3f7ff79 100755
--- a/tools/run_tests/port_server.py
+++ b/tools/run_tests/port_server.py
@@ -30,8 +30,10 @@
"""Manage TCP ports for unit tests; started by run_tests.py"""
+from __future__ import print_function
+
import argparse
-import BaseHTTPServer
+from six.moves import BaseHTTPServer
import hashlib
import os
import socket
@@ -46,7 +48,7 @@ _MY_VERSION = 9
if len(sys.argv) == 2 and sys.argv[1] == 'dump_version':
- print _MY_VERSION
+ print(_MY_VERSION)
sys.exit(0)
@@ -62,7 +64,7 @@ if args.logfile is not None:
sys.stderr = open(args.logfile, 'w')
sys.stdout = sys.stderr
-print 'port server running on port %d' % args.port
+print('port server running on port %d' % args.port)
pool = []
in_use = {}
@@ -152,7 +154,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
self.send_header('Content-Type', 'text/plain')
self.end_headers()
now = time.time()
- self.wfile.write(yaml.dump({'pool': pool, 'in_use': dict((k, now - v) for k, v in in_use.iteritems())}))
+ self.wfile.write(yaml.dump({'pool': pool, 'in_use': dict((k, now - v) for k, v in in_use.items())}))
elif self.path == '/quitquitquit':
self.send_response(200)
self.end_headers()
@@ -164,4 +166,4 @@ while keep_running:
httpd.handle_request()
sys.stderr.flush()
-print 'done'
+print('done')
diff --git a/tools/run_tests/report_utils.py b/tools/run_tests/report_utils.py
index 35dcaca3d3..5648a694cd 100644
--- a/tools/run_tests/report_utils.py
+++ b/tools/run_tests/report_utils.py
@@ -29,6 +29,8 @@
"""Generate XML and HTML test reports."""
+from __future__ import print_function
+
try:
from mako.runtime import Context
from mako.template import Template
@@ -60,7 +62,7 @@ def render_junit_xml_report(resultset, xml_report):
root = ET.Element('testsuites')
testsuite = ET.SubElement(root, 'testsuite', id='1', package='grpc',
name='tests')
- for shortname, results in resultset.iteritems():
+ for shortname, results in resultset.items():
for result in results:
xml_test = ET.SubElement(testsuite, 'testcase', name=shortname)
if result.elapsed_time:
@@ -83,10 +85,10 @@ def render_interop_html_report(
try:
mytemplate = Template(filename=template_file, format_exceptions=True)
except NameError:
- print 'Mako template is not installed. Skipping HTML report generation.'
+ print('Mako template is not installed. Skipping HTML report generation.')
return
except IOError as e:
- print 'Failed to find the template %s: %s' % (template_file, e)
+ print('Failed to find the template %s: %s' % (template_file, e))
return
sorted_test_cases = sorted(test_cases)
diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py
index 13a4a49325..f9065c5bfd 100755
--- a/tools/run_tests/run_interop_tests.py
+++ b/tools/run_tests/run_interop_tests.py
@@ -30,6 +30,8 @@
"""Run interop (cross-language) tests in parallel."""
+from __future__ import print_function
+
import argparse
import atexit
import dockerjob
@@ -372,7 +374,7 @@ def docker_run_cmdline(cmdline, image, docker_args=[], cwd=None, environ=None):
# turn environ into -e docker args
if environ:
- for k,v in environ.iteritems():
+ for k,v in environ.items():
docker_cmdline += ['-e', '%s=%s' % (k,v)]
# set working directory
@@ -674,15 +676,15 @@ servers = set(s for s in itertools.chain.from_iterable(_SERVERS
if args.use_docker:
if not args.travis:
- print 'Seen --use_docker flag, will run interop tests under docker.'
- print
- print 'IMPORTANT: The changes you are testing need to be locally committed'
- print 'because only the committed changes in the current branch will be'
- print 'copied to the docker environment.'
+ print('Seen --use_docker flag, will run interop tests under docker.')
+ print('')
+ print('IMPORTANT: The changes you are testing need to be locally committed')
+ print('because only the committed changes in the current branch will be')
+ print('copied to the docker environment.')
time.sleep(5)
if not args.use_docker and servers:
- print 'Running interop servers is only supported with --use_docker option enabled.'
+ print('Running interop servers is only supported with --use_docker option enabled.')
sys.exit(1)
languages = set(_LANGUAGES[l]
@@ -768,7 +770,7 @@ try:
(server_host, server_port) = server[1].split(':')
server_addresses[server_name] = (server_host, server_port)
- for server_name, server_address in server_addresses.iteritems():
+ for server_name, server_address in server_addresses.items():
(server_host, server_port) = server_address
server_language = _LANGUAGES.get(server_name, None)
skip_server = [] # test cases unimplemented by server
@@ -800,7 +802,7 @@ try:
jobs.append(test_job)
if not jobs:
- print 'No jobs to run.'
+ print('No jobs to run.')
for image in docker_images.itervalues():
dockerjob.remove_image(image, skip_nonexistent=True)
sys.exit(1)
@@ -814,7 +816,7 @@ try:
report_utils.render_junit_xml_report(resultset, 'report.xml')
- for name, job in resultset.iteritems():
+ for name, job in resultset.items():
if "http2" in name:
job[0].http2results = aggregate_http2_results(job[0].message)
@@ -826,12 +828,12 @@ try:
finally:
# Check if servers are still running.
- for server, job in server_jobs.iteritems():
+ for server, job in server_jobs.items():
if not job.is_running():
- print 'Server "%s" has exited prematurely.' % server
+ print('Server "%s" has exited prematurely.' % server)
dockerjob.finish_jobs([j for j in server_jobs.itervalues()])
for image in docker_images.itervalues():
- print 'Removing docker image %s' % image
+ print('Removing docker image %s' % image)
dockerjob.remove_image(image)
diff --git a/tools/run_tests/run_performance_tests.py b/tools/run_tests/run_performance_tests.py
index 14901caf07..5fdf7a407d 100755
--- a/tools/run_tests/run_performance_tests.py
+++ b/tools/run_tests/run_performance_tests.py
@@ -30,6 +30,8 @@
"""Run performance tests locally or remotely."""
+from __future__ import print_function
+
import argparse
import itertools
import jobset
@@ -310,7 +312,7 @@ def create_scenarios(languages, workers_by_lang, remote_host=None, regex='.*',
'in the same scenario')
if custom_server_lang:
if not workers_by_lang.get(custom_server_lang, []):
- print 'Warning: Skipping scenario %s as' % scenario_json['name']
+ print('Warning: Skipping scenario %s as' % scenario_json['name'])
print('SERVER_LANGUAGE is set to %s yet the language has '
'not been selected with -l' % custom_server_lang)
continue
@@ -319,7 +321,7 @@ def create_scenarios(languages, workers_by_lang, remote_host=None, regex='.*',
workers[idx] = workers_by_lang[custom_server_lang][idx]
if custom_client_lang:
if not workers_by_lang.get(custom_client_lang, []):
- print 'Warning: Skipping scenario %s as' % scenario_json['name']
+ print('Warning: Skipping scenario %s as' % scenario_json['name'])
print('CLIENT_LANGUAGE is set to %s yet the language has '
'not been selected with -l' % custom_client_lang)
continue
@@ -344,14 +346,14 @@ def finish_qps_workers(jobs):
while any(job.is_running() for job in jobs):
for job in qpsworker_jobs:
if job.is_running():
- print 'QPS worker "%s" is still running.' % job.host_and_port
+ print('QPS worker "%s" is still running.' % job.host_and_port)
if retries > 10:
- print 'Killing all QPS workers.'
+ print('Killing all QPS workers.')
for job in jobs:
job.kill()
retries += 1
time.sleep(3)
- print 'All QPS workers finished.'
+ print('All QPS workers finished.')
argp = argparse.ArgumentParser(description='Run performance tests.')
diff --git a/tools/run_tests/run_stress_tests.py b/tools/run_tests/run_stress_tests.py
index e42ee24ffb..de4a22877c 100755
--- a/tools/run_tests/run_stress_tests.py
+++ b/tools/run_tests/run_stress_tests.py
@@ -29,6 +29,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Run stress test in C++"""
+from __future__ import print_function
+
import argparse
import atexit
import dockerjob
@@ -93,7 +95,7 @@ def docker_run_cmdline(cmdline, image, docker_args=[], cwd=None, environ=None):
# turn environ into -e docker args
if environ:
- for k, v in environ.iteritems():
+ for k, v in environ.items():
docker_cmdline += ['-e', '%s=%s' % (k, v)]
# set working directory
@@ -140,7 +142,7 @@ def cloud_to_cloud_jobspec(language,
'--num_channels_per_server=%s' % num_channels_per_server,
'--metrics_port=%s' % metrics_port
]))
- print cmdline
+ print(cmdline)
cwd = language.client_cwd
environ = language.global_env()
if docker_image:
@@ -287,7 +289,7 @@ try:
(server_host, server_port) = server[1].split(':')
server_addresses[server_name] = (server_host, server_port)
- for server_name, server_address in server_addresses.iteritems():
+ for server_name, server_address in server_addresses.items():
(server_host, server_port) = server_address
for language in languages:
test_job = cloud_to_cloud_jobspec(
@@ -302,7 +304,7 @@ try:
jobs.append(test_job)
if not jobs:
- print 'No jobs to run.'
+ print('No jobs to run.')
for image in docker_images.itervalues():
dockerjob.remove_image(image, skip_nonexistent=True)
sys.exit(1)
@@ -317,12 +319,12 @@ try:
finally:
# Check if servers are still running.
- for server, job in server_jobs.iteritems():
+ for server, job in server_jobs.items():
if not job.is_running():
- print 'Server "%s" has exited prematurely.' % server
+ print('Server "%s" has exited prematurely.' % server)
dockerjob.finish_jobs([j for j in server_jobs.itervalues()])
for image in docker_images.itervalues():
- print 'Removing docker image %s' % image
+ print('Removing docker image %s' % image)
dockerjob.remove_image(image)
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index f081887fc0..59d2cad856 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -30,6 +30,8 @@
"""Run tests in parallel."""
+from __future__ import print_function
+
import argparse
import ast
import collections
@@ -48,7 +50,7 @@ import sys
import tempfile
import traceback
import time
-import urllib2
+from six.moves import urllib
import uuid
import jobset
@@ -93,7 +95,7 @@ class Config(object):
would like to run
"""
actual_environ = self.environ.copy()
- for k, v in environ.iteritems():
+ for k, v in environ.items():
actual_environ[k] = v
return jobset.JobSpec(cmdline=self.tool_prefix + cmdline,
shortname=shortname,
@@ -202,7 +204,7 @@ class CLanguage(object):
flaky=target.get('flaky', False),
environ=env))
elif self.args.regex == '.*' or self.platform == 'windows':
- print '\nWARNING: binary not found, skipping', binary
+ print('\nWARNING: binary not found, skipping', binary)
return sorted(out)
def make_targets(self):
@@ -393,7 +395,7 @@ class PythonLanguage(object):
return [self.config.job_spec(
config.run,
timeout_seconds=5*60,
- environ=dict(environment.items() +
+ environ=dict(list(environment.items()) +
[('GRPC_PYTHON_TESTRUNNER_FILTER', suite_name)]),
shortname='%s.test.%s' % (config.name, suite_name),)
for suite_name in tests_json
@@ -418,7 +420,10 @@ class PythonLanguage(object):
return 'Makefile'
def dockerfile_dir(self):
- return 'tools/dockerfile/test/python_jessie_%s' % _docker_arch_suffix(self.args.arch)
+ return 'tools/dockerfile/test/python_%s_%s' % (self.python_manager_name(), _docker_arch_suffix(self.args.arch))
+
+ def python_manager_name(self):
+ return 'pyenv' if self.args.compiler in ['python3.5', 'python3.6'] else 'jessie'
def _get_pythons(self, args):
if args.arch == 'x86':
@@ -453,6 +458,8 @@ class PythonLanguage(object):
shell + runner + [os.path.join(name, venv_relative_python[0])])
python27_config = python_config_generator(name='py27', major='2', minor='7', bits=bits)
python34_config = python_config_generator(name='py34', major='3', minor='4', bits=bits)
+ python35_config = python_config_generator(name='py35', major='3', minor='5', bits=bits)
+ python36_config = python_config_generator(name='py36', major='3', minor='6', bits=bits)
if args.compiler == 'default':
if os.name == 'nt':
return (python27_config,)
@@ -462,6 +469,10 @@ class PythonLanguage(object):
return (python27_config,)
elif args.compiler == 'python3.4':
return (python34_config,)
+ elif args.compiler == 'python3.5':
+ return (python35_config,)
+ elif args.compiler == 'python3.6':
+ return (python36_config,)
else:
raise Exception('Compiler %s not supported.' % args.compiler)
@@ -662,7 +673,7 @@ class ObjCLanguage(object):
return []
def make_targets(self):
- return ['grpc_objective_c_plugin', 'interop_server']
+ return ['interop_server']
def make_options(self):
return []
@@ -755,7 +766,7 @@ def _windows_arch_option(arch):
elif arch == 'x64':
return '/p:Platform=x64'
else:
- print 'Architecture %s not supported.' % arch
+ print('Architecture %s not supported.' % arch)
sys.exit(1)
@@ -773,11 +784,11 @@ def _check_arch_option(arch):
elif runtime_arch == '32bit' and arch == 'x86':
return
else:
- print 'Architecture %s does not match current runtime architecture.' % arch
+ print('Architecture %s does not match current runtime architecture.' % arch)
sys.exit(1)
else:
if args.arch != 'default':
- print 'Architecture %s not supported on current platform.' % args.arch
+ print('Architecture %s not supported on current platform.' % args.arch)
sys.exit(1)
@@ -791,7 +802,7 @@ def _windows_build_bat(compiler):
elif compiler == 'vs2010':
return 'vsprojects\\build_vs2010.bat'
else:
- print 'Compiler %s not supported.' % compiler
+ print('Compiler %s not supported.' % compiler)
sys.exit(1)
@@ -805,7 +816,7 @@ def _windows_toolset_option(compiler):
elif compiler == 'vs2010':
return '/p:PlatformToolset=v100'
else:
- print 'Compiler %s not supported.' % compiler
+ print('Compiler %s not supported.' % compiler)
sys.exit(1)
@@ -816,7 +827,7 @@ def _docker_arch_suffix(arch):
elif arch == 'x86':
return 'x86'
else:
- print 'Architecture %s not supported with current settings.' % arch
+ print('Architecture %s not supported with current settings.' % arch)
sys.exit(1)
@@ -893,7 +904,7 @@ argp.add_argument('--compiler',
'gcc4.4', 'gcc4.6', 'gcc4.9', 'gcc5.3',
'clang3.4', 'clang3.5', 'clang3.6', 'clang3.7',
'vs2010', 'vs2013', 'vs2015',
- 'python2.7', 'python3.4',
+ 'python2.7', 'python3.4', 'python3.5', 'python3.6',
'node0.12', 'node4', 'node5',
'coreclr'],
default='default',
@@ -932,7 +943,7 @@ for spec in args.update_submodules:
branch = spec[1]
cwd = 'third_party/%s' % submodule
def git(cmd, cwd=cwd):
- print 'in %s: git %s' % (cwd, cmd)
+ print('in %s: git %s' % (cwd, cmd))
subprocess.check_call('git %s' % cmd, cwd=cwd, shell=True)
git('fetch')
git('checkout %s' % branch)
@@ -943,8 +954,8 @@ if need_to_regenerate_projects:
if jobset.platform_string() == 'linux':
subprocess.check_call('tools/buildgen/generate_projects.sh', shell=True)
else:
- print 'WARNING: may need to regenerate projects, but since we are not on'
- print ' Linux this step is being skipped. Compilation MAY fail.'
+ print('WARNING: may need to regenerate projects, but since we are not on')
+ print(' Linux this step is being skipped. Compilation MAY fail.')
# grab config
@@ -971,18 +982,18 @@ for l in languages:
language_make_options=[]
if any(language.make_options() for language in languages):
if not 'gcov' in args.config and len(languages) != 1:
- print 'languages with custom make options cannot be built simultaneously with other languages'
+ print('languages with custom make options cannot be built simultaneously with other languages')
sys.exit(1)
else:
language_make_options = next(iter(languages)).make_options()
if args.use_docker:
if not args.travis:
- print 'Seen --use_docker flag, will run tests under docker.'
- print
- print 'IMPORTANT: The changes you are testing need to be locally committed'
- print 'because only the committed changes in the current branch will be'
- print 'copied to the docker environment.'
+ print('Seen --use_docker flag, will run tests under docker.')
+ print('')
+ print('IMPORTANT: The changes you are testing need to be locally committed')
+ print('because only the committed changes in the current branch will be')
+ print('copied to the docker environment.')
time.sleep(5)
dockerfile_dirs = set([l.dockerfile_dir() for l in languages])
@@ -1066,7 +1077,7 @@ build_steps = list(set(
for l in languages
for cmdline in l.pre_build_steps()))
if make_targets:
- make_commands = itertools.chain.from_iterable(make_jobspec(build_config, list(targets), makefile) for (makefile, targets) in make_targets.iteritems())
+ make_commands = itertools.chain.from_iterable(make_jobspec(build_config, list(targets), makefile) for (makefile, targets) in make_targets.items())
build_steps.extend(set(make_commands))
build_steps.extend(set(
jobset.JobSpec(cmdline, environ=build_step_environ(build_config), timeout_seconds=None)
@@ -1083,13 +1094,13 @@ forever = args.forever
def _shut_down_legacy_server(legacy_server_port):
try:
- version = int(urllib2.urlopen(
+ version = int(urllib.request.urlopen(
'http://localhost:%d/version_number' % legacy_server_port,
timeout=10).read())
except:
pass
else:
- urllib2.urlopen(
+ urllib.request.urlopen(
'http://localhost:%d/quitquitquit' % legacy_server_port).read()
@@ -1111,29 +1122,29 @@ def _start_port_server(port_server_port):
# if not running ==> start a new one
# otherwise, leave it up
try:
- version = int(urllib2.urlopen(
+ version = int(urllib.request.urlopen(
'http://localhost:%d/version_number' % port_server_port,
timeout=10).read())
- print 'detected port server running version %d' % version
+ print('detected port server running version %d' % version)
running = True
except Exception as e:
- print 'failed to detect port server: %s' % sys.exc_info()[0]
- print e.strerror
+ print('failed to detect port server: %s' % sys.exc_info()[0])
+ print(e.strerror)
running = False
if running:
current_version = int(subprocess.check_output(
[sys.executable, os.path.abspath('tools/run_tests/port_server.py'),
'dump_version']))
- print 'my port server is version %d' % current_version
+ print('my port server is version %d' % current_version)
running = (version >= current_version)
if not running:
- print 'port_server version mismatch: killing the old one'
- urllib2.urlopen('http://localhost:%d/quitquitquit' % port_server_port).read()
+ print('port_server version mismatch: killing the old one')
+ urllib.request.urlopen('http://localhost:%d/quitquitquit' % port_server_port).read()
time.sleep(1)
if not running:
fd, logfile = tempfile.mkstemp()
os.close(fd)
- print 'starting port_server, with log file %s' % logfile
+ print('starting port_server, with log file %s' % logfile)
args = [sys.executable, os.path.abspath('tools/run_tests/port_server.py'),
'-p', '%d' % port_server_port, '-l', logfile]
env = dict(os.environ)
@@ -1159,34 +1170,34 @@ def _start_port_server(port_server_port):
waits = 0
while True:
if waits > 10:
- print 'killing port server due to excessive start up waits'
+ print('killing port server due to excessive start up waits')
port_server.kill()
if port_server.poll() is not None:
- print 'port_server failed to start'
+ print('port_server failed to start')
# try one final time: maybe another build managed to start one
time.sleep(1)
try:
- urllib2.urlopen('http://localhost:%d/get' % port_server_port,
+ urllib.request.urlopen('http://localhost:%d/get' % port_server_port,
timeout=1).read()
- print 'last ditch attempt to contact port server succeeded'
+ print('last ditch attempt to contact port server succeeded')
break
except:
traceback.print_exc()
port_log = open(logfile, 'r').read()
- print port_log
+ print(port_log)
sys.exit(1)
try:
- urllib2.urlopen('http://localhost:%d/get' % port_server_port,
+ urllib.request.urlopen('http://localhost:%d/get' % port_server_port,
timeout=1).read()
- print 'port server is up and ready'
+ print('port server is up and ready')
break
except socket.timeout:
- print 'waiting for port_server: timeout'
+ print('waiting for port_server: timeout')
traceback.print_exc();
time.sleep(1)
waits += 1
- except urllib2.URLError:
- print 'waiting for port_server: urlerror'
+ except urllib.error.URLError:
+ print('waiting for port_server: urlerror')
traceback.print_exc();
time.sleep(1)
waits += 1
diff --git a/tools/run_tests/task_runner.py b/tools/run_tests/task_runner.py
index b42aa17cbb..2e3fa443b9 100755
--- a/tools/run_tests/task_runner.py
+++ b/tools/run_tests/task_runner.py
@@ -30,6 +30,8 @@
"""Runs selected gRPC test/build tasks."""
+from __future__ import print_function
+
import argparse
import atexit
import jobset
@@ -111,7 +113,7 @@ build_jobs = []
for target in targets:
build_jobs.append(target.build_jobspec())
if not build_jobs:
- print 'Nothing to build.'
+ print('Nothing to build.')
sys.exit(1)
jobset.message('START', 'Building targets.', do_newline=True)