Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 138 lines (119 sloc) 5.39 kB
d95f25e @markrcote Bug 783585 Fix line endings. r=wlach
markrcote authored
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 # You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 import datetime
6 import logging
7 import pytz
8 import re
9 import socket
10
11 import builds
12
13 def from_iso_date_or_datetime(s):
14 datefmt = '%Y-%m-%d'
15 datetimefmt = datefmt + 'T%H:%M:%S'
16 try:
17 d = datetime.datetime.strptime(s, datetimefmt)
18 except ValueError:
19 d = datetime.datetime.strptime(s, datefmt)
20 return d
21
22
23 def main(args, options):
24 logging.info('Looking for builds...')
25 if args[0] == 'latest':
d687f59 @bclary Bug 821954 - allow specification of repo, build types, r=mcote.
bclary authored
26 cache_build_dir = (builds.BuildCache(options.repos,
27 options.buildtypes).
28 find_latest_build(options.build_location))
d1e02c5 @bclary Bug 785086 - Add ability to download unit test prerequisites and to r…
bclary authored
29 if not cache_build_dir:
56f5c82 @markrcote Bug 783585 Improve latest-build downloader and handle build errors in…
markrcote authored
30 return 1
d1e02c5 @bclary Bug 785086 - Add ability to download unit test prerequisites and to r…
bclary authored
31 commands = ['triggerjobs %s' % cache_build_dir]
d95f25e @markrcote Bug 783585 Fix line endings. r=wlach
markrcote authored
32 else:
33 if re.match('\d{14}', args[0]):
34 # build id
35 build_time = datetime.datetime.strptime(args[0], '%Y%m%d%H%M%S')
36 start_time = build_time
37 end_time = build_time
38 else:
39 start_time = from_iso_date_or_datetime(args[0])
40 if len(args) > 1:
41 end_time = from_iso_date_or_datetime(args[1])
42 else:
43 end_time = datetime.datetime.now()
44 if not start_time.tzinfo:
45 start_time = start_time.replace(tzinfo=pytz.timezone('US/Pacific'))
46 if not end_time.tzinfo:
47 end_time = end_time.replace(tzinfo=pytz.timezone('US/Pacific'))
d687f59 @bclary Bug 821954 - allow specification of repo, build types, r=mcote.
bclary authored
48 cache_build_dir_list = (builds.BuildCache(options.repos,
49 options.buildtypes).
50 find_builds(start_time, end_time,
51 options.build_location))
d1e02c5 @bclary Bug 785086 - Add ability to download unit test prerequisites and to r…
bclary authored
52 if not cache_build_dir_list:
56f5c82 @markrcote Bug 783585 Improve latest-build downloader and handle build errors in…
markrcote authored
53 return 1
d1e02c5 @bclary Bug 785086 - Add ability to download unit test prerequisites and to r…
bclary authored
54 commands = ['triggerjobs %s' % cache_build_dir for cache_build_dir in
55 cache_build_dir_list]
d95f25e @markrcote Bug 783585 Fix line endings. r=wlach
markrcote authored
56 logging.info('Connecting to autophone server...')
57 commands.append('exit')
58 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
59 s.connect((options.ip, options.port))
60 logging.info('- %s' % s.recv(1024).strip())
61 for c in commands:
62 logging.info('%s' % c)
63 s.sendall(c + '\n')
64 logging.info('- %s' % s.recv(1024).strip())
65 return 0
66
67
68 if __name__ == '__main__':
69 import errno
70 import sys
71 from optparse import OptionParser
72
73 usage = '''%prog [options] <datetime, date/datetime, or date/datetime range>
74 Triggers one or more test runs.
75
76 The argument(s) should be one of the following:
77 - a build ID, e.g. 20120403063158
78 - a date/datetime, e.g. 2012-04-03 or 2012-04-03T06:31:58
79 - a date/datetime range, e.g. 2012-04-03T06:31:58 2012-04-05
80 - the string "latest"
81
82 If a build ID is given, a test run is initiated for that, and only that,
83 particular build.
84
85 If a single date or datetime is given, test runs are initiated for all builds
86 with build IDs between the given date/datetime and now.
87
88 If a date/datetime range is given, test runs are initiated for all builds
89 with build IDs in the given range.
90
91 If "latest" is given, test runs are initiated for the most recent build.'''
92 parser = OptionParser(usage=usage)
93 parser.add_option('-i', '--ip', action='store', type='string', dest='ip',
94 default='127.0.0.1',
95 help='IP address of autophone controller; defaults to localhost')
96 parser.add_option('-p', '--port', action='store', type='int', dest='port',
97 default=28001,
98 help='port of autophone controller; defaults to 28001')
d687f59 @bclary Bug 821954 - allow specification of repo, build types, r=mcote.
bclary authored
99 parser.add_option('-b', '--build-location', action='store', type='string',
100 dest='build_location', default='nightly',
101 help='build location to search for builds, defaults to nightly;'
d95f25e @markrcote Bug 783585 Fix line endings. r=wlach
markrcote authored
102 ' can be "tinderbox" for both m-c and m-i')
6464449 @markrcote Bug 818188 - Fix ftp-directory-name generation. r=bc
markrcote authored
103 parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
104 default=False, help='verbose output')
d687f59 @bclary Bug 821954 - allow specification of repo, build types, r=mcote.
bclary authored
105 parser.add_option('--repo',
106 dest='repos',
107 action='append',
108 help='The repos to test. '
109 'One of mozilla-central, mozilla-inbound, mozilla-aurora, '
110 'mozilla-beta. To specify multiple repos, specify them '
111 'with additional --repo options. Defaults to mozilla-central.')
112 parser.add_option('--buildtype',
113 dest='buildtypes',
114 action='append',
115 help='The build types to test. '
116 'One of opt or debug. To specify multiple build types, '
117 'specify them with additional --buildtype options. '
118 'Defaults to opt.')
d95f25e @markrcote Bug 783585 Fix line endings. r=wlach
markrcote authored
119 (options, args) = parser.parse_args()
120 if len(args) > 2:
121 parser.print_help()
122 sys.exit(errno.EINVAL)
d687f59 @bclary Bug 821954 - allow specification of repo, build types, r=mcote.
bclary authored
123
124 if not options.repos:
125 options.repos = ['mozilla-central']
126
127 if not options.buildtypes:
128 options.buildtypes = ['opt']
129
6464449 @markrcote Bug 818188 - Fix ftp-directory-name generation. r=bc
markrcote authored
130 if options.verbose:
131 log_level = logging.DEBUG
132 else:
133 log_level = logging.INFO
134
135 logging.basicConfig(level=log_level)
136
d95f25e @markrcote Bug 783585 Fix line endings. r=wlach
markrcote authored
137 sys.exit(main(args, options))
Something went wrong with that request. Please try again.