From 3460fd9b5379b288b34c6e2c5984d2e9f67cc3bd Mon Sep 17 00:00:00 2001 From: Maryam Tahhan Date: Wed, 11 May 2016 10:21:59 +0100 Subject: testcase: execution time 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 Reviewed-by: Christian Trautman Reviewed-by: Martin Klozik Reviewed-by: Al Morton --- testcases/testcase.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'testcases') diff --git a/testcases/testcase.py b/testcases/testcase.py index 5b9ead69..1437aeae 100644 --- a/testcases/testcase.py +++ b/testcases/testcase.py @@ -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'] -- cgit 1.2.3-korg