Make the job executiontag available in both the server and client side job
objects as job.tag.
This is useful if your job would like to copy its data off directly to a
results repository on its own from the client machine.
Mostly small changes to pass the data down, though I did some docstring
cleanup near code that I touched which makes the diff larger.
The execution tag is taken from the autoserv -P parameter if supplied
and no explicit --execution-tag parameter is supplied. This prevents
the need to change monitor_db.py to pass yet another autoserv parameter.
Signed-off-by: Gregory Smith <[email protected]>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@3359 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/autoserv b/server/autoserv
index e16a517..faaeb81 100755
--- a/server/autoserv
+++ b/server/autoserv
@@ -48,6 +48,9 @@
cleanup = parser.options.cleanup
no_tee = parser.options.no_tee
parse_job = parser.options.parse_job
+ execution_tag = parser.options.execution_tag
+ if not execution_tag:
+ execution_tag = parse_job
host_protection = parser.options.host_protection
ssh_user = parser.options.ssh_user
ssh_port = parser.options.ssh_port
@@ -96,7 +99,7 @@
job = server_job.server_job(control, parser.args[1:], results, label,
user, machines, client, parse_job,
ssh_user, ssh_port, ssh_pass,
- group_name=group_name)
+ group_name=group_name, tag=execution_tag)
job.logging.start_logging()
# perform checks
diff --git a/server/autoserv_parser.py b/server/autoserv_parser.py
index c04a67a..0bf34f7 100644
--- a/server/autoserv_parser.py
+++ b/server/autoserv_parser.py
@@ -52,7 +52,13 @@
self.parser.add_option("-P", action="store", type="string",
dest="parse_job",
default='',
- help="parse the results of the job")
+ help="Parse the results of the job using this "
+ "execution tag. Accessable in control "
+ "files as job.tag.")
+ self.parser.add_option("--execution-tag", action="store", type="string",
+ dest="execution_tag", default='',
+ help="Accessable in control files as job.tag; "
+ "Defaults to the value passed to -P.")
self.parser.add_option("-i", action="store_true",
dest="install_before", default=False,
help="reinstall machines before running the job")
diff --git a/server/autotest.py b/server/autotest.py
index 9f81fb2..0b6f6af 100644
--- a/server/autotest.py
+++ b/server/autotest.py
@@ -209,28 +209,31 @@
self.got = True
- def run(self, control_file, results_dir = '.', host = None,
- timeout=None, tag=None, parallel_flag=False, background=False,
- client_disconnect_timeout=1800):
+ def run(self, control_file, results_dir='.', host=None, timeout=None,
+ tag=None, parallel_flag=False, background=False,
+ client_disconnect_timeout=1800, job_tag=''):
"""
Run an autotest job on the remote machine.
- Args:
- control_file: an open file-like-obj of the control file
- results_dir: a str path where the results should be stored
- on the local filesystem
- host: a Host instance on which the control file should
- be run
- tag: tag name for the client side instance of autotest
- parallel_flag: flag set when multiple jobs are run at the
- same time
- background: indicates that the client should be launched as
- a background job; the code calling run will be
- responsible for monitoring the client and
- collecting the results
- Raises:
- AutotestRunError: if there is a problem executing
- the control file
+ @param control_file: An open file-like-obj of the control file.
+ @param results_dir: A str path where the results should be stored
+ on the local filesystem.
+ @param host: A Host instance on which the control file should
+ be run.
+ @param timeout: Maximum number of seconds to wait for the run or None.
+ @param tag: Tag name for the client side instance of autotest.
+ @param parallel_flag: Flag set when multiple jobs are run at the
+ same time.
+ @param background: Indicates that the client should be launched as
+ a background job; the code calling run will be responsible
+ for monitoring the client and collecting the results.
+ @param client_disconnect_timeout: Seconds to wait for the remote host
+ to come back after a reboot. [default: 30 minutes]
+ @param job_tag: The scheduler's execution tag for this particular job
+ to pass on to the clients. 'job#-owner/hostgroupname'
+
+ @raises AutotestRunError: If there is a problem executing
+ the control file.
"""
host = self._get_host_and_setup(host)
results_dir = os.path.abspath(results_dir)
@@ -240,7 +243,7 @@
atrun = _Run(host, results_dir, tag, parallel_flag, background)
self._do_run(control_file, results_dir, host, atrun, timeout,
- client_disconnect_timeout)
+ client_disconnect_timeout, job_tag)
def _get_host_and_setup(self, host):
@@ -254,7 +257,7 @@
def _do_run(self, control_file, results_dir, host, atrun, timeout,
- client_disconnect_timeout):
+ client_disconnect_timeout, job_tag):
try:
atrun.verify_machine()
except:
@@ -283,6 +286,8 @@
% host.job.last_boot_tag)
prologue_lines.append("job.default_test_cleanup(%r)\n"
% host.job.run_test_cleanup)
+ if job_tag:
+ prologue_lines.append("job.default_tag(%r)\n" % job_tag)
# If the packaging system is being used, add the repository list.
try:
diff --git a/server/control_segments/client_wrapper b/server/control_segments/client_wrapper
index f8acae3..ac840ff 100644
--- a/server/control_segments/client_wrapper
+++ b/server/control_segments/client_wrapper
@@ -6,7 +6,7 @@
ssh_pass)
host = hosts.create_host(hostname, user=user, port=port, password=passwd)
host.log_kernel()
- at.run(control, host=host)
+ at.run(control, host=host, job_tag=job.tag)
job.parallel_simple(run_client, machines)
diff --git a/server/server_job.py b/server/server_job.py
index 8566e5e..53af0c1 100755
--- a/server/server_job.py
+++ b/server/server_job.py
@@ -76,22 +76,24 @@
def __init__(self, control, args, resultdir, label, user, machines,
client=False, parse_job='',
ssh_user='root', ssh_port=22, ssh_pass='',
- group_name=''):
+ group_name='', tag=''):
"""
Create a server side job object.
- @param control The pathname of the control file.
- @param args Passed to the control file.
- @param resultdir Where to throw the results.
- @param label Description of the job.
- @param user Username for the job (email address).
- @param client True if this is a client-side control file.
- @param parse_job bool, should the results be through the TKO parser.
- @param ssh_user The SSH username. [root]
- @param ssh_port The SSH port number. [22]
- @param ssh_pass The SSH passphrase, if needed.
- @param group_name If supplied, this will be written out as
+ @param control: The pathname of the control file.
+ @param args: Passed to the control file.
+ @param resultdir: Where to throw the results.
+ @param label: Description of the job.
+ @param user: Username for the job (email address).
+ @param client: True if this is a client-side control file.
+ @param parse_job: string, if supplied it is the job execution tag that
+ the results will be passed through to the TKO parser with.
+ @param ssh_user: The SSH username. [root]
+ @param ssh_port: The SSH port number. [22]
+ @param ssh_pass: The SSH passphrase, if needed.
+ @param group_name: If supplied, this will be written out as
host_group_name in the keyvals file for the parser.
+ @param tag: The job execution tag from the scheduler. [optional]
"""
path = os.path.dirname(__file__)
self.autodir = os.path.abspath(os.path.join(path, '..'))
@@ -128,6 +130,7 @@
self.ssh_user = ssh_user
self.ssh_port = ssh_port
self.ssh_pass = ssh_pass
+ self.tag = tag
self.run_test_cleanup = True
self.last_boot_tag = None
self.hosts = set()
@@ -477,8 +480,8 @@
try:
shutil.rmtree(temp_control_file_dir)
except Exception, e:
- print 'Error %s removing dir %s' % (e,
- temp_control_file_dir)
+ logging.warn('Could not remove temp directory %s: %s',
+ temp_control_file_dir, e)
if machines and (collect_crashdumps or collect_crashinfo):
namespace['test_start_time'] = test_start_time