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

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

Issue 22909021: Add build slave side support for the new swarming.py script. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: fixes 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
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """This script acts as the liason between the master and the swarming_client 6 """This script acts as the liason between the master and the swarming_client
7 code. 7 code.
8 8
9 This helps with master restarts and when swarming_client is updated. It helps 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 10 support older versions of the client code, without having to complexify the
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 '--test-name-prefix', options.prefix, 43 '--test-name-prefix', options.prefix,
44 ] 44 ]
45 for i in options.tasks: 45 for i in options.tasks:
46 cmd.append('--run_from_hash') 46 cmd.append('--run_from_hash')
47 cmd.extend(i) 47 cmd.extend(i)
48 48
49 print ' '.join(cmd) 49 print ' '.join(cmd)
50 return subprocess.call(cmd, cwd=client) 50 return subprocess.call(cmd, cwd=client)
51 51
52 52
53 def v1(client, options): 53 def v0_1(client, options):
54 """Adds --priority support in r217581.""" 54 """Code starting around r218375.
55
56 TODO(maruel): Put exact revision once committe.d
57 """
55 cmd = [ 58 cmd = [
56 sys.executable, 59 sys.executable,
57 os.path.join(client, 'swarm_trigger_step.py'), 60 os.path.join(client, 'swarming.py'),
58 '--swarm-url', options.swarming, 61 'trigger',
59 '--data-server', options.isolate_server, 62 '--swarming', options.swarming,
60 '--os_image', options.os, 63 '--isolate-server', options.isolate_server,
61 '--test-name-prefix', options.prefix, 64 '--os', options.os,
65 '--task-prefix', options.prefix,
62 '--priority', str(PRIORITIES[options.type]), 66 '--priority', str(PRIORITIES[options.type]),
63 ] 67 ]
64 68
65 for i in options.tasks: 69 for i in options.tasks:
66 cmd.append('--run_from_hash') 70 cmd.append('--tasks')
67 cmd.extend(i) 71 cmd.extend(i)
68 72
73 # Enable profiling on the -dev server.
74 if '-dev' in options.swarming:
75 cmd.append('--profile')
76
69 print ' '.join(cmd) 77 print ' '.join(cmd)
70 return subprocess.call(cmd, cwd=client) 78 return subprocess.call(cmd, cwd=client)
71 79
72 80
73 def determine_version_and_run_handler(client, options): 81 def determine_version_and_run_handler(client, options):
74 """Executes the proper handler based on the code layout and --version support. 82 """Executes the proper handler based on the code layout and --version support.
75 """ 83 """
76 # TODO(maruel): Determine version. 84 if os.path.isfile(os.path.join(client, 'swarm_get_results.py')):
77 return v0(client, options) 85 # Oh, that's old.
86 return v0(client, options)
87 return v0_1(client, options)
78 88
79 89
80 def main(): 90 def main():
81 """Note: this is solely to run the current master's code and can totally 91 """Note: this is solely to run the current master's code and can totally
82 differ from the underlying script flags. 92 differ from the underlying script flags.
83 93
84 To update these flags: 94 To update these flags:
85 - Update the following code to support both the previous flag and the new 95 - Update the following code to support both the previous flag and the new
86 flag. 96 flag.
87 - Change scripts/master/factory/swarm_commands.py to pass the new flag. 97 - Change scripts/master/factory/swarm_commands.py to pass the new flag.
88 - Restart all the masters using swarming. 98 - Restart all the masters using swarming.
89 - Remove the old flag from this code. 99 - Remove the old flag from this code.
90 """ 100 """
91 client = swarming_utils.find_client(os.getcwd()) 101 client = swarming_utils.find_client(os.getcwd())
92 if not client: 102 if not client:
93 print >> sys.stderr, 'Failed to find swarm(ing)_client' 103 print >> sys.stderr, 'Failed to find swarm(ing)_client'
94 return 1 104 return 1
95 105
96 parser = optparse.OptionParser() 106 parser = optparse.OptionParser()
97 parser.add_option( 107 parser.add_option(
98 '--os', 108 '--os',
99 help='it\'s possible to trigger a task on an OS while the client code ' 109 help='it\'s possible to trigger a task on an OS while the client code '
100 'runs on another OS') 110 'runs on another OS')
101 parser.add_option('--swarming') 111 parser.add_option('--swarming')
102 parser.add_option('--isolate-server') 112 parser.add_option('--isolate-server')
103 parser.add_option('--task-prefix', help='task name prefix') 113 parser.add_option('--task-prefix', help='task name prefix')
104 parser.add_option( 114 parser.add_option(
105 '--type', 115 '--type',
106 choices=sorted(PRIORITIES), 116 choices=sorted(PRIORITIES),
117 # TODO(maruel): Remove once all masters are restarted.
118 default='tryjob',
107 help='Type of job will define it\'s priority') 119 help='Type of job will define it\'s priority')
108 parser.add_option( 120 parser.add_option(
109 '--task', nargs=4, action='append', default=[], dest='tasks') 121 '--task', nargs=4, action='append', default=[], dest='tasks')
110 options, args = parser.parse_args() 122 options, args = parser.parse_args()
111 if args: 123 if args:
112 parser.error('Unsupported args: %s' % args) 124 parser.error('Unsupported args: %s' % args)
113 125
114 return determine_version_and_run_handler(client, options) 126 return determine_version_and_run_handler(client, options)
115 127
116 128
117 if __name__ == '__main__': 129 if __name__ == '__main__':
118 fix_encoding.fix_encoding() 130 fix_encoding.fix_encoding()
119 sys.exit(main()) 131 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