Returns job id and status 99/42699/4
authorTaseer Ahmed <taseer94@gmail.com>
Thu, 21 Sep 2017 19:41:37 +0000 (00:41 +0500)
committerTaseer Ahmed <taseer94@gmail.com>
Wed, 27 Sep 2017 05:17:35 +0000 (10:17 +0500)
- If the user GETs for job without ID and type status,
  return all jobs along with status

JIRA: STORPERF-213

Change-Id: I5518acae45f259644c961c6dc9f0cb170b86b6e1
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
docker/storperf-master/rest_server.py
docker/storperf-master/storperf/test_executor.py
docs/testing/user/test-usage.rst

index 5be3fb4..7bcd650 100644 (file)
@@ -280,11 +280,17 @@ class Job(Resource):
 
             if metrics_type == "status":
                 return jsonify(storperf.fetch_job_status(workload_id))
+
         else:
             metrics_type = None
             if request.args.get('type'):
                 metrics_type = request.args.get('type')
-            return jsonify(storperf.fetch_all_jobs(metrics_type))
+
+            if metrics_type == "status":
+                return jsonify(storperf.fetch_job_status(workload_id))
+
+            else:
+                return jsonify(storperf.fetch_all_jobs(metrics_type))
 
     @swagger.operation(
         parameters=[
index 4c2c972..629ae15 100644 (file)
@@ -219,9 +219,18 @@ class TestExecutor(object):
         if self.job_db.job_id == job_id and self._terminated is False:
             status = "Running"
 
-        result['Status'] = status
-        result['Workloads'] = self.workload_status
-        result['TestResultURL'] = self.result_url
+            result['Status'] = status
+            result['Workloads'] = self.workload_status
+            result['TestResultURL'] = self.result_url
+
+        else:
+            jobs = self.job_db.fetch_jobs()
+            self.logger.info("Jobs")
+            self.logger.info(jobs)
+            for job in jobs:
+                if self.job_db.job_id == job_id and self._terminated is False:
+                    status = "Running"
+            result[job] = status
 
         return result
 
index 2934a5c..8048cff 100644 (file)
@@ -209,6 +209,7 @@ This is an example of a type=status call.
      }
    }
 
+If the `job_id` is not provided along with `type` status, then all jobs are returned along with their status.
 Metrics
 ~~~~~~~
 Metrics can be queried at any time during or after the completion of a run.