2 # Copyright 2016 gRPC authors.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 """Definition of targets run distribution package tests."""
20 sys.path.insert(0, os.path.abspath('..'))
21 import python_utils.jobset as jobset
24 def create_docker_jobspec(name,
31 timeout_seconds=30 * 60):
32 """Creates jobspec for a task running under docker."""
33 environ = environ.copy()
34 environ['RUN_COMMAND'] = shell_command
35 # the entire repo will be cloned if copy_rel_path is not set.
37 environ['RELATIVE_COPY_PATH'] = copy_rel_path
40 for k, v in environ.items():
41 docker_args += ['-e', '%s=%s' % (k, v)]
43 'DOCKERFILE_DIR': dockerfile_dir,
44 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh'
46 jobspec = jobset.JobSpec(
47 cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] +
50 shortname='distribtest.%s' % (name),
51 timeout_seconds=timeout_seconds,
52 flake_retries=flake_retries,
53 timeout_retries=timeout_retries)
57 def create_jobspec(name,
64 timeout_seconds=10 * 60):
65 """Creates jobspec."""
66 environ = environ.copy()
68 environ['WORKSPACE_NAME'] = 'workspace_%s' % name
69 cmdline = ['bash', 'tools/run_tests/artifacts/run_in_workspace.sh'
71 jobspec = jobset.JobSpec(cmdline=cmdline,
73 shortname='distribtest.%s' % (name),
74 timeout_seconds=timeout_seconds,
75 flake_retries=flake_retries,
76 timeout_retries=timeout_retries,
81 class CSharpDistribTest(object):
82 """Tests C# NuGet package"""
88 use_dotnet_cli=False):
89 self.name = 'csharp_%s_%s' % (platform, arch)
90 self.platform = platform
92 self.docker_suffix = docker_suffix
93 self.labels = ['distribtest', 'csharp', platform, arch]
94 self.script_suffix = ''
96 self.name += '_%s' % docker_suffix
97 self.labels.append(docker_suffix)
99 self.name += '_dotnetcli'
100 self.script_suffix = '_dotnetcli'
101 self.labels.append('dotnetcli')
103 self.labels.append('olddotnet')
105 def pre_build_jobspecs(self):
108 def build_jobspec(self):
109 if self.platform == 'linux':
110 return create_docker_jobspec(
112 'tools/dockerfile/distribtest/csharp_%s_%s' %
113 (self.docker_suffix, self.arch),
114 'test/distrib/csharp/run_distrib_test%s.sh' %
116 copy_rel_path='test/distrib')
117 elif self.platform == 'macos':
118 return create_jobspec(self.name, [
119 'test/distrib/csharp/run_distrib_test%s.sh' % self.script_suffix
121 environ={'EXTERNAL_GIT_ROOT': '../../../..'},
123 elif self.platform == 'windows':
124 if self.arch == 'x64':
125 # Use double leading / as the first occurrence gets removed by msys bash
126 # when invoking the .bat file (side-effect of posix path conversion)
128 'MSBUILD_EXTRA_ARGS': '//p:Platform=x64',
129 'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\x64\\Debug'
132 environ = {'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\Debug'}
133 return create_jobspec(self.name, [
134 'test\\distrib\\csharp\\run_distrib_test%s.bat' %
140 raise Exception("Not supported yet.")
146 class PythonDistribTest(object):
147 """Tests Python package"""
149 def __init__(self, platform, arch, docker_suffix, source=False):
152 self.name = 'python_dev_%s_%s_%s' % (platform, arch, docker_suffix)
154 self.name = 'python_%s_%s_%s' % (platform, arch, docker_suffix)
155 self.platform = platform
157 self.docker_suffix = docker_suffix
158 self.labels = ['distribtest', 'python', platform, arch, docker_suffix]
160 def pre_build_jobspecs(self):
163 def build_jobspec(self):
164 if not self.platform == 'linux':
165 raise Exception("Not supported yet.")
168 return create_docker_jobspec(
170 'tools/dockerfile/distribtest/python_dev_%s_%s' %
171 (self.docker_suffix, self.arch),
172 'test/distrib/python/run_source_distrib_test.sh',
173 copy_rel_path='test/distrib')
175 return create_docker_jobspec(
177 'tools/dockerfile/distribtest/python_%s_%s' %
178 (self.docker_suffix, self.arch),
179 'test/distrib/python/run_binary_distrib_test.sh',
180 copy_rel_path='test/distrib')
186 class RubyDistribTest(object):
187 """Tests Ruby package"""
195 self.package_type = 'binary'
197 self.package_type = 'source'
198 self.name = 'ruby_%s_%s_%s_version_%s_package_type_%s' % (
199 platform, arch, docker_suffix, ruby_version or
200 'unspecified', self.package_type)
201 self.platform = platform
203 self.docker_suffix = docker_suffix
204 self.ruby_version = ruby_version
205 self.labels = ['distribtest', 'ruby', platform, arch, docker_suffix]
207 def pre_build_jobspecs(self):
210 def build_jobspec(self):
215 if not self.platform == 'linux':
216 raise Exception("Not supported yet.")
218 dockerfile_name = 'tools/dockerfile/distribtest/ruby_%s_%s' % (
219 self.docker_suffix, self.arch)
220 if self.ruby_version is not None:
221 dockerfile_name += '_%s' % self.ruby_version
222 return create_docker_jobspec(
225 'test/distrib/ruby/run_distrib_test.sh %s %s %s' %
226 (arch_to_gem_arch[self.arch], self.platform, self.package_type),
227 copy_rel_path='test/distrib')
233 class PHP7DistribTest(object):
234 """Tests PHP7 package"""
236 def __init__(self, platform, arch, docker_suffix=None):
237 self.name = 'php7_%s_%s_%s' % (platform, arch, docker_suffix)
238 self.platform = platform
240 self.docker_suffix = docker_suffix
241 self.labels = ['distribtest', 'php7', platform, arch]
243 self.labels.append(docker_suffix)
245 def pre_build_jobspecs(self):
248 def build_jobspec(self):
249 if self.platform == 'linux':
250 return create_docker_jobspec(
252 'tools/dockerfile/distribtest/php7_%s_%s' %
253 (self.docker_suffix, self.arch),
254 'test/distrib/php/run_distrib_test.sh',
255 copy_rel_path='test/distrib')
256 elif self.platform == 'macos':
257 return create_jobspec(
258 self.name, ['test/distrib/php/run_distrib_test_macos.sh'],
259 environ={'EXTERNAL_GIT_ROOT': '../../../..'},
260 timeout_seconds=15 * 60,
263 raise Exception("Not supported yet.")
269 class CppDistribTest(object):
270 """Tests Cpp make install by building examples."""
272 def __init__(self, platform, arch, docker_suffix=None, testcase=None):
273 if platform == 'linux':
274 self.name = 'cpp_%s_%s_%s_%s' % (platform, arch, docker_suffix,
277 self.name = 'cpp_%s_%s_%s' % (platform, arch, testcase)
278 self.platform = platform
280 self.docker_suffix = docker_suffix
281 self.testcase = testcase
290 self.labels.append(docker_suffix)
292 def pre_build_jobspecs(self):
295 def build_jobspec(self):
296 if self.platform == 'linux':
297 return create_docker_jobspec(
299 'tools/dockerfile/distribtest/cpp_%s_%s' %
300 (self.docker_suffix, self.arch),
301 'test/distrib/cpp/run_distrib_test_%s.sh' % self.testcase,
302 timeout_seconds=45 * 60)
303 elif self.platform == 'windows':
304 return create_jobspec(
306 ['test\\distrib\\cpp\\run_distrib_test_%s.bat' % self.testcase],
308 timeout_seconds=30 * 60,
311 raise Exception("Not supported yet.")
318 """Gets list of supported targets"""
321 CppDistribTest('linux', 'x64', 'jessie', 'cmake_as_submodule'),
322 CppDistribTest('linux', 'x64', 'stretch', 'cmake'),
323 CppDistribTest('linux', 'x64', 'stretch', 'cmake_as_externalproject'),
324 CppDistribTest('linux', 'x64', 'stretch', 'cmake_fetchcontent'),
325 CppDistribTest('linux', 'x64', 'stretch', 'cmake_module_install'),
326 CppDistribTest('linux', 'x64', 'stretch',
327 'cmake_module_install_pkgconfig'),
328 CppDistribTest('linux', 'x64', 'stretch', 'cmake_pkgconfig'),
329 CppDistribTest('linux', 'x64', 'stretch', 'raspberry_pi'),
330 CppDistribTest('windows', 'x86', testcase='cmake'),
331 CppDistribTest('windows', 'x86', testcase='cmake_as_externalproject'),
333 CSharpDistribTest('linux', 'x64', 'jessie'),
334 CSharpDistribTest('linux', 'x64', 'stretch'),
335 CSharpDistribTest('linux', 'x64', 'stretch', use_dotnet_cli=True),
336 CSharpDistribTest('linux', 'x64', 'centos7'),
337 CSharpDistribTest('linux', 'x64', 'ubuntu1604'),
338 CSharpDistribTest('linux', 'x64', 'ubuntu1604', use_dotnet_cli=True),
339 CSharpDistribTest('linux', 'x64', 'alpine', use_dotnet_cli=True),
340 CSharpDistribTest('linux', 'x64', 'dotnet31', use_dotnet_cli=True),
341 CSharpDistribTest('linux', 'x64', 'dotnet5', use_dotnet_cli=True),
342 CSharpDistribTest('macos', 'x64'),
343 CSharpDistribTest('windows', 'x86'),
344 CSharpDistribTest('windows', 'x64'),
346 PythonDistribTest('linux', 'x64', 'jessie'),
347 PythonDistribTest('linux', 'x86', 'jessie'),
348 PythonDistribTest('linux', 'x64', 'centos6'),
349 PythonDistribTest('linux', 'x64', 'centos7'),
350 PythonDistribTest('linux', 'x64', 'fedora23'),
351 PythonDistribTest('linux', 'x64', 'opensuse'),
352 PythonDistribTest('linux', 'x64', 'arch'),
353 PythonDistribTest('linux', 'x64', 'ubuntu1604'),
354 PythonDistribTest('linux', 'x64', 'ubuntu1804'),
355 PythonDistribTest('linux', 'x64', 'alpine3.7', source=True),
356 PythonDistribTest('linux', 'x64', 'jessie', source=True),
357 PythonDistribTest('linux', 'x86', 'jessie', source=True),
358 PythonDistribTest('linux', 'x64', 'centos7', source=True),
359 PythonDistribTest('linux', 'x64', 'fedora23', source=True),
360 PythonDistribTest('linux', 'x64', 'arch', source=True),
361 PythonDistribTest('linux', 'x64', 'ubuntu1604', source=True),
362 PythonDistribTest('linux', 'x64', 'ubuntu1804', source=True),
364 RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_4'),
365 RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_5'),
366 RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_6'),
367 RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_7'),
368 # TODO(apolcyn): add a ruby 3.0 test once protobuf adds support
369 RubyDistribTest('linux',
372 ruby_version='ruby_2_4',
374 RubyDistribTest('linux', 'x64', 'centos7'),
375 RubyDistribTest('linux', 'x64', 'fedora23'),
376 RubyDistribTest('linux', 'x64', 'opensuse'),
377 RubyDistribTest('linux', 'x64', 'ubuntu1604'),
378 RubyDistribTest('linux', 'x64', 'ubuntu1804'),
380 PHP7DistribTest('linux', 'x64', 'stretch'),
381 PHP7DistribTest('macos', 'x64'),