Add URL for results report 65/27865/1
authormbeierl <mark.beierl@dell.com>
Wed, 1 Feb 2017 19:27:19 +0000 (14:27 -0500)
committermbeierl <mark.beierl@dell.com>
Wed, 1 Feb 2017 19:41:49 +0000 (14:41 -0500)
Records the URL returned from testresults db.

Changes the URL ref from localhost to external and reports in
daily job.

Change-Id: I0068ea963671fb183779ac20592ba6933647eea0
JIRA: STORPERF-104
Signed-off-by: mbeierl <mark.beierl@dell.com>
ci/daily.sh
storperf/db/job_db.py
storperf/db/test_results_db.py
storperf/test_executor.py
storperf/utilities/data_handler.py
tests/utilities_tests/data_handler_test.py

index b31f8e6..1e01cb8 100755 (executable)
@@ -90,7 +90,6 @@ do
     | awk '/Status/ {print $2}' | cut -d\" -f2`
 done
 
-
 echo ==========================================================================
 echo Starting full matrix run
 echo ==========================================================================
@@ -112,9 +111,14 @@ do
     | awk '/Status/ {print $2}' | cut -d\" -f2`
 done
 
+HREF=`curl -s -X GET "http://127.0.0.1:5000/api/v1.0/jobs?id=$JOB&type=status" \
+    | awk '/TestResultURL/ {print $2}' | cut -d\" -f2 | cut -d/ -f4-`
+
 echo "Deleting stack for cleanup"
 curl -X DELETE --header 'Accept: application/json' 'http://127.0.0.1:5000/api/v1.0/configurations'
 
 sudo chmod 777 -R $WORKSPACE/ci/job/carbon
 
+echo "Results published to: http://testresults.opnfv.org/test/$HREF"
+
 exit 0
index 3d66be8..05160ec 100644 (file)
@@ -7,11 +7,11 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
-from sqlite3 import OperationalError
-from threading import Lock
 import calendar
 import logging
+from sqlite3 import OperationalError
 import sqlite3
+from threading import Lock
 import time
 import uuid
 
@@ -54,6 +54,14 @@ class JobDB(object):
             except OperationalError:
                 self.logger.debug("Job params table exists")
 
+            try:
+                cursor.execute('''CREATE TABLE job_summary
+                (job_id text,
+                summary text)''')
+                self.logger.debug("Created job table")
+            except OperationalError:
+                self.logger.debug("Job table exists")
+
             cursor.execute('SELECT * FROM jobs')
             cursor.execute('SELECT * FROM job_params')
             db.commit()
index 038525f..a2f7038 100644 (file)
@@ -52,10 +52,10 @@ def push_results_to_db(db_url, project, case_name,
             logger.debug(r)
             logger.debug(r.status_code)
             logger.debug(r.content)
-        return True
+        return json.loads(r.content)
     except Exception, e:
         logger.error("Error [push_results_to_db('%s', '%s', '%s', " +
                      "'%s', '%s', '%s', '%s', '%s', '%s')]:" %
                      (db_url, project, case_name, pod_name, version,
                       scenario, criteria, build_tag, details), e)
-        return False
+        return None
index e6f0784..d46e0c7 100644 (file)
@@ -43,6 +43,7 @@ class TestExecutor(object):
         self.end_time = None
         self.current_workload = None
         self.workload_status = {}
+        self.result_url = None
         self._queue_depths = [1, 4, 8]
         self._block_sizes = [512, 4096, 16384]
         self.event_listeners = set()
@@ -198,6 +199,7 @@ class TestExecutor(object):
 
         result['Status'] = status
         result['Workloads'] = self.workload_status
+        result['TestResultURL'] = self.result_url
 
         return result
 
@@ -303,6 +305,9 @@ class TestExecutor(object):
             self.logger.info("Completed workload %s" % (workload_name))
         self.logger.info("Completed job %s" % (self.job_db.job_id))
 
+        if self.result_url is not None:
+            self.logger.info("Results can be found at %s" % self.result_url)
+
         self.end_time = time.time()
         self._terminated = True
         self.broadcast_event()
index 78708b5..b62d37b 100644 (file)
@@ -9,14 +9,15 @@
 
 import logging
 import os
+from time import sleep
+import time
+
 from storperf.db import test_results_db
 from storperf.db.graphite_db import GraphiteDB
 from storperf.utilities import data_treatment as DataTreatment
 from storperf.utilities import dictionary
 from storperf.utilities import math as math
 from storperf.utilities import steady_state as SteadyState
-from time import sleep
-import time
 
 
 class DataHandler(object):
@@ -167,17 +168,18 @@ class DataHandler(object):
         if test_db is not None:
             self.logger.info("Pushing results to %s" % (test_db))
             try:
-                test_results_db.push_results_to_db(test_db,
-                                                   "storperf",
-                                                   test_case,
-                                                   start_time,
-                                                   end_time,
-                                                   self.logger,
-                                                   pod_name,
-                                                   version,
-                                                   scenario,
-                                                   criteria,
-                                                   build_tag,
-                                                   payload)
+                response = test_results_db.push_results_to_db(test_db,
+                                                              "storperf",
+                                                              test_case,
+                                                              start_time,
+                                                              end_time,
+                                                              self.logger,
+                                                              pod_name,
+                                                              version,
+                                                              scenario,
+                                                              criteria,
+                                                              build_tag,
+                                                              payload)
+                executor.result_url = response['href']
             except:
                 self.logger.exception("Error pushing results into Database")
index 7963c9f..90df0f6 100644 (file)
@@ -8,11 +8,12 @@
 ##############################################################################
 
 import os
-from storperf.utilities.data_handler import DataHandler
 import unittest
 
 import mock
 
+from storperf.utilities.data_handler import DataHandler
+
 
 class MockGraphiteDB(object):
 
@@ -54,7 +55,8 @@ class DataHandlerTest(unittest.TestCase):
     def push_results_to_db(self, *args):
         self.pushed = True
         self.db_results = args
-        pass
+        results = {"href": "http://localhost/api/result/uuid-that-is-long"}
+        return results
 
     def terminate(self):
         self._terminated = True
@@ -283,4 +285,3 @@ class DataHandlerTest(unittest.TestCase):
                          'Start time')
         self.assertEqual('2017-09-04 21:20:00', self.db_results[4],
                          'End time')
-