diff options
author | jadmanski <jadmanski@592f7852-d20e-0410-864c-8624ca9c26a4> | 2008-09-15 19:15:02 +0000 |
---|---|---|
committer | jadmanski <jadmanski@592f7852-d20e-0410-864c-8624ca9c26a4> | 2008-09-15 19:15:02 +0000 |
commit | e9a06dff97ee68a0a399e3048a20032f5787285c (patch) | |
tree | 6618f1166ca77fd4c5faae5ef346daeb3338556c | |
parent | c413213f37ee4c4949c3c33f86672f54c872df7b (diff) |
Add a method to the Host objects for logging the currently running
kernel, and a method for logging "informational" status logs that
update the kernel without requiring any real action to occur. This
logging will always occur at the start of a client job, for server-side
jobs it will still be opt-in only, since we don't have a clean place
to log it where we know we have access to a host object.
Risk: Medium
Visibility: Client-side jobs should always have a real kernel
associated with all logged tests, and server-side jobs have an easy
way to log the same thing.
Signed-off-by: John Admanski <jadmanski@google.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@2157 592f7852-d20e-0410-864c-8624ca9c26a4
-rw-r--r-- | client/common_lib/logging.py | 2 | ||||
-rw-r--r-- | server/hosts/base_classes.py | 11 | ||||
-rwxr-xr-x | server/server_job.py | 1 | ||||
-rw-r--r-- | tko/parsers/version_0_unittest.py | 6 | ||||
-rw-r--r-- | tko/parsers/version_1.py | 20 | ||||
-rw-r--r-- | tko/parsers/version_1_unittest.py | 7 |
6 files changed, 46 insertions, 1 deletions
diff --git a/client/common_lib/logging.py b/client/common_lib/logging.py index 5f6f6200..c0905df4 100644 --- a/client/common_lib/logging.py +++ b/client/common_lib/logging.py @@ -11,7 +11,7 @@ job_statuses = ["TEST_NA", "ABORT", "ERROR", "FAIL", "WARN", "GOOD", "ALERT", "RUNNING", "NOSTATUS"] def is_valid_status(status): - if not re.match(r'(START|(END )?('+'|'.join(job_statuses)+'))$', + if not re.match(r'(START|INFO|(END )?('+'|'.join(job_statuses)+'))$', status): return False else: diff --git a/server/hosts/base_classes.py b/server/hosts/base_classes.py index 4896b3fe..9e2b654d 100644 --- a/server/hosts/base_classes.py +++ b/server/hosts/base_classes.py @@ -217,6 +217,17 @@ class Host(object): self.job.record(*args, **dargs) + def log_kernel(self): + """ Helper method for logging kernel information into the status logs. + Intended for cases where the "current" kernel is not really defined + and we want to explicitly log it. Does nothing if this host isn't + actually associated with a job. """ + if self.job: + kernel = self.get_kernel_ver() + self.job.record("INFO", None, None, + optional_fields={"kernel": kernel}) + + def log_reboot(self, reboot_func): """ Decorator for wrapping a reboot in a group for status logging purposes. The reboot_func parameter should be an actual diff --git a/server/server_job.py b/server/server_job.py index b2733cb6..ebf0bddd 100755 --- a/server/server_job.py +++ b/server/server_job.py @@ -58,6 +58,7 @@ def run_client(machine): machine, ssh_user, ssh_port, ssh_pass) host = hosts.create_host(hostname, user=user, port=port, password=passwd) + host.log_kernel() at.run(control, host=host) job.parallel_simple(run_client, machines) diff --git a/tko/parsers/version_0_unittest.py b/tko/parsers/version_0_unittest.py index 03c13b2f..6ca7df82 100644 --- a/tko/parsers/version_0_unittest.py +++ b/tko/parsers/version_0_unittest.py @@ -17,6 +17,12 @@ class test_status_line(unittest.TestCase): self.assertEquals(line.status, None) + def test_fails_info(self): + self.assertRaises(AssertionError, + version_0.status_line, 0, "INFO", "----", "----", + "", {}) + + def test_handles_status(self): for stat in self.statuses: line = version_0.status_line(0, stat, "----", "test", diff --git a/tko/parsers/version_1.py b/tko/parsers/version_1.py index 25308137..0aea722f 100644 --- a/tko/parsers/version_1.py +++ b/tko/parsers/version_1.py @@ -53,6 +53,21 @@ class iteration(models.iteration): class status_line(version_0.status_line): + def __init__(self, indent, status, subdir, testname, reason, + optional_fields): + # handle INFO fields + if status == "INFO": + self.type = "INFO" + self.indent = indent + self.status = self.subdir = self.testname = self.reason = None + self.optional_fields = optional_fields + else: + # everything else is backwards compatible + super(status_line, self).__init__(indent, status, subdir, + testname, reason, + optional_fields) + + def is_successful_reboot(self, current_status): # make sure this is a reboot line if self.testname != "reboot": @@ -192,6 +207,11 @@ class parser(base.parser): started_time_stack.append(started_time) subdir_stack.append(line.subdir) continue + elif line.type == "INFO": + # update the current kernel if one is defined in the info + if "kernel" in line.optional_fields: + current_kernel = line.get_kernel() + continue elif line.type == "STATUS": # ABORT if indentation was unexpectedly low if line.indent < stack.size(): diff --git a/tko/parsers/version_1_unittest.py b/tko/parsers/version_1_unittest.py index 8e85224f..072ab5bd 100644 --- a/tko/parsers/version_1_unittest.py +++ b/tko/parsers/version_1_unittest.py @@ -17,6 +17,13 @@ class test_status_line(unittest.TestCase): self.assertEquals(line.status, None) + def test_handles_info(self): + line = version_1.status_line(0, "INFO", "----", "----", + "", {}) + self.assertEquals(line.type, "INFO") + self.assertEquals(line.status, None) + + def test_handles_status(self): for stat in self.statuses: line = version_1.status_line(0, stat, "----", "test", |