diff options
Diffstat (limited to 'testcases')
-rw-r--r-- | testcases/testcase.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/testcases/testcase.py b/testcases/testcase.py index 34861091..ebf1e797 100644 --- a/testcases/testcase.py +++ b/testcases/testcase.py @@ -36,6 +36,7 @@ from tools import functions from tools import namespace from tools import veth from tools.teststepstools import TestStepsTools +from tools.llc_management import rmd CHECK_PREFIX = 'validate_' @@ -78,6 +79,7 @@ class TestCase(object): self._step_result_mapping = {} self._step_status = None self._step_send_traffic = False # indication if send_traffic was called within test steps + self._vnf_list = [] self._testcase_run_time = None S.setValue('VSWITCH', cfg.get('vSwitch', S.getValue('VSWITCH'))) @@ -168,7 +170,7 @@ class TestCase(object): self._traffic['l3'] = S.getValue(self._tunnel_type.upper() + '_FRAME_L3') self._traffic['l4'] = S.getValue(self._tunnel_type.upper() + '_FRAME_L4') self._traffic['l2']['dstmac'] = S.getValue('NICS')[1]['mac'] - elif len(S.getValue('NICS')) and \ + elif len(S.getValue('NICS')) >= 2 and \ (S.getValue('NICS')[0]['type'] == 'vf' or S.getValue('NICS')[1]['type'] == 'vf'): mac1 = S.getValue('NICS')[0]['mac'] @@ -184,6 +186,10 @@ class TestCase(object): if step[0].startswith('vnf'): self._step_vnf_list[step[0]] = None + # if llc allocation is required, initialize it. + if S.getValue('LLC_ALLOCATION'): + self._rmd = rmd.CacheAllocator() + def run_initialize(self): """ Prepare test execution environment """ @@ -201,6 +207,8 @@ class TestCase(object): loader.get_vnf_class(), len(self._step_vnf_list)) + self._vnf_list = self._vnf_ctl.get_vnfs() + # verify enough hugepages are free to run the testcase if not self._check_for_enough_hugepages(): raise RuntimeError('Not enough hugepages free to run test.') @@ -254,6 +262,10 @@ class TestCase(object): self._step_status = {'status' : True, 'details' : ''} + # Perform LLC-allocations + if S.getValue('LLC_ALLOCATION'): + self._rmd.setup_llc_allocation() + self._logger.debug("Setup:") def run_finalize(self): @@ -262,6 +274,13 @@ class TestCase(object): # Stop all VNFs started by TestSteps in case that something went wrong self.step_stop_vnfs() + # Cleanup any LLC-allocations + if S.getValue('LLC_ALLOCATION'): + self._rmd.cleanup_llc_allocation() + + # Stop all processes executed by testcase + tasks.terminate_all_tasks(self._logger) + # umount hugepages if mounted self._umount_hugepages() @@ -792,10 +811,21 @@ class TestCase(object): # so it is not sent again after the execution of teststeps self._step_send_traffic = True elif step[0].startswith('vnf'): + # use vnf started within TestSteps if not self._step_vnf_list[step[0]]: # initialize new VM self._step_vnf_list[step[0]] = loader.get_vnf_class()() test_object = self._step_vnf_list[step[0]] + elif step[0].startswith('VNF'): + if step[1] in ('start', 'stop'): + raise RuntimeError("Cannot execute start() or stop() method of " + "VNF deployed automatically by scenario.") + # use vnf started by scenario deployment (e.g. pvp) + vnf_index = int(step[0][3:]) + try: + test_object = self._vnf_list[vnf_index] + except IndexError: + raise RuntimeError("VNF with index {} is not running.".format(vnf_index)) elif step[0] == 'wait': input(os.linesep + "Step {}: Press Enter to continue with " "the next step...".format(i) + os.linesep + os.linesep) |