speedup C# basictests: only build C# once for coreclr and mono tests (#28587)

* only build C# once for coreclr and mono tests

* one more attempt

* only build C# once for coreclr and mono
pull/26812/head^2
Jan Tattermusch 3 years ago committed by GitHub
parent b08aba1c2a
commit a215992f0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      tools/internal_ci/linux/grpc_basictests_csharp.cfg
  2. 2
      tools/internal_ci/linux/pull_request/grpc_basictests_csharp.cfg
  3. 71
      tools/run_tests/run_tests.py
  4. 12
      tools/run_tests/run_tests_matrix.py

@ -26,5 +26,5 @@ action {
env_vars {
key: "RUN_TESTS_FLAGS"
value: "-f basictests linux csharp --inner_jobs 16 -j 2 --internal_ci --bq_result_table aggregate_results"
value: "-f basictests linux csharp --inner_jobs 4 -j 1 --internal_ci --bq_result_table aggregate_results"
}

@ -26,5 +26,5 @@ action {
env_vars {
key: "RUN_TESTS_FLAGS"
value: "-f basictests linux csharp --inner_jobs 16 -j 2 --internal_ci --max_time=3600"
value: "-f basictests linux csharp --inner_jobs 4 -j 1 --internal_ci --max_time=3600"
}

@ -877,12 +877,18 @@ class CSharpLanguage(object):
def configure(self, config, args):
self.config = config
self.args = args
_check_compiler(self.args.compiler, ['default', 'coreclr', 'mono'])
if self.args.compiler == 'default':
# test both runtimes by default
self.test_runtimes = ['coreclr', 'mono']
else:
# only test the specified runtime
self.test_runtimes = [self.args.compiler]
if self.platform == 'windows':
_check_compiler(self.args.compiler, ['default', 'coreclr'])
_check_arch(self.args.arch, ['default'])
self._cmake_arch_option = 'x64'
else:
_check_compiler(self.args.compiler, ['default', 'coreclr'])
self._docker_distro = 'buster'
def test_specs(self):
@ -891,28 +897,28 @@ class CSharpLanguage(object):
msbuild_config = _MSBUILD_CONFIG[self.config.build_config]
nunit_args = ['--labels=All', '--noresult', '--workers=1']
assembly_subdir = 'bin/%s' % msbuild_config
assembly_extension = '.exe'
if self.args.compiler == 'coreclr':
assembly_subdir += '/netcoreapp3.1'
runtime_cmd = ['dotnet', 'exec']
assembly_extension = '.dll'
else:
assembly_subdir += '/net45'
if self.platform == 'windows':
runtime_cmd = []
elif self.platform == 'mac':
# mono before version 5.2 on MacOS defaults to 32bit runtime
runtime_cmd = ['mono', '--arch=64']
specs = []
for test_runtime in self.test_runtimes:
if self.args.compiler == 'coreclr':
assembly_extension = '.dll'
assembly_subdir = 'bin/%s/netcoreapp3.1' % msbuild_config
runtime_cmd = ['dotnet', 'exec']
else:
runtime_cmd = ['mono']
assembly_extension = '.exe'
assembly_subdir = 'bin/%s/net45' % msbuild_config
if self.platform == 'windows':
runtime_cmd = []
elif self.platform == 'mac':
# mono before version 5.2 on MacOS defaults to 32bit runtime
runtime_cmd = ['mono', '--arch=64']
else:
runtime_cmd = ['mono']
for assembly in six.iterkeys(tests_by_assembly):
assembly_file = 'src/csharp/%s/%s/%s%s' % (
assembly, assembly_subdir, assembly, assembly_extension)
specs = []
for assembly in six.iterkeys(tests_by_assembly):
assembly_file = 'src/csharp/%s/%s/%s%s' % (
assembly, assembly_subdir, assembly, assembly_extension)
if self.config.build_config != 'gcov' or self.platform != 'windows':
# normally, run each test as a separate process
for test in tests_by_assembly[assembly]:
cmdline = runtime_cmd + [assembly_file,
@ -920,28 +926,8 @@ class CSharpLanguage(object):
specs.append(
self.config.job_spec(
cmdline,
shortname='csharp.%s' % test,
shortname='csharp.%s.%s' % (test_runtime, test),
environ=_FORCE_ENVIRON_FOR_WRAPPERS))
else:
# For C# test coverage, run all tests from the same assembly at once
# using OpenCover.Console (only works on Windows).
cmdline = [
'src\\csharp\\packages\\OpenCover.4.6.519\\tools\\OpenCover.Console.exe',
'-target:%s' % assembly_file, '-targetdir:src\\csharp',
'-targetargs:%s' % ' '.join(nunit_args),
'-filter:+[Grpc.Core]*', '-register:user',
'-output:src\\csharp\\coverage_csharp_%s.xml' % assembly
]
# set really high cpu_cost to make sure instances of OpenCover.Console run exclusively
# to prevent problems with registering the profiler.
run_exclusive = 1000000
specs.append(
self.config.job_spec(cmdline,
shortname='csharp.coverage.%s' %
assembly,
cpu_cost=run_exclusive,
environ=_FORCE_ENVIRON_FOR_WRAPPERS))
return specs
def pre_build_steps(self):
@ -1420,6 +1406,7 @@ argp.add_argument(
'cmake_vs2015',
'cmake_vs2017',
'cmake_vs2019',
'mono',
],
default='default',
help=

@ -201,7 +201,7 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS):
inner_jobs=inner_jobs,
timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
# C# tests on .NET desktop/mono
# C# tests (both on .NET desktop/mono and .NET core)
test_jobs += _generate_jobs(languages=['csharp'],
configs=['dbg', 'opt'],
platforms=['linux', 'macos', 'windows'],
@ -209,16 +209,6 @@ def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS):
extra_args=extra_args +
['--report_multi_target'],
inner_jobs=inner_jobs)
# C# tests on .NET core
test_jobs += _generate_jobs(languages=['csharp'],
configs=['dbg', 'opt'],
platforms=['linux', 'macos', 'windows'],
arch='default',
compiler='coreclr',
labels=['basictests', 'multilang'],
extra_args=extra_args +
['--report_multi_target'],
inner_jobs=inner_jobs)
test_jobs += _generate_jobs(languages=['python'],
configs=['opt'],

Loading…
Cancel
Save