Permalink
Browse files

Bug 850395 - Allow device-specific jobs. r=bc

  • Loading branch information...
1 parent 3efbb60 commit cc8be502c662d5aad7d3e9374883dee9e94abebf @markrcote markrcote committed Mar 12, 2013
Showing with 35 additions and 21 deletions.
  1. +9 −3 autophone.py
  2. +0 −3 buildserver.py
  3. +26 −15 trigger_runs.py
View
@@ -197,9 +197,11 @@ def worker_msg_loop(self):
self.stop()
# Start the phones for testing
- def start_tests(self, build_url):
+ def start_tests(self, build_url, devices=None):
self.worker_lock.acquire()
for p in self.phone_workers.values():
+ if devices and p.phone_cfg['phoneid'] not in devices:
+ continue
logging.info('Notifying device %s of new build.' %
p.phone_cfg['phoneid'])
p.new_build(build_url)
@@ -223,7 +225,7 @@ def route_cmd(self, data):
elif cmd == 'log':
logging.info(params)
elif cmd == 'triggerjobs':
- self.trigger_jobs(params)
+ response = self.trigger_jobs(params)
elif cmd == 'register':
self.register_cmd(params)
elif cmd == 'status':
@@ -372,7 +374,11 @@ def read_tests(self):
def trigger_jobs(self, data):
logging.info('Received user-specified job: %s' % data)
- self.start_tests(data)
+ args = data.split(' ')
+ if not args:
+ return 'invalid args'
+ self.start_tests(args[0], args[1:])
+ return 'ok'
def reset_phones(self):
logging.info('Resetting phones...')
View
@@ -8,8 +8,6 @@
import socket
import threading
-from builds import BuildCache
-
DEFAULT_PORT = 28008
class BuildCacheServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
@@ -81,4 +79,3 @@ def get(self, url, force=False):
return None
buf += data
return json.loads(buf)
-
View
@@ -20,15 +20,22 @@ def from_iso_date_or_datetime(s):
return d
+def command_str(build, devices):
+ s = 'triggerjobs %s' % build
+ if devices:
+ s += ' %s' % ' '.join(devices)
+ return s
+
+
def main(args, options):
logging.info('Looking for builds...')
+ build_urls = []
if args[0] == 'latest':
- cache_build_dir = (builds.BuildCache(options.repos,
- options.buildtypes).
- find_latest_build(options.build_location))
- if not cache_build_dir:
- return 1
- commands = ['triggerjobs %s' % cache_build_dir]
+ build_url = builds.BuildCache(
+ options.repos, options.buildtypes).find_latest_build(
+ options.build_location)
+ if build_url:
+ build_urls = [build_url]
else:
if re.match('\d{14}', args[0]):
# build id
@@ -45,14 +52,13 @@ def main(args, options):
start_time = start_time.replace(tzinfo=pytz.timezone('US/Pacific'))
if not end_time.tzinfo:
end_time = end_time.replace(tzinfo=pytz.timezone('US/Pacific'))
- cache_build_dir_list = (builds.BuildCache(options.repos,
- options.buildtypes).
- find_builds(start_time, end_time,
- options.build_location))
- if not cache_build_dir_list:
- return 1
- commands = ['triggerjobs %s' % cache_build_dir for cache_build_dir in
- cache_build_dir_list]
+ build_urls = builds.BuildCache(
+ options.repos, options.buildtypes).find_builds(
+ start_time, end_time, options.build_location)
+
+ if not build_urls:
+ return 1
+ commands = [command_str(b, options.devices) for b in build_urls]
logging.info('Connecting to autophone server...')
commands.append('exit')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -64,7 +70,7 @@ def main(args, options):
logging.info('- %s' % s.recv(1024).strip())
return 0
-
+
if __name__ == '__main__':
import errno
import sys
@@ -116,6 +122,11 @@ def main(args, options):
'One of opt or debug. To specify multiple build types, '
'specify them with additional --buildtype options. '
'Defaults to opt.')
+ parser.add_option('--device',
+ dest='devices',
+ action='append',
+ help='Device on which to run the job. Defaults to all '
+ 'if not specified. Can be specified multiple times.')
(options, args) = parser.parse_args()
if len(args) > 2:
parser.print_help()

0 comments on commit cc8be50

Please sign in to comment.