blob: a16daac4fe9c04e2f56bf547fedc52d5d64231df [file] [log] [blame]
Nathaniel Manistacbf21da2016-02-02 22:17:44 +00001#!/usr/bin/env python2.7
Jan Tattermusch38b519a2016-01-27 18:32:42 -08002# Copyright 2016, Google Inc.
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met:
8#
9# * Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# * Redistributions in binary form must reproduce the above
12# copyright notice, this list of conditions and the following disclaimer
13# in the documentation and/or other materials provided with the
14# distribution.
15# * Neither the name of Google Inc. nor the names of its
16# contributors may be used to endorse or promote products derived from
17# this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31"""Definition of targets run distribution package tests."""
32
33import jobset
34
35
36def create_docker_jobspec(name, dockerfile_dir, shell_command, environ={},
37 flake_retries=0, timeout_retries=0):
38 """Creates jobspec for a task running under docker."""
39 environ = environ.copy()
40 environ['RUN_COMMAND'] = shell_command
Jan Tattermuschb5f73972016-02-05 13:53:47 -080041 environ['RELATIVE_COPY_PATH'] = 'test/distrib'
Jan Tattermusch38b519a2016-01-27 18:32:42 -080042
43 docker_args=[]
siddharthshukla0589e532016-07-07 16:08:01 +020044 for k,v in environ.items():
Jan Tattermusch38b519a2016-01-27 18:32:42 -080045 docker_args += ['-e', '%s=%s' % (k, v)]
46 docker_env = {'DOCKERFILE_DIR': dockerfile_dir,
Jan Tattermusch9835d4b2016-04-29 15:05:05 -070047 'DOCKER_RUN_SCRIPT': 'tools/run_tests/dockerize/docker_run.sh'}
Jan Tattermusch38b519a2016-01-27 18:32:42 -080048 jobspec = jobset.JobSpec(
Jan Tattermusch9835d4b2016-04-29 15:05:05 -070049 cmdline=['tools/run_tests/dockerize/build_and_run_docker.sh'] + docker_args,
Jan Tattermusch38b519a2016-01-27 18:32:42 -080050 environ=docker_env,
51 shortname='distribtest.%s' % (name),
52 timeout_seconds=30*60,
53 flake_retries=flake_retries,
54 timeout_retries=timeout_retries)
55 return jobspec
56
57
Jan Tattermuschc83a9c02016-02-06 14:53:28 -080058def create_jobspec(name, cmdline, environ=None, shell=False,
59 flake_retries=0, timeout_retries=0):
60 """Creates jobspec."""
61 jobspec = jobset.JobSpec(
62 cmdline=cmdline,
63 environ=environ,
64 shortname='distribtest.%s' % (name),
65 timeout_seconds=10*60,
66 flake_retries=flake_retries,
67 timeout_retries=timeout_retries,
68 shell=shell)
69 return jobspec
70
71
Craig Tiller17f697b2016-02-02 13:50:51 -080072class CSharpDistribTest(object):
Jan Tattermusch38b519a2016-01-27 18:32:42 -080073 """Tests C# NuGet package"""
74
Jan Tattermuschb809cd92016-09-08 10:43:25 +020075 def __init__(self, platform, arch, docker_suffix=None, use_dotnet_cli=False):
Jan Tattermuschc83a9c02016-02-06 14:53:28 -080076 self.name = 'csharp_nuget_%s_%s' % (platform, arch)
Jan Tattermusch38b519a2016-01-27 18:32:42 -080077 self.platform = platform
78 self.arch = arch
Jan Tattermusch73c99f32016-02-01 10:28:13 -080079 self.docker_suffix = docker_suffix
Jan Tattermuschc83a9c02016-02-06 14:53:28 -080080 self.labels = ['distribtest', 'csharp', platform, arch]
Jan Tattermuschb809cd92016-09-08 10:43:25 +020081 self.script_suffix = ''
Jan Tattermuschc83a9c02016-02-06 14:53:28 -080082 if docker_suffix:
83 self.name += '_%s' % docker_suffix
84 self.labels.append(docker_suffix)
Jan Tattermuschb809cd92016-09-08 10:43:25 +020085 if use_dotnet_cli:
86 self.name += '_dotnetcli'
87 self.script_suffix = '_dotnetcli'
88 self.labels.append('dotnetcli')
89 else:
90 self.labels.append('olddotnet')
Jan Tattermusch38b519a2016-01-27 18:32:42 -080091
92 def pre_build_jobspecs(self):
93 return []
94
95 def build_jobspec(self):
Jan Tattermuschc83a9c02016-02-06 14:53:28 -080096 if self.platform == 'linux':
97 return create_docker_jobspec(self.name,
Jan Tattermusch73c99f32016-02-01 10:28:13 -080098 'tools/dockerfile/distribtest/csharp_%s_%s' % (
99 self.docker_suffix,
100 self.arch),
Jan Tattermuschb809cd92016-09-08 10:43:25 +0200101 'test/distrib/csharp/run_distrib_test%s.sh' % self.script_suffix)
Jan Tattermuschc83a9c02016-02-06 14:53:28 -0800102 elif self.platform == 'macos':
103 return create_jobspec(self.name,
Jan Tattermuschb809cd92016-09-08 10:43:25 +0200104 ['test/distrib/csharp/run_distrib_test%s.sh' % self.script_suffix],
Jan Tattermuschc83a9c02016-02-06 14:53:28 -0800105 environ={'EXTERNAL_GIT_ROOT': '../../..'})
Jan Tattermusch3f1aa9b2016-02-29 15:15:23 -0800106 elif self.platform == 'windows':
Jan Tattermuschfa4b1632016-02-26 17:14:01 -0800107 if self.arch == 'x64':
108 environ={'MSBUILD_EXTRA_ARGS': '/p:Platform=x64',
109 'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\x64\\Debug'}
110 else:
111 environ={'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\\Debug'}
112 return create_jobspec(self.name,
Jan Tattermuschb809cd92016-09-08 10:43:25 +0200113 ['test\\distrib\\csharp\\run_distrib_test%s.bat' % self.script_suffix],
Jan Tattermuschfa4b1632016-02-26 17:14:01 -0800114 environ=environ)
Jan Tattermusch3f1aa9b2016-02-29 15:15:23 -0800115 else:
116 raise Exception("Not supported yet.")
Jan Tattermusch38b519a2016-01-27 18:32:42 -0800117
118 def __str__(self):
119 return self.name
120
murgatroid99b781c972016-02-04 13:29:56 -0800121class NodeDistribTest(object):
122 """Tests Node package"""
123
124 def __init__(self, platform, arch, docker_suffix, node_version):
murgatroid99617b4b82016-02-08 14:45:45 -0800125 self.name = 'node_npm_%s_%s_%s' % (platform, arch, node_version)
murgatroid99b781c972016-02-04 13:29:56 -0800126 self.platform = platform
127 self.arch = arch
murgatroid99b781c972016-02-04 13:29:56 -0800128 self.node_version = node_version
129 self.labels = ['distribtest', 'node', platform, arch,
murgatroid99830f9a72016-02-10 10:28:28 -0800130 'node-%s' % node_version]
murgatroid99617b4b82016-02-08 14:45:45 -0800131 if docker_suffix is not None:
132 self.name += '_%s' % docker_suffix
133 self.docker_suffix = docker_suffix
murgatroid99830f9a72016-02-10 10:28:28 -0800134 self.labels.append(docker_suffix)
murgatroid99b781c972016-02-04 13:29:56 -0800135
136 def pre_build_jobspecs(self):
137 return []
138
139 def build_jobspec(self):
murgatroid9909727632016-02-08 13:09:21 -0800140 if self.platform == 'linux':
murgatroid99802393b2016-02-11 17:23:15 -0800141 linux32 = ''
142 if self.arch == 'x86':
143 linux32 = 'linux32'
murgatroid9909727632016-02-08 13:09:21 -0800144 return create_docker_jobspec(self.name,
145 'tools/dockerfile/distribtest/node_%s_%s' % (
146 self.docker_suffix,
147 self.arch),
murgatroid99802393b2016-02-11 17:23:15 -0800148 '%s test/distrib/node/run_distrib_test.sh %s' % (
149 linux32,
murgatroid9909727632016-02-08 13:09:21 -0800150 self.node_version))
151 elif self.platform == 'macos':
152 return create_jobspec(self.name,
153 ['test/distrib/node/run_distrib_test.sh',
154 str(self.node_version)],
155 environ={'EXTERNAL_GIT_ROOT': '../../..'})
156 else:
murgatroid99b781c972016-02-04 13:29:56 -0800157 raise Exception("Not supported yet.")
158
murgatroid99b781c972016-02-04 13:29:56 -0800159 def __str__(self):
160 return self.name
161
Jan Tattermusch38b519a2016-01-27 18:32:42 -0800162
Craig Tiller17f697b2016-02-02 13:50:51 -0800163class PythonDistribTest(object):
Craig Tillerb2afc1f2016-02-02 12:30:08 -0800164 """Tests Python package"""
165
166 def __init__(self, platform, arch, docker_suffix):
167 self.name = 'python_%s_%s_%s' % (platform, arch, docker_suffix)
168 self.platform = platform
169 self.arch = arch
170 self.docker_suffix = docker_suffix
171 self.labels = ['distribtest', 'python', platform, arch, docker_suffix]
172
173 def pre_build_jobspecs(self):
174 return []
175
176 def build_jobspec(self):
177 if not self.platform == 'linux':
178 raise Exception("Not supported yet.")
179
180 return create_docker_jobspec(self.name,
181 'tools/dockerfile/distribtest/python_%s_%s' % (
182 self.docker_suffix,
183 self.arch),
184 'test/distrib/python/run_distrib_test.sh')
185
186 def __str__(self):
187 return self.name
188
189
Craig Tillere3fd4aa2016-02-02 16:17:37 -0800190class RubyDistribTest(object):
191 """Tests Ruby package"""
192
193 def __init__(self, platform, arch, docker_suffix):
194 self.name = 'ruby_%s_%s_%s' % (platform, arch, docker_suffix)
195 self.platform = platform
196 self.arch = arch
197 self.docker_suffix = docker_suffix
198 self.labels = ['distribtest', 'ruby', platform, arch, docker_suffix]
199
200 def pre_build_jobspecs(self):
201 return []
202
203 def build_jobspec(self):
204 if not self.platform == 'linux':
205 raise Exception("Not supported yet.")
206
207 return create_docker_jobspec(self.name,
208 'tools/dockerfile/distribtest/ruby_%s_%s' % (
209 self.docker_suffix,
210 self.arch),
211 'test/distrib/ruby/run_distrib_test.sh')
212
213 def __str__(self):
214 return self.name
215
216
Stanley Cheung5adb71f2016-02-13 00:03:02 -0800217class PHPDistribTest(object):
218 """Tests PHP package"""
219
Stanley Cheung80db5be2016-02-24 21:35:56 -0800220 def __init__(self, platform, arch, docker_suffix=None):
Stanley Cheung5adb71f2016-02-13 00:03:02 -0800221 self.name = 'php_%s_%s_%s' % (platform, arch, docker_suffix)
222 self.platform = platform
223 self.arch = arch
224 self.docker_suffix = docker_suffix
225 self.labels = ['distribtest', 'php', platform, arch, docker_suffix]
226
227 def pre_build_jobspecs(self):
228 return []
229
230 def build_jobspec(self):
Stanley Cheung80db5be2016-02-24 21:35:56 -0800231 if self.platform == 'linux':
232 return create_docker_jobspec(self.name,
233 'tools/dockerfile/distribtest/php_%s_%s' % (
234 self.docker_suffix,
235 self.arch),
236 'test/distrib/php/run_distrib_test.sh')
237 elif self.platform == 'macos':
238 return create_jobspec(self.name,
239 ['test/distrib/php/run_distrib_test.sh'],
240 environ={'EXTERNAL_GIT_ROOT': '../../..'})
241 else:
Stanley Cheung5adb71f2016-02-13 00:03:02 -0800242 raise Exception("Not supported yet.")
243
Stanley Cheung5adb71f2016-02-13 00:03:02 -0800244 def __str__(self):
245 return self.name
246
247
yang-g933fbaf2016-05-24 11:45:42 -0700248class CppDistribTest(object):
249 """Tests Cpp make intall by building examples."""
250
251 def __init__(self, platform, arch, docker_suffix=None):
252 self.name = 'cpp_%s_%s_%s' % (platform, arch, docker_suffix)
253 self.platform = platform
254 self.arch = arch
255 self.docker_suffix = docker_suffix
256 self.labels = ['distribtest', 'cpp', platform, arch, docker_suffix]
257
258 def pre_build_jobspecs(self):
259 return []
260
261 def build_jobspec(self):
262 if self.platform == 'linux':
263 return create_docker_jobspec(self.name,
264 'tools/dockerfile/distribtest/cpp_%s_%s' % (
265 self.docker_suffix,
266 self.arch),
267 'test/distrib/cpp/run_distrib_test.sh')
268 else:
269 raise Exception("Not supported yet.")
270
271 def __str__(self):
272 return self.name
273
274
Jan Tattermusch38b519a2016-01-27 18:32:42 -0800275def targets():
276 """Gets list of supported targets"""
yang-g933fbaf2016-05-24 11:45:42 -0700277 return [CppDistribTest('linux', 'x64', 'jessie'),
278 CSharpDistribTest('linux', 'x64', 'wheezy'),
Jan Tattermusch73c99f32016-02-01 10:28:13 -0800279 CSharpDistribTest('linux', 'x64', 'jessie'),
Craig Tillercfcb5e22016-02-02 10:41:02 -0800280 CSharpDistribTest('linux', 'x86', 'jessie'),
Craig Tiller8d0b2022016-02-02 13:24:50 -0800281 CSharpDistribTest('linux', 'x64', 'centos7'),
Jan Tattermusch14b07e62016-02-03 10:58:27 -0800282 CSharpDistribTest('linux', 'x64', 'ubuntu1404'),
283 CSharpDistribTest('linux', 'x64', 'ubuntu1504'),
284 CSharpDistribTest('linux', 'x64', 'ubuntu1510'),
285 CSharpDistribTest('linux', 'x64', 'ubuntu1604'),
Jan Tattermuschb809cd92016-09-08 10:43:25 +0200286 CSharpDistribTest('linux', 'x64', 'ubuntu1404', use_dotnet_cli=True),
Jan Tattermuschc83a9c02016-02-06 14:53:28 -0800287 CSharpDistribTest('macos', 'x86'),
Jan Tattermuschfa4b1632016-02-26 17:14:01 -0800288 CSharpDistribTest('windows', 'x86'),
289 CSharpDistribTest('windows', 'x64'),
Craig Tillerb2afc1f2016-02-02 12:30:08 -0800290 PythonDistribTest('linux', 'x64', 'wheezy'),
291 PythonDistribTest('linux', 'x64', 'jessie'),
292 PythonDistribTest('linux', 'x86', 'jessie'),
293 PythonDistribTest('linux', 'x64', 'centos6'),
294 PythonDistribTest('linux', 'x64', 'centos7'),
295 PythonDistribTest('linux', 'x64', 'fedora20'),
296 PythonDistribTest('linux', 'x64', 'fedora21'),
297 PythonDistribTest('linux', 'x64', 'fedora22'),
298 PythonDistribTest('linux', 'x64', 'fedora23'),
Craig Tillera0ff10c2016-02-02 13:15:05 -0800299 PythonDistribTest('linux', 'x64', 'opensuse'),
Craig Tillerb06e2632016-02-02 13:24:10 -0800300 PythonDistribTest('linux', 'x64', 'arch'),
Craig Tiller17f697b2016-02-02 13:50:51 -0800301 PythonDistribTest('linux', 'x64', 'ubuntu1204'),
302 PythonDistribTest('linux', 'x64', 'ubuntu1404'),
303 PythonDistribTest('linux', 'x64', 'ubuntu1504'),
304 PythonDistribTest('linux', 'x64', 'ubuntu1510'),
305 PythonDistribTest('linux', 'x64', 'ubuntu1604'),
Craig Tillere3fd4aa2016-02-02 16:17:37 -0800306 RubyDistribTest('linux', 'x64', 'wheezy'),
307 RubyDistribTest('linux', 'x64', 'jessie'),
308 RubyDistribTest('linux', 'x86', 'jessie'),
309 RubyDistribTest('linux', 'x64', 'centos6'),
310 RubyDistribTest('linux', 'x64', 'centos7'),
311 RubyDistribTest('linux', 'x64', 'fedora20'),
312 RubyDistribTest('linux', 'x64', 'fedora21'),
313 RubyDistribTest('linux', 'x64', 'fedora22'),
314 RubyDistribTest('linux', 'x64', 'fedora23'),
315 RubyDistribTest('linux', 'x64', 'opensuse'),
Craig Tillere3fd4aa2016-02-02 16:17:37 -0800316 RubyDistribTest('linux', 'x64', 'ubuntu1204'),
317 RubyDistribTest('linux', 'x64', 'ubuntu1404'),
318 RubyDistribTest('linux', 'x64', 'ubuntu1504'),
319 RubyDistribTest('linux', 'x64', 'ubuntu1510'),
320 RubyDistribTest('linux', 'x64', 'ubuntu1604'),
murgatroid99617b4b82016-02-08 14:45:45 -0800321 NodeDistribTest('macos', 'x64', None, '4'),
Stanley Cheung5adb71f2016-02-13 00:03:02 -0800322 NodeDistribTest('macos', 'x64', None, '5'),
323 NodeDistribTest('linux', 'x86', 'jessie', '4'),
324 PHPDistribTest('linux', 'x64', 'jessie'),
Stanley Cheung80db5be2016-02-24 21:35:56 -0800325 PHPDistribTest('macos', 'x64'),
murgatroid99b781c972016-02-04 13:29:56 -0800326 ] + [
327 NodeDistribTest('linux', 'x64', os, version)
328 for os in ('wheezy', 'jessie', 'ubuntu1204', 'ubuntu1404',
murgatroid99f25318c2016-02-08 14:52:30 -0800329 'ubuntu1504', 'ubuntu1510', 'ubuntu1604')
murgatroid998c686e72016-02-10 10:59:22 -0800330 for version in ('0.12', '3', '4', '5')
Craig Tillerb2afc1f2016-02-02 12:30:08 -0800331 ]