Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: scripts/slave/swarming/trigger_swarm.py

Issue 23176003: Create proper wrapper scripts to decouple from swarm_client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: add docstrings Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
Isaac (away) 2013/08/20 22:22:33 I'm confused what the purpose of this file is -- c
M-A Ruel 2013/08/23 02:18:33 It triggers a swarm job. Then get_swarm_results.py
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """This script acts as the liason between the master and the swarming_client
7 code.
8
9 This helps with master restarts and when swarming_client is updated. It helps
10 support older versions of the client code, without having to complexify the
11 master code.
12 """
13
14 import optparse
15 import os
16 import subprocess
17 import sys
18
19 from common import find_depot_tools # pylint: disable=W0611
20
21 from slave.swarming import swarming_utils
22
23 # From depot tools/
24 import fix_encoding
25
26
27 PRIORITIES = {
28 'ci': 10,
29 'cq': 20,
30 'fyi': 30,
31 'tryjob': 40,
32 }
33
34
35 def v0(client, options):
36 """Compatible up to the oldest swarm_client code."""
37 cmd = [
38 sys.executable,
39 os.path.join(client, 'swarm_trigger_step.py'),
40 '--swarm-url', options.swarming,
41 '--data-server', options.isolate_server,
42 '--os_image', options.os,
43 '--test-name-prefix', options.prefix,
44 ]
45 for i in options.tasks:
46 cmd.append('--run_from_hash')
47 cmd.extend(i)
48
49 print ' '.join(cmd)
50 return subprocess.call(cmd, cwd=client)
51
52
53 def v1(client, options):
54 """Adds --priority support in r217581."""
55 cmd = [
56 sys.executable,
57 os.path.join(client, 'swarm_trigger_step.py'),
58 '--swarm-url', options.swarming,
59 '--data-server', options.isolate_server,
60 '--os_image', options.os,
61 '--test-name-prefix', options.prefix,
62 '--priority', str(PRIORITIES[options.type]),
63 ]
64
65 for i in options.tasks:
66 cmd.append('--run_from_hash')
67 cmd.extend(i)
68
69 print ' '.join(cmd)
70 return subprocess.call(cmd, cwd=client)
71
72
73 def determine_version_and_run_handler(client, options):
74 """Executes the proper handler based on the code layout and --version support.
75 """
76 # TODO(maruel): Determine version.
77 return v0(client, options)
78
79
80 def main():
81 """Note: this is solely to run the current master's code and can totally
82 differ from the underlying script flags.
83
84 To update these flags:
85 - Update the following code to support both the previous flag and the new
86 flag.
87 - Change scripts/master/factory/swarm_commands.py to pass the new flag.
88 - Restart all the masters using swarming.
89 - Remove the old flag from this code.
90 """
91 client = swarming_utils.find_client(os.getcwd())
92 if not client:
93 print >> sys.stderr, 'Failed to find swarm(ing)_client'
94 return 1
95
96 parser = optparse.OptionParser()
97 parser.add_option(
98 '--os',
99 help='it\'s possible to trigger a task on an OS while the client code '
100 'runs on another OS')
101 parser.add_option('--swarming')
102 parser.add_option('--isolate-server')
103 parser.add_option('--task-prefix', help='task name prefix')
104 parser.add_option(
105 '--type',
106 choices=sorted(PRIORITIES),
107 help='Type of job will define it\'s priority')
108 parser.add_option(
109 '--task', nargs=4, action='append', default=[], dest='tasks')
110 options, args = parser.parse_args()
111 if args:
112 parser.error('Unsupported args: %s' % args)
113
114 return determine_version_and_run_handler(client, options)
115
116
117 if __name__ == '__main__':
118 fix_encoding.fix_encoding()
119 sys.exit(main())
OLDNEW
« scripts/slave/swarming/get_swarm_results.py ('K') | « scripts/slave/swarming/swarming_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698