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

Side by Side Diff: server/autotest.py

Issue 6883035: Merge remote branch 'autotest-upstream/master' into autotest-merge (Closed) Base URL: ssh://gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 8 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 # Copyright 2007 Google Inc. Released under the GPL v2 1 # Copyright 2007 Google Inc. Released under the GPL v2
2 2
3 import re, os, sys, traceback, subprocess, time, pickle, glob, tempfile 3 import re, os, sys, traceback, subprocess, time, pickle, glob, tempfile
4 import logging, getpass 4 import logging, getpass
5 from autotest_lib.server import installable_object, prebuild, utils 5 from autotest_lib.server import installable_object, prebuild, utils
6 from autotest_lib.client.common_lib import base_job, log, error, autotemp 6 from autotest_lib.client.common_lib import base_job, log, error, autotemp
7 from autotest_lib.client.common_lib import global_config, packages 7 from autotest_lib.client.common_lib import global_config, packages
8 from autotest_lib.client.common_lib import utils as client_utils 8 from autotest_lib.client.common_lib import utils as client_utils
9 9
10 AUTOTEST_SVN = 'svn://test.kernel.org/autotest/trunk/client' 10 AUTOTEST_SVN = 'svn://test.kernel.org/autotest/trunk/client'
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 host.run('mkdir -p %s' % utils.sh_escape(path)) 112 host.run('mkdir -p %s' % utils.sh_escape(path))
113 host.run('test -w %s' % utils.sh_escape(path)) 113 host.run('test -w %s' % utils.sh_escape(path))
114 return path 114 return path
115 except error.AutoservRunError: 115 except error.AutoservRunError:
116 logging.debug('Failed to create %s', path) 116 logging.debug('Failed to create %s', path)
117 raise error.AutoservInstallError( 117 raise error.AutoservInstallError(
118 'Unable to find a place to install Autotest; tried %s', 118 'Unable to find a place to install Autotest; tried %s',
119 ', '.join(client_autodir_paths)) 119 ', '.join(client_autodir_paths))
120 120
121 121
122 def get_fetch_location(self):
123 c = global_config.global_config
124 repos = c.get_config_value("PACKAGES", 'fetch_location', type=list,
125 default=[])
126 repos.reverse()
127 return repos
128
129
122 def install(self, host=None, autodir=None): 130 def install(self, host=None, autodir=None):
123 self._install(host=host, autodir=autodir) 131 self._install(host=host, autodir=autodir)
124 132
125 133
126 def install_full_client(self, host=None, autodir=None): 134 def install_full_client(self, host=None, autodir=None):
127 self._install(host=host, autodir=autodir, use_autoserv=False, 135 self._install(host=host, autodir=autodir, use_autoserv=False,
128 use_packaging=False) 136 use_packaging=False)
129 137
130 138
131 def install_no_autoserv(self, host=None, autodir=None): 139 def install_no_autoserv(self, host=None, autodir=None):
132 self._install(host=host, autodir=autodir, use_autoserv=False) 140 self._install(host=host, autodir=autodir, use_autoserv=False)
133 141
134 142
135 def _install_using_packaging(self, host, autodir): 143 def _install_using_packaging(self, host, autodir):
136 c = global_config.global_config 144 repos = self.get_fetch_location()
137 repos = c.get_config_value("PACKAGES", 'fetch_location', type=list,
138 default=[])
139 repos.reverse()
140 if not repos: 145 if not repos:
141 raise error.PackageInstallError("No repos to install an " 146 raise error.PackageInstallError("No repos to install an "
142 "autotest client from") 147 "autotest client from")
143 pkgmgr = packages.PackageManager(autodir, hostname=host.hostname, 148 pkgmgr = packages.PackageManager(autodir, hostname=host.hostname,
144 repo_urls=repos, 149 repo_urls=repos,
145 do_locking=False, 150 do_locking=False,
146 run_function=host.run, 151 run_function=host.run,
147 run_function_dargs=dict(timeout=600)) 152 run_function_dargs=dict(timeout=600))
148 # The packages dir is used to store all the packages that 153 # The packages dir is used to store all the packages that
149 # are fetched on that client. (for the tests,deps etc. 154 # are fetched on that client. (for the tests,deps etc.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 359
355 # build up the initialization prologue for the control file 360 # build up the initialization prologue for the control file
356 prologue_lines = [] 361 prologue_lines = []
357 362
358 # Add the additional user arguments 363 # Add the additional user arguments
359 prologue_lines.append("args = %r\n" % self.job.args) 364 prologue_lines.append("args = %r\n" % self.job.args)
360 365
361 # If the packaging system is being used, add the repository list. 366 # If the packaging system is being used, add the repository list.
362 repos = None 367 repos = None
363 try: 368 try:
364 c = global_config.global_config 369 repos = self.get_fetch_location()
365 repos = c.get_config_value("PACKAGES", 'fetch_location', type=list)
366 repos.reverse() # high priority packages should be added last
367 pkgmgr = packages.PackageManager('autotest', hostname=host.hostname, 370 pkgmgr = packages.PackageManager('autotest', hostname=host.hostname,
368 repo_urls=repos) 371 repo_urls=repos)
369 prologue_lines.append('job.add_repository(%s)\n' % repos) 372 prologue_lines.append('job.add_repository(%s)\n' % repos)
370 except global_config.ConfigError, e: 373 except global_config.ConfigError, e:
371 # If repos is defined packaging is enabled so log the error 374 # If repos is defined packaging is enabled so log the error
372 if repos: 375 if repos:
373 logging.error(e) 376 logging.error(e)
374 377
375 # on full-size installs, turn on any profilers the server is using 378 # on full-size installs, turn on any profilers the server is using
376 if not atrun.background: 379 if not atrun.background:
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 self.host.send_file(tarball_path, remote_dest) 997 self.host.send_file(tarball_path, remote_dest)
995 finally: 998 finally:
996 temp_dir.clean() 999 temp_dir.clean()
997 return 1000 return
998 1001
999 1002
1000 def log_warning(self, msg, warning_type): 1003 def log_warning(self, msg, warning_type):
1001 """Injects a WARN message into the current status logging stream.""" 1004 """Injects a WARN message into the current status logging stream."""
1002 timestamp = int(time.time()) 1005 timestamp = int(time.time())
1003 if self.job.warning_manager.is_valid(timestamp, warning_type): 1006 if self.job.warning_manager.is_valid(timestamp, warning_type):
1004 self.job.record('WARN', None, None, {}, msg) 1007 self.job.record('WARN', None, None, msg)
1005 1008
1006 1009
1007 def write(self, data): 1010 def write(self, data):
1008 # now start processing the existing buffer and the new data 1011 # now start processing the existing buffer and the new data
1009 data = self.leftover + data 1012 data = self.leftover + data
1010 lines = data.split('\n') 1013 lines = data.split('\n')
1011 processed_lines = 0 1014 processed_lines = 0
1012 try: 1015 try:
1013 # process all the buffered data except the last line 1016 # process all the buffered data except the last line
1014 # ignore the last line since we may not have all of it yet 1017 # ignore the last line since we may not have all of it yet
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 1071
1069 @returns: True if the test passes, False otherwise.""" 1072 @returns: True if the test passes, False otherwise."""
1070 at = self._Autotest() 1073 at = self._Autotest()
1071 control_file = ('result = job.run_test(%s)\n' 1074 control_file = ('result = job.run_test(%s)\n'
1072 'job.set_state("test_result", result)\n') 1075 'job.set_state("test_result", result)\n')
1073 test_args = [repr(test_name)] 1076 test_args = [repr(test_name)]
1074 test_args += ['%s=%r' % (k, v) for k, v in dargs.iteritems()] 1077 test_args += ['%s=%r' % (k, v) for k, v in dargs.iteritems()]
1075 control_file %= ', '.join(test_args) 1078 control_file %= ', '.join(test_args)
1076 at.run(control_file, host=self) 1079 at.run(control_file, host=self)
1077 return at.job.get_state('test_result', default=False) 1080 return at.job.get_state('test_result', default=False)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698