OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python2.7 |
| 2 # 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 |
| 33 import jobset |
| 34 |
| 35 |
| 36 def 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 |
| 41 environ['RELATIVE_COPY_PATH'] = 'test/distrib' |
| 42 |
| 43 docker_args=[] |
| 44 for k,v in environ.iteritems(): |
| 45 docker_args += ['-e', '%s=%s' % (k, v)] |
| 46 docker_env = {'DOCKERFILE_DIR': dockerfile_dir, |
| 47 'DOCKER_RUN_SCRIPT': 'tools/jenkins/docker_run.sh'} |
| 48 jobspec = jobset.JobSpec( |
| 49 cmdline=['tools/jenkins/build_and_run_docker.sh'] + docker_args, |
| 50 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 |
| 58 def 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 |
| 72 class CSharpDistribTest(object): |
| 73 """Tests C# NuGet package""" |
| 74 |
| 75 def __init__(self, platform, arch, docker_suffix=None): |
| 76 self.name = 'csharp_nuget_%s_%s' % (platform, arch) |
| 77 self.platform = platform |
| 78 self.arch = arch |
| 79 self.docker_suffix = docker_suffix |
| 80 self.labels = ['distribtest', 'csharp', platform, arch] |
| 81 if docker_suffix: |
| 82 self.name += '_%s' % docker_suffix |
| 83 self.labels.append(docker_suffix) |
| 84 |
| 85 def pre_build_jobspecs(self): |
| 86 return [] |
| 87 |
| 88 def build_jobspec(self): |
| 89 if self.platform == 'linux': |
| 90 return create_docker_jobspec(self.name, |
| 91 'tools/dockerfile/distribtest/csharp_%s_%s' % ( |
| 92 self.docker_suffix, |
| 93 self.arch), |
| 94 'test/distrib/csharp/run_distrib_test.sh') |
| 95 elif self.platform == 'macos': |
| 96 return create_jobspec(self.name, |
| 97 ['test/distrib/csharp/run_distrib_test.sh'], |
| 98 environ={'EXTERNAL_GIT_ROOT': '../../..'}) |
| 99 elif self.platform == 'windows': |
| 100 if self.arch == 'x64': |
| 101 environ={'MSBUILD_EXTRA_ARGS': '/p:Platform=x64', |
| 102 'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\x64\\Debug'} |
| 103 else: |
| 104 environ={'DISTRIBTEST_OUTPATH': 'DistribTest\\bin\\\Debug'} |
| 105 return create_jobspec(self.name, |
| 106 ['test\\distrib\\csharp\\run_distrib_test.bat'], |
| 107 environ=environ) |
| 108 else: |
| 109 raise Exception("Not supported yet.") |
| 110 |
| 111 def __str__(self): |
| 112 return self.name |
| 113 |
| 114 class NodeDistribTest(object): |
| 115 """Tests Node package""" |
| 116 |
| 117 def __init__(self, platform, arch, docker_suffix, node_version): |
| 118 self.name = 'node_npm_%s_%s_%s' % (platform, arch, node_version) |
| 119 self.platform = platform |
| 120 self.arch = arch |
| 121 self.node_version = node_version |
| 122 self.labels = ['distribtest', 'node', platform, arch, |
| 123 'node-%s' % node_version] |
| 124 if docker_suffix is not None: |
| 125 self.name += '_%s' % docker_suffix |
| 126 self.docker_suffix = docker_suffix |
| 127 self.labels.append(docker_suffix) |
| 128 |
| 129 def pre_build_jobspecs(self): |
| 130 return [] |
| 131 |
| 132 def build_jobspec(self): |
| 133 if self.platform == 'linux': |
| 134 linux32 = '' |
| 135 if self.arch == 'x86': |
| 136 linux32 = 'linux32' |
| 137 return create_docker_jobspec(self.name, |
| 138 'tools/dockerfile/distribtest/node_%s_%s' % ( |
| 139 self.docker_suffix, |
| 140 self.arch), |
| 141 '%s test/distrib/node/run_distrib_test.sh %s'
% ( |
| 142 linux32, |
| 143 self.node_version)) |
| 144 elif self.platform == 'macos': |
| 145 return create_jobspec(self.name, |
| 146 ['test/distrib/node/run_distrib_test.sh', |
| 147 str(self.node_version)], |
| 148 environ={'EXTERNAL_GIT_ROOT': '../../..'}) |
| 149 else: |
| 150 raise Exception("Not supported yet.") |
| 151 |
| 152 def __str__(self): |
| 153 return self.name |
| 154 |
| 155 |
| 156 class PythonDistribTest(object): |
| 157 """Tests Python package""" |
| 158 |
| 159 def __init__(self, platform, arch, docker_suffix): |
| 160 self.name = 'python_%s_%s_%s' % (platform, arch, docker_suffix) |
| 161 self.platform = platform |
| 162 self.arch = arch |
| 163 self.docker_suffix = docker_suffix |
| 164 self.labels = ['distribtest', 'python', platform, arch, docker_suffix] |
| 165 |
| 166 def pre_build_jobspecs(self): |
| 167 return [] |
| 168 |
| 169 def build_jobspec(self): |
| 170 if not self.platform == 'linux': |
| 171 raise Exception("Not supported yet.") |
| 172 |
| 173 return create_docker_jobspec(self.name, |
| 174 'tools/dockerfile/distribtest/python_%s_%s' % ( |
| 175 self.docker_suffix, |
| 176 self.arch), |
| 177 'test/distrib/python/run_distrib_test.sh') |
| 178 |
| 179 def __str__(self): |
| 180 return self.name |
| 181 |
| 182 |
| 183 class RubyDistribTest(object): |
| 184 """Tests Ruby package""" |
| 185 |
| 186 def __init__(self, platform, arch, docker_suffix): |
| 187 self.name = 'ruby_%s_%s_%s' % (platform, arch, docker_suffix) |
| 188 self.platform = platform |
| 189 self.arch = arch |
| 190 self.docker_suffix = docker_suffix |
| 191 self.labels = ['distribtest', 'ruby', platform, arch, docker_suffix] |
| 192 |
| 193 def pre_build_jobspecs(self): |
| 194 return [] |
| 195 |
| 196 def build_jobspec(self): |
| 197 if not self.platform == 'linux': |
| 198 raise Exception("Not supported yet.") |
| 199 |
| 200 return create_docker_jobspec(self.name, |
| 201 'tools/dockerfile/distribtest/ruby_%s_%s' % ( |
| 202 self.docker_suffix, |
| 203 self.arch), |
| 204 'test/distrib/ruby/run_distrib_test.sh') |
| 205 |
| 206 def __str__(self): |
| 207 return self.name |
| 208 |
| 209 |
| 210 class PHPDistribTest(object): |
| 211 """Tests PHP package""" |
| 212 |
| 213 def __init__(self, platform, arch, docker_suffix=None): |
| 214 self.name = 'php_%s_%s_%s' % (platform, arch, docker_suffix) |
| 215 self.platform = platform |
| 216 self.arch = arch |
| 217 self.docker_suffix = docker_suffix |
| 218 self.labels = ['distribtest', 'php', platform, arch, docker_suffix] |
| 219 |
| 220 def pre_build_jobspecs(self): |
| 221 return [] |
| 222 |
| 223 def build_jobspec(self): |
| 224 if self.platform == 'linux': |
| 225 return create_docker_jobspec(self.name, |
| 226 'tools/dockerfile/distribtest/php_%s_%s' % ( |
| 227 self.docker_suffix, |
| 228 self.arch), |
| 229 'test/distrib/php/run_distrib_test.sh') |
| 230 elif self.platform == 'macos': |
| 231 return create_jobspec(self.name, |
| 232 ['test/distrib/php/run_distrib_test.sh'], |
| 233 environ={'EXTERNAL_GIT_ROOT': '../../..'}) |
| 234 else: |
| 235 raise Exception("Not supported yet.") |
| 236 |
| 237 def __str__(self): |
| 238 return self.name |
| 239 |
| 240 |
| 241 def targets(): |
| 242 """Gets list of supported targets""" |
| 243 return [CSharpDistribTest('linux', 'x64', 'wheezy'), |
| 244 CSharpDistribTest('linux', 'x64', 'jessie'), |
| 245 CSharpDistribTest('linux', 'x86', 'jessie'), |
| 246 CSharpDistribTest('linux', 'x64', 'centos7'), |
| 247 CSharpDistribTest('linux', 'x64', 'ubuntu1404'), |
| 248 CSharpDistribTest('linux', 'x64', 'ubuntu1504'), |
| 249 CSharpDistribTest('linux', 'x64', 'ubuntu1510'), |
| 250 CSharpDistribTest('linux', 'x64', 'ubuntu1604'), |
| 251 CSharpDistribTest('macos', 'x86'), |
| 252 CSharpDistribTest('windows', 'x86'), |
| 253 CSharpDistribTest('windows', 'x64'), |
| 254 PythonDistribTest('linux', 'x64', 'wheezy'), |
| 255 PythonDistribTest('linux', 'x64', 'jessie'), |
| 256 PythonDistribTest('linux', 'x86', 'jessie'), |
| 257 PythonDistribTest('linux', 'x64', 'centos6'), |
| 258 PythonDistribTest('linux', 'x64', 'centos7'), |
| 259 PythonDistribTest('linux', 'x64', 'fedora20'), |
| 260 PythonDistribTest('linux', 'x64', 'fedora21'), |
| 261 PythonDistribTest('linux', 'x64', 'fedora22'), |
| 262 PythonDistribTest('linux', 'x64', 'fedora23'), |
| 263 PythonDistribTest('linux', 'x64', 'opensuse'), |
| 264 PythonDistribTest('linux', 'x64', 'arch'), |
| 265 PythonDistribTest('linux', 'x64', 'ubuntu1204'), |
| 266 PythonDistribTest('linux', 'x64', 'ubuntu1404'), |
| 267 PythonDistribTest('linux', 'x64', 'ubuntu1504'), |
| 268 PythonDistribTest('linux', 'x64', 'ubuntu1510'), |
| 269 PythonDistribTest('linux', 'x64', 'ubuntu1604'), |
| 270 RubyDistribTest('linux', 'x64', 'wheezy'), |
| 271 RubyDistribTest('linux', 'x64', 'jessie'), |
| 272 RubyDistribTest('linux', 'x86', 'jessie'), |
| 273 RubyDistribTest('linux', 'x64', 'centos6'), |
| 274 RubyDistribTest('linux', 'x64', 'centos7'), |
| 275 RubyDistribTest('linux', 'x64', 'fedora20'), |
| 276 RubyDistribTest('linux', 'x64', 'fedora21'), |
| 277 RubyDistribTest('linux', 'x64', 'fedora22'), |
| 278 RubyDistribTest('linux', 'x64', 'fedora23'), |
| 279 RubyDistribTest('linux', 'x64', 'opensuse'), |
| 280 RubyDistribTest('linux', 'x64', 'ubuntu1204'), |
| 281 RubyDistribTest('linux', 'x64', 'ubuntu1404'), |
| 282 RubyDistribTest('linux', 'x64', 'ubuntu1504'), |
| 283 RubyDistribTest('linux', 'x64', 'ubuntu1510'), |
| 284 RubyDistribTest('linux', 'x64', 'ubuntu1604'), |
| 285 NodeDistribTest('macos', 'x64', None, '4'), |
| 286 NodeDistribTest('macos', 'x64', None, '5'), |
| 287 NodeDistribTest('linux', 'x86', 'jessie', '4'), |
| 288 PHPDistribTest('linux', 'x64', 'jessie'), |
| 289 PHPDistribTest('macos', 'x64'), |
| 290 ] + [ |
| 291 NodeDistribTest('linux', 'x64', os, version) |
| 292 for os in ('wheezy', 'jessie', 'ubuntu1204', 'ubuntu1404', |
| 293 'ubuntu1504', 'ubuntu1510', 'ubuntu1604') |
| 294 for version in ('0.12', '3', '4', '5') |
| 295 ] |
OLD | NEW |