diff options
author | Mark Beierl <mark.beierl@dell.com> | 2016-11-22 15:45:17 -0500 |
---|---|---|
committer | Mark Beierl <mark.beierl@dell.com> | 2016-11-23 10:54:26 -0500 |
commit | def8cbb9d7e45060512594b6e3c89bf2db3cced7 (patch) | |
tree | 98fe2dc368657f257f45fa3ece7814a1294bf975 | |
parent | 677d8f93db164ac7fb15811d5ce1e1a0eee30160 (diff) |
Ability to query job status
Provide a method to query the status of a job by id
Change-Id: I4d3567995e7c7c3359596346009358276e79d65c
JIRA: STORPERF-89
Signed-off-by: Mark Beierl <mark.beierl@dell.com>
-rw-r--r-- | rest_server.py | 3 | ||||
-rw-r--r-- | storperf/storperf_master.py | 3 | ||||
-rw-r--r-- | storperf/test_executor.py | 28 |
3 files changed, 26 insertions, 8 deletions
diff --git a/rest_server.py b/rest_server.py index 2b5bbfb..d852bbb 100644 --- a/rest_server.py +++ b/rest_server.py @@ -287,6 +287,9 @@ class Job(Resource): if type == "metadata": return jsonify(storperf.fetch_metadata(workload_id)) + if type == "status": + return jsonify({"Status": storperf.fetch_job_status(workload_id)}) + @swagger.operation( parameters=[ { diff --git a/storperf/storperf_master.py b/storperf/storperf_master.py index 91b1bd1..99df47f 100644 --- a/storperf/storperf_master.py +++ b/storperf/storperf_master.py @@ -331,6 +331,9 @@ class StorPerfMaster(object): def fetch_metadata(self, job_id): return self.job_db.fetch_workload_params(job_id) + def fetch_job_status(self, job_id): + return self._test_executor.execution_status(job_id) + def _setup_slave(self, slave): logger = logging.getLogger(__name__ + ":" + slave) diff --git a/storperf/test_executor.py b/storperf/test_executor.py index fc51adc..c984175 100644 --- a/storperf/test_executor.py +++ b/storperf/test_executor.py @@ -7,8 +7,16 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +import copy +import imp +import logging from os import listdir +import os from os.path import isfile, join +import sched +from threading import Thread +import time + from storperf.carbon.converter import Converter from storperf.carbon.emitter import CarbonMetricTransmitter from storperf.db import test_results_db @@ -16,13 +24,6 @@ from storperf.db.graphite_db import GraphiteDB from storperf.db.job_db import JobDB from storperf.fio.fio_invoker import FIOInvoker from storperf.utilities import dictionary -from threading import Thread -import copy -import imp -import logging -import os -import sched -import time class UnknownWorkload(Exception): @@ -165,6 +166,15 @@ class TestExecutor(object): terminated_hosts.append(workload.remote_host) return terminated_hosts + def execution_status(self, job_id): + if self.job_db.job_id != job_id: + return "Completed" + + if (self._terminated is False): + return "Running" + + return "Completed" + def execute_workloads(self): self._terminated = False self.logger.info("Starting job %s" % (self.job_db.job_id)) @@ -232,6 +242,8 @@ class TestExecutor(object): self.logger.info("Completed workload %s" % (workload_name)) self.logger.info("Completed job %s" % (self.job_db.job_id)) + self._terminated = True + end_time = time.time() pod_name = dictionary.get_key_from_dict(self.metadata, 'pod_name', @@ -263,7 +275,7 @@ class TestExecutor(object): payload['metrics'] = graphite_db.fetch_averages(self.job_db.job_id) criteria = {} criteria['block_sizes'] = self.block_sizes - criteria['queue_depths'] = self.block_sizes + criteria['queue_depths'] = self.queue_depths try: test_results_db.push_results_to_db(test_db, |