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"""
84 def __init__(self, platform, arch, docker_suffix=None,
85 use_dotnet_cli=False):
86 self.name = 'csharp_%s_%s' % (platform, arch)
87 self.platform = platform
89 self.docker_suffix = docker_suffix
90 self.labels = ['distribtest', 'csharp', platform, arch]
91 self.script_suffix = ''
93 self.name += '_%s' % docker_suffix
94 self.labels.append(docker_suffix)
96 self.name += '_dotnetcli'
97 self.script_suffix = '_dotnetcli'
98 self.labels.append('dotnetcli')
100 self.labels.append('olddotnet')
102 def pre_build_jobspecs(self):
105 def build_jobspec(self):
106 if self.platform == 'linux':
107 return create_docker_jobspec(
109 'tools/dockerfile/distribtest/csharp_%s_%s' %
110 (self.docker_suffix, self.arch),
111 'test/distrib/csharp/run_distrib_test%s.sh' %
113 copy_rel_path='test/distrib')
114 elif self.platform == 'macos':
115 return create_jobspec(self.name, [
116 'test/distrib/csharp/run_distrib_test%s.sh' % self.script_suffix
118 environ={'EXTERNAL_GIT_ROOT': '../../../..'},
120 elif self.platform == 'windows':
121 if self.arch == 'x64':
122 # Use double leading / as the first occurrence gets removed by msys bash
123 # when invoking the .bat file (side-effect of posix path conversion)
125 'MSBUILD_EXTRA_ARGS': '//p:Platform=x64',
126 'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\x64\\Debug'
129 environ = {'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\Debug'}
130 return create_jobspec(self.name, [
131 'test\\distrib\\csharp\\run_distrib_test%s.bat' %
137 raise Exception("Not supported yet.")
143 class PythonDistribTest(object):
144 """Tests Python package"""
146 def __init__(self, platform, arch, docker_suffix, source=False):
149 self.name = 'python_dev_%s_%s_%s' % (platform, arch, docker_suffix)
151 self.name = 'python_%s_%s_%s' % (platform, arch, docker_suffix)
152 self.platform = platform
154 self.docker_suffix = docker_suffix
155 self.labels = ['distribtest', 'python', platform, arch, docker_suffix]
157 def pre_build_jobspecs(self):
160 def build_jobspec(self):
161 if not self.platform == 'linux':
162 raise Exception("Not supported yet.")
165 return create_docker_jobspec(
167 'tools/dockerfile/distribtest/python_dev_%s_%s' %
168 (self.docker_suffix, self.arch),
169 'test/distrib/python/run_source_distrib_test.sh',
170 copy_rel_path='test/distrib')
172 return create_docker_jobspec(
174 'tools/dockerfile/distribtest/python_%s_%s' %
175 (self.docker_suffix, self.arch),
176 'test/distrib/python/run_binary_distrib_test.sh',
177 copy_rel_path='test/distrib')
183 class RubyDistribTest(object):
184 """Tests Ruby package"""
186 def __init__(self, platform, arch, docker_suffix, ruby_version=None):
187 self.name = 'ruby_%s_%s_%s_version_%s' % (platform, arch, docker_suffix,
188 ruby_version or 'unspecified')
189 self.platform = platform
191 self.docker_suffix = docker_suffix
192 self.ruby_version = ruby_version
193 self.labels = ['distribtest', 'ruby', platform, arch, docker_suffix]
195 def pre_build_jobspecs(self):
198 def build_jobspec(self):
203 if not self.platform == 'linux':
204 raise Exception("Not supported yet.")
206 dockerfile_name = 'tools/dockerfile/distribtest/ruby_%s_%s' % (
207 self.docker_suffix, self.arch)
208 if self.ruby_version is not None:
209 dockerfile_name += '_%s' % self.ruby_version
210 return create_docker_jobspec(
213 'test/distrib/ruby/run_distrib_test.sh %s %s' %
214 (arch_to_gem_arch[self.arch], self.platform),
215 copy_rel_path='test/distrib')
221 class PHPDistribTest(object):
222 """Tests PHP package"""
224 def __init__(self, platform, arch, docker_suffix=None):
225 self.name = 'php_%s_%s_%s' % (platform, arch, docker_suffix)
226 self.platform = platform
228 self.docker_suffix = docker_suffix
229 self.labels = ['distribtest', 'php', platform, arch, docker_suffix]
231 def pre_build_jobspecs(self):
234 def build_jobspec(self):
235 if self.platform == 'linux':
236 return create_docker_jobspec(
238 'tools/dockerfile/distribtest/php_%s_%s' %
239 (self.docker_suffix, self.arch),
240 'test/distrib/php/run_distrib_test.sh',
241 copy_rel_path='test/distrib')
242 elif self.platform == 'macos':
243 return create_jobspec(
244 self.name, ['test/distrib/php/run_distrib_test_macos.sh'],
245 environ={'EXTERNAL_GIT_ROOT': '../../../..'},
248 raise Exception("Not supported yet.")
254 class CppDistribTest(object):
255 """Tests Cpp make install by building examples."""
257 def __init__(self, platform, arch, docker_suffix=None, testcase=None):
258 if platform == 'linux':
259 self.name = 'cpp_%s_%s_%s_%s' % (platform, arch, docker_suffix,
262 self.name = 'cpp_%s_%s_%s' % (platform, arch, testcase)
263 self.platform = platform
265 self.docker_suffix = docker_suffix
266 self.testcase = testcase
268 'distribtest', 'cpp', platform, arch, docker_suffix, testcase
271 def pre_build_jobspecs(self):
274 def build_jobspec(self):
275 if self.platform == 'linux':
276 return create_docker_jobspec(
278 'tools/dockerfile/distribtest/cpp_%s_%s' %
279 (self.docker_suffix, self.arch),
280 'test/distrib/cpp/run_distrib_test_%s.sh' % self.testcase,
281 timeout_seconds=45 * 60)
282 elif self.platform == 'windows':
283 return create_jobspec(
285 ['test\\distrib\\cpp\\run_distrib_test_%s.bat' % self.testcase],
287 timeout_seconds=30 * 60,
290 raise Exception("Not supported yet.")
297 """Gets list of supported targets"""
299 CppDistribTest('linux', 'x64', 'jessie', 'routeguide'),
300 CppDistribTest('linux', 'x64', 'jessie', 'cmake'),
301 CppDistribTest('linux', 'x64', 'jessie', 'cmake_as_externalproject'),
302 CppDistribTest('linux', 'x64', 'jessie', 'cmake_as_submodule'),
303 CppDistribTest('linux', 'x64', 'jessie', 'cmake_fetchcontent'),
304 CppDistribTest('linux', 'x64', 'jessie', 'cmake_module_install'),
305 CppDistribTest('linux', 'x64', 'jessie', 'cmake_pkgconfig'),
306 CppDistribTest('linux', 'x64', 'jessie', 'raspberry_pi'),
307 CppDistribTest('windows', 'x86', testcase='cmake'),
308 CppDistribTest('windows', 'x86', testcase='cmake_as_externalproject'),
309 CSharpDistribTest('linux', 'x64', 'jessie'),
310 CSharpDistribTest('linux', 'x86', 'jessie'),
311 CSharpDistribTest('linux', 'x64', 'stretch'),
312 CSharpDistribTest('linux', 'x64', 'stretch', use_dotnet_cli=True),
313 CSharpDistribTest('linux', 'x64', 'centos7'),
314 CSharpDistribTest('linux', 'x64', 'ubuntu1604'),
315 CSharpDistribTest('linux', 'x64', 'ubuntu1604', use_dotnet_cli=True),
316 CSharpDistribTest('linux', 'x64', 'alpine', use_dotnet_cli=True),
317 CSharpDistribTest('macos', 'x86'),
318 CSharpDistribTest('windows', 'x86'),
319 CSharpDistribTest('windows', 'x64'),
320 PythonDistribTest('linux', 'x64', 'jessie'),
321 PythonDistribTest('linux', 'x86', 'jessie'),
322 PythonDistribTest('linux', 'x64', 'centos6'),
323 PythonDistribTest('linux', 'x64', 'centos7'),
324 PythonDistribTest('linux', 'x64', 'fedora23'),
325 PythonDistribTest('linux', 'x64', 'opensuse'),
326 PythonDistribTest('linux', 'x64', 'arch'),
327 PythonDistribTest('linux', 'x64', 'ubuntu1404'),
328 PythonDistribTest('linux', 'x64', 'ubuntu1604'),
329 PythonDistribTest('linux', 'x64', 'alpine3.7', source=True),
330 PythonDistribTest('linux', 'x64', 'jessie', source=True),
331 PythonDistribTest('linux', 'x86', 'jessie', source=True),
332 PythonDistribTest('linux', 'x64', 'centos7', source=True),
333 PythonDistribTest('linux', 'x64', 'fedora23', source=True),
334 PythonDistribTest('linux', 'x64', 'arch', source=True),
335 PythonDistribTest('linux', 'x64', 'ubuntu1404', source=True),
336 PythonDistribTest('linux', 'x64', 'ubuntu1604', source=True),
337 RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_3'),
338 RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_4'),
339 RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_5'),
340 RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_6'),
341 RubyDistribTest('linux', 'x64', 'centos6'),
342 RubyDistribTest('linux', 'x64', 'centos7'),
343 RubyDistribTest('linux', 'x64', 'fedora23'),
344 RubyDistribTest('linux', 'x64', 'opensuse'),
345 RubyDistribTest('linux', 'x64', 'ubuntu1404'),
346 RubyDistribTest('linux', 'x64', 'ubuntu1604'),
347 PHPDistribTest('linux', 'x64', 'jessie'),
348 PHPDistribTest('macos', 'x64'),