diff options
author | ahothan <ahothan@cisco.com> | 2018-11-17 09:43:19 -0800 |
---|---|---|
committer | ahothan <ahothan@cisco.com> | 2018-11-17 09:43:19 -0800 |
commit | 4988edf6afb74026db81677f25877b27b8fcfc05 (patch) | |
tree | 2802815fbb45ffe545331319c7e2e8fc8840254e | |
parent | 9527113c350f92b2293f596b6153f9c9d626f2af (diff) |
NFVBENCH-109 With EXT/No ARP/No vlan tagging, nfvbench still requires vlans to be set
Change-Id: Ie5ca9bb3ef546d47061ee54cef638aa419592ceb
Signed-off-by: ahothan <ahothan@cisco.com>
-rw-r--r-- | nfvbench/chaining.py | 22 | ||||
-rw-r--r-- | pylint.rc | 2 | ||||
-rw-r--r-- | test/test_chains.py | 30 |
3 files changed, 41 insertions, 13 deletions
diff --git a/nfvbench/chaining.py b/nfvbench/chaining.py index 5e2d730..8d717aa 100644 --- a/nfvbench/chaining.py +++ b/nfvbench/chaining.py @@ -823,16 +823,17 @@ class ChainManager(object): raise else: # no openstack, no need to create chains - # make sure there at least as many entries as chains in each left/right list - if len(config.vlans) != 2: - raise ChainException('The config vlans property must be a list ' - 'with 2 lists of VLAN IDs') - if not config.l2_loopback: - self._get_dest_macs_from_config() - re_vlan = "[0-9]*$" - self.vlans = [self._check_list('vlans[0]', config.vlans[0], re_vlan), - self._check_list('vlans[1]', config.vlans[1], re_vlan)] + if not config.l2_loopback and config.no_arp: + self._get_dest_macs_from_config() + if config.vlan_tagging: + # make sure there at least as many entries as chains in each left/right list + if len(config.vlans) != 2: + raise ChainException('The config vlans property must be a list ' + 'with 2 lists of VLAN IDs') + re_vlan = "[0-9]*$" + self.vlans = [self._check_list('vlans[0]', config.vlans[0], re_vlan), + self._check_list('vlans[1]', config.vlans[1], re_vlan)] def _get_dest_macs_from_config(self): re_mac = "[0-9a-fA-F]{2}([-:])[0-9a-fA-F]{2}(\\1[0-9a-fA-F]{2}){4}$" @@ -847,7 +848,8 @@ class ChainManager(object): if isinstance(ll, (int, str)): ll = [ll] if not ll or len(ll) < self.chain_count: - raise ChainException('%s=%s must be a list with 1 element per chain' % (list_name, ll)) + raise ChainException('%s=%s must be a list with %d elements per chain' % + (list_name, ll, self.chain_count)) for item in ll: if not re.match(pattern, str(item)): raise ChainException("Invalid format '{item}' specified in {fname}" @@ -384,6 +384,8 @@ max-statements=50 # Minimum number of public methods for a class (see R0903). min-public-methods=0 +[ELIF] +max-nested-blocks=6 [IMPORTS] diff --git a/test/test_chains.py b/test/test_chains.py index 36a29dd..109b73b 100644 --- a/test/test_chains.py +++ b/test/test_chains.py @@ -78,8 +78,28 @@ def test_chain_runner_ext_no_openstack(): config.vlans = [100, 200] config['traffic_generator']['mac_addrs_left'] = ['00:00:00:00:00:00'] config['traffic_generator']['mac_addrs_right'] = ['00:00:00:00:01:00'] - runner = ChainRunner(config, None, specs, BasicFactory()) - runner.close() + + for shared_net in [True, False]: + for no_arp in [False, True]: + for vlan_tag in [False, True]: + for scc in [1, 2]: + config = _get_chain_config(ChainType.EXT, scc, shared_net) + config.no_arp = no_arp + if no_arp: + # If EXT and no arp, the config must provide mac (1 pair per chain) + config['traffic_generator']['mac_addrs_left'] = ['00:00:00:00:00:00'] * scc + config['traffic_generator']['mac_addrs_right'] = ['00:00:00:00:01:00'] * scc + config['vlan_tagging'] = vlan_tag + if vlan_tag: + # these are the 2 valid forms of vlan ranges + if scc == 1: + config.vlans = [100, 200] + else: + config.vlans = [[port * 100 + index for index in range(scc)] + for port in range(2)] + runner = ChainRunner(config, None, specs, BasicFactory()) + runner.close() + def _mock_find_image(self, image_name): return True @@ -129,7 +149,11 @@ def _test_ext_chain(config, cred, mock_glance, mock_neutron, mock_client): runner.close() def test_ext_chain_runner(): - """Test openstack+EXT chain runner.""" + """Test openstack+EXT chain runner. + + Test 8 combinations of configs: + shared/not shared net x arp/no_arp x scc 1 or 2 + """ cred = MagicMock(spec=nfvbench.credentials.Credentials) for shared_net in [True, False]: for no_arp in [False, True]: |