testcase: execution time 09/13909/4
authorMaryam Tahhan <maryam.tahhan@intel.com>
Wed, 11 May 2016 09:21:59 +0000 (10:21 +0100)
committerMaryam Tahhan <maryam.tahhan@intel.com>
Wed, 11 May 2016 14:19:16 +0000 (15:19 +0100)
Measure the execution time for a testcase and add it to the log. We need
to report the test execution times for the testcases for OPNFV release
C. Modified the timing result in the csv + results file to display a
H:M:S format.

Change-Id: Ife9e361da5f8b3fc3721050ae3e6dce049f7402d
Signed-off-by: Maryam Tahhan <maryam.tahhan@intel.com>
Reviewed-by: Christian Trautman <ctrautma@redhat.com>
Reviewed-by: Martin Klozik <martinx.klozik@intel.com>
Reviewed-by: Al Morton <acmorton@att.com>
core/results/results_constants.py
testcases/testcase.py

index 1049e89..b7ab705 100644 (file)
@@ -59,6 +59,8 @@ class ResultsConstants(object):
     SCAL_STREAM_TYPE = 'match_type'
     SCAL_PRE_INSTALLED_FLOWS = 'pre-installed_flows'
 
+    TEST_RUN_TIME = "test_execution_time"
+
     @staticmethod
     def get_traffic_constants():
         """Method returns all Constants used to store results.
index 5b9ead6..1437aea 100644 (file)
@@ -45,6 +45,7 @@ class TestCase(object):
             values.
         :param results_dir: Where the csv formatted results are written.
         """
+        self._testcase_start_time = time.time()
         self._hugepages_mounted = False
         self._traffic_ctl = None
         self._vnf_ctl = None
@@ -56,6 +57,7 @@ class TestCase(object):
         self.guest_loopback = []
         self._settings_original = {}
         self._settings_paths_modified = False
+        self._testcast_run_time = None
 
         self._update_settings('VSWITCH', cfg.get('vSwitch', S.getValue('VSWITCH')))
         self._update_settings('VNF', cfg.get('VNF', S.getValue('VNF')))
@@ -284,6 +286,9 @@ class TestCase(object):
         # tear down test execution environment and log results
         self.run_finalize()
 
+        self._testcase_run_time = time.strftime("%H:%M:%S",
+                                  time.gmtime(time.time() - self._testcase_start_time))
+        logging.info("Testcase execution time: " + self._testcase_run_time)
         # report test results
         self.run_report()
 
@@ -313,6 +318,7 @@ class TestCase(object):
             item[ResultsConstants.ID] = self.name
             item[ResultsConstants.DEPLOYMENT] = self.deployment
             item[ResultsConstants.TRAFFIC_TYPE] = self._traffic['l3']['proto']
+            item[ResultsConstants.TEST_RUN_TIME] = self._testcase_run_time
             if self._traffic['multistream']:
                 item[ResultsConstants.SCAL_STREAM_COUNT] = self._traffic['multistream']
                 item[ResultsConstants.SCAL_STREAM_TYPE] = self._traffic['stream_type']