From: Ondrej Lichtner <olichtne(a)redhat.com>
This module defines classes for storing Result data related to a test
run. Most are generated automatically by LNST during test execution and
a tester also has a Recipe interface available to create Result objects
for custom entries.
These will later be integrated with the rest of the LNST Controller so
that they're created in the right places and accessible as Recipe data
after the test run is finished for optional post-processing.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/RecipeResults.py | 98 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 98 insertions(+)
create mode 100644 lnst/Controller/RecipeResults.py
diff --git a/lnst/Controller/RecipeResults.py b/lnst/Controller/RecipeResults.py
new file mode 100644
index 0000000..b79516d
--- /dev/null
+++ b/lnst/Controller/RecipeResults.py
@@ -0,0 +1,98 @@
+"""
+This module defines classes for storing Result data related to a test run.
+Most are generated automatically by LNST during test execution and a tester
+also has a Recipe interface available to create Result objects for custom
+entries.
+
+Copyright 2018 Red Hat, Inc.
+Licensed under the GNU General Public License, version 2 as
+published by the Free Software Foundation; see COPYING for details.
+"""
+
+__author__ = """
+olichtne(a)redhat.com (Ondrej Lichtner)
+"""
+
+import time
+
+class BaseResult(object):
+ """Base class for storing result data
+
+ should not be instantiated directly, only defines the interface"""
+ def __init__(self, success=True):
+ self._timestamp = time.time()
+ self._success = success
+
+ @property
+ def timestamp(self):
+ return self._timestamp
+
+ @property
+ def success(self):
+ return self._success
+
+ @property
+ def short_desc(self):
+ return "Short description of result if relevant"
+
+ @property
+ def data(self):
+ return None
+
+class JobResult(BaseResult):
+ """Base class for storing result data of Jobs
+
+ should not be instantiated directly, just stores the Job instance"""
+ def __init__(self, job, success):
+ super(JobResult, self).__init__(success)
+
+ self._job = job
+
+ @property
+ def job(self):
+ return self._job
+
+class JobStartResult(JobResult):
+ """Generated automatically when a Job is succesfully started on a
slave"""
+ @BaseResult.short_desc.getter
+ def short_desc(self):
+ return "Job started: {}".format(str(self.job))
+
+class JobFinishResult(JobResult):
+ """Generated automatically when a Job is finished on a slave
+
+ success depends on the Job passed value and returns the data returned as
+ a result of the Job."""
+ def __init__(self, job):
+ super(JobFinishResult, self).__init__(job, True)
+
+ @BaseResult.success.getter
+ def success(self):
+ return self._job.passed
+
+ @BaseResult.short_desc.getter
+ def short_desc(self):
+ return "Job finished: {}".format(str(self.job))
+
+ @BaseResult.data.getter
+ def data(self):
+ return self.job.result
+
+class Result(BaseResult):
+ """Class intended to store aribitrary tester supplied data
+
+ Will be created when the tester calls the Recipe interface for adding
+ results."""
+ def __init__(self, success, short_desc="", data=None):
+ super(Result, self).__init__(success)
+
+ self._short_desc = short_desc
+ self._data = data
+
+ @BaseResult.short_desc.getter
+ def short_desc(self):
+ return self._short_desc
+
+ @BaseResult.data.getter
+ def data(self):
+ return self._data
--
2.16.1
Show replies by date