summaryrefslogtreecommitdiffstats
path: root/api/utils/daemonthread.py
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2016-12-28 10:27:14 +0000
committerchenjiankun <chenjiankun1@huawei.com>2016-12-28 10:34:55 +0000
commit254414758828a12a353e0670704faa5bcb792cae (patch)
treec5b9b5d7fc02e62dd0e917b8cc5b3269e6c9c742 /api/utils/daemonthread.py
parent827e341ed222a562a87d8f238fc0a6a16cfb1393 (diff)
Record test case names when run a task using API
JIRA: YARDSTICK-509 Currently we use influxdb as database and will not record test case name when run a test case. So if we must offer test case name if we want to get result from API. Regarding future requirement, I create sqlite database and alchemy orm framework. And record test case name when run a test case. So we needn't offer test case any more when call for get result API. Change-Id: I7d7dc24543a33918546267591f7bdcd0742928cb Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api/utils/daemonthread.py')
-rw-r--r--api/utils/daemonthread.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/api/utils/daemonthread.py b/api/utils/daemonthread.py
index 47c0b9108..19182c429 100644
--- a/api/utils/daemonthread.py
+++ b/api/utils/daemonthread.py
@@ -8,11 +8,10 @@
##############################################################################
import threading
import os
-import datetime
import errno
from api import conf
-from api.utils.influx import write_data_tasklist
+from api.database.handlers import TasksHandler
class DaemonThread(threading.Thread):
@@ -21,19 +20,24 @@ class DaemonThread(threading.Thread):
super(DaemonThread, self).__init__(target=method, args=args)
self.method = method
self.command_list = args[0]
- self.task_id = args[1]
+ self.task_dict = args[1]
def run(self):
- timestamp = datetime.datetime.now()
+ self.task_dict['status'] = 0
+ task_id = self.task_dict['task_id']
try:
- write_data_tasklist(self.task_id, timestamp, 0)
- self.method(self.command_list, self.task_id)
- write_data_tasklist(self.task_id, timestamp, 1)
+ task_handler = TasksHandler()
+ task = task_handler.insert(self.task_dict)
+
+ self.method(self.command_list, task_id)
+
+ task_handler.update_status(task, 1)
except Exception as e:
- write_data_tasklist(self.task_id, timestamp, 2, error=str(e))
+ task_handler.update_status(task, 2)
+ task_handler.update_error(task, str(e))
finally:
- _handle_testsuite_file(self.task_id)
+ _handle_testsuite_file(task_id)
def _handle_testsuite_file(task_id):