Merge "Rebase to fuel 10.0 for fuel@opnfv D release"
[vswitchperf.git] / testcases / integration.py
1 # Copyright 2015-2016 Intel Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #   http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """IntegrationTestCase class
15 """
16
17 import logging
18
19 from collections import OrderedDict
20 from testcases import TestCase
21
22 class IntegrationTestCase(TestCase):
23     """IntegrationTestCase class
24     """
25
26     def __init__(self, cfg):
27         """ Testcase initialization
28         """
29         self._type = 'integration'
30         super(IntegrationTestCase, self).__init__(cfg)
31         self._logger = logging.getLogger(__name__)
32         # enforce check of step result for step driven testcases
33         self._step_check = True
34
35     def run_report(self):
36         """ Report test results
37         """
38         if self.test:
39             results = OrderedDict()
40             results['status'] = 'OK' if self._step_status['status'] else 'FAILED'
41             results['details'] = self._step_status['details']
42             TestCase.write_result_to_file([results], self._output_file)
43             self.step_report_status("Test '{}'".format(self.name), self._step_status['status'])
44             # inform vsperf about testcase failure
45             if not self._step_status['status']:
46                 raise Exception
47         else:
48             super(IntegrationTestCase, self).run_report()