Skip to content

Commit a7d2c8e

Browse files
committed
Fix Error 6502: use existing topology with device group instead of new topology
Per reviewer feedback, all IXIA ports on leaf0_dc1 already have topologies from create_topology_handles() — there are no unused ports. Use T1D5P3 which has a topology but no device groups: test_vxlan_dci.py (L3VNI_dci:8 and L3VNI_dci:9): - Pick last non-PortChannel port from topo_handles (e.g. T1D5P3) - Extract tg_handle, port_handle, topology_handle from topo_handles dict - Pass topology_handle to helper functions vxlan_helper.py (configure_ixia_bgp_ipv6/ipv4_session): - Re-add topology_handle parameter - When topology_handle provided: create device group on existing topology via tg_topology_config(), then add ethernet + IPv4 stacks via tg_interface_config(protocol_handle=...) — same pattern as create_device_groups() - When topology_handle is None: fallback to original tg_interface_config with port_handle (creates fresh topology)
1 parent 3a85039 commit a7d2c8e

File tree

2 files changed

+226
-130
lines changed

2 files changed

+226
-130
lines changed

spytest/tests/csco-tmp/test_vxlan_dci.py

Lines changed: 44 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5279,13 +5279,13 @@ def test_base_dci_l3vni_type5_ipv6_prefix_advertisement(self):
52795279
summ = ''
52805280

52815281
# --- Step 1: Get TGEN handles for leaf0_dc1 ---
5282-
# Use a dedicated IXIA port for BGP that does NOT already have a topology
5283-
# from create_topology_handles(). Ports in topo_handles already have IXIA
5284-
# topologies; calling tg_interface_config on them creates a duplicate and
5285-
# fails with Error 6502: Port already used.
5286-
# Following the bgp_ixia.txt pattern: use tgapi.get_handle_byname() on an
5287-
# unused port to get a fresh (tg_handle, port_handle) pair.
5288-
st.banner('Step 1: Get dedicated IXIA BGP port for leaf0_dc1')
5282+
# Use a port from topo_handles that already has a topology but NO device
5283+
# groups (e.g. T1D5P3). All ports already have topologies created by
5284+
# create_topology_handles(), so we cannot create a fresh topology (Error
5285+
# 6502). Instead we pick the last single (non-PortChannel) port, pass
5286+
# its existing topology_handle to the helper, and let the helper create
5287+
# a device group on it — following the create_device_groups() pattern.
5288+
st.banner('Step 1: Get IXIA BGP port for leaf0_dc1 (existing topology, no device groups)')
52895289
topo_handles = tgen_handles.get('topo_handles', {})
52905290

52915291
# Find leaf0_dc1 in topo_handles
@@ -5303,41 +5303,26 @@ def test_base_dci_l3vni_type5_ipv6_prefix_advertisement(self):
53035303

53045304
st.log('Using leaf node: {}'.format(leaf_node))
53055305

5306-
# Find a TGEN port NOT used by L2VNI traffic (no existing topology).
5307-
# Collect ports already consumed by create_topology_handles / l2vni_intf_dict.
5306+
# Pick a non-PortChannel port from topo_handles that has a topology but
5307+
# no device groups created on it (e.g. T1D5P3). Use the last single
5308+
# port in sorted order so we don't collide with the primary L2VNI port.
53085309
leaf_topo_ports = topo_handles.get(leaf_node, {})
5309-
used_ports = set(leaf_topo_ports.keys())
5310-
l2vni_intf = test_cfg.get('l2vni_intf_dict', {}).get(leaf_node, [])
5311-
for entry in l2vni_intf:
5312-
if isinstance(entry, dict):
5313-
for p in entry.get('ports', []):
5314-
used_ports.add(p)
5315-
else:
5316-
used_ports.add(entry)
5317-
5318-
# Enumerate all TGEN ports for this leaf from testbed vars
5319-
dut_id = vars.dut_ids.get(leaf_node, '')
5320-
all_tgen_ports = sorted(
5321-
[k for k, v in vars.items()
5322-
if isinstance(k, str) and k.startswith('T1' + dut_id + 'P')])
5323-
st.log('All TGEN ports for {}: {}'.format(leaf_node, all_tgen_ports))
5324-
st.log('Ports already used by L2VNI topologies: {}'.format(used_ports))
5325-
5326-
bgp_port_name = None
5327-
for p in all_tgen_ports:
5328-
if p not in used_ports:
5329-
bgp_port_name = p
5330-
break
5310+
single_ports = sorted(
5311+
[k for k in leaf_topo_ports if 'portchannel' not in k.lower()])
5312+
st.log('Available single TGEN ports for {}: {}'.format(leaf_node, single_ports))
53315313

5332-
if not bgp_port_name:
5333-
summ += 'No unused TGEN port available for BGP on {}\n'.format(leaf_node)
5314+
if not single_ports:
5315+
summ += 'No single TGEN port available for BGP on {}\n'.format(leaf_node)
53345316
report_result(False, tc_id, summ)
53355317
return
53365318

5337-
st.log('Using dedicated BGP port: {} (not used by traffic topologies)'.format(
5338-
bgp_port_name))
5339-
tg_handle, port_handle = tgapi.get_handle_byname(bgp_port_name)
5340-
st.log('BGP port_handle: {}'.format(port_handle))
5319+
bgp_port_name = single_ports[-1] # last port, e.g. T1D5P3
5320+
port_info = leaf_topo_ports[bgp_port_name]
5321+
tg_handle = port_info['tg_handle']
5322+
port_handle = port_info['port_handle']
5323+
topo_handle = port_info.get('topology_handle')
5324+
st.log('Using BGP port: {} (topology_handle={})'.format(
5325+
bgp_port_name, topo_handle))
53415326

53425327
# --- Step 2: Get leaf ASN from BGP underlay info ---
53435328
st.banner('Step 2: Get leaf ASN and configure IXIA BGP session')
@@ -5385,12 +5370,13 @@ def test_base_dci_l3vni_type5_ipv6_prefix_advertisement(self):
53855370
ixia_ip=ixia_ip, vrf_name='Vrf101')
53865371

53875372
# --- Step 3b: Configure IXIA BGP session and advertise IPv6 prefixes ---
5388-
# Using a dedicated unused port avoids Error 6502 (no existing topology)
5389-
# and ValueError (tg_interface_config creates a fresh registered topology).
5373+
# Pass the existing topology_handle so the helper creates a device group
5374+
# on the existing topology instead of creating a new one (Error 6502).
53905375
st.banner('Step 3b: Configure IXIA BGP session per bgp_ixia.txt pattern')
53915376
ixia_result = vxlan_obj.configure_ixia_bgp_ipv6_session(
53925377
tg_handle=tg_handle,
53935378
port_handle=port_handle,
5379+
topology_handle=topo_handle,
53945380
ixia_ip=ixia_ip,
53955381
gateway=ixia_gateway,
53965382
netmask=ixia_netmask,
@@ -5488,9 +5474,9 @@ def test_base_dci_l3vni_type5_ipv4_prefix_advertisement(self):
54885474
summ = ''
54895475

54905476
# --- Step 1: Get TGEN handles for leaf0_dc1 ---
5491-
# Use a dedicated IXIA port for BGP (same approach as IPv6 test case).
5492-
# See L3VNI_dci:8 for detailed explanation of Error 6502 fix.
5493-
st.banner('Step 1: Get dedicated IXIA BGP port for leaf0_dc1')
5477+
# Same approach as L3VNI_dci:8: use a port with an existing topology but
5478+
# no device groups (e.g. T1D5P3). Pass topology_handle to helper.
5479+
st.banner('Step 1: Get IXIA BGP port for leaf0_dc1 (existing topology, no device groups)')
54945480
topo_handles = tgen_handles.get('topo_handles', {})
54955481

54965482
# Find leaf0_dc1 in topo_handles
@@ -5508,39 +5494,24 @@ def test_base_dci_l3vni_type5_ipv4_prefix_advertisement(self):
55085494

55095495
st.log('Using leaf node: {}'.format(leaf_node))
55105496

5511-
# Find a TGEN port NOT used by L2VNI traffic (no existing topology).
5497+
# Pick the last non-PortChannel port from topo_handles (has topology, no device groups)
55125498
leaf_topo_ports = topo_handles.get(leaf_node, {})
5513-
used_ports = set(leaf_topo_ports.keys())
5514-
l2vni_intf = test_cfg.get('l2vni_intf_dict', {}).get(leaf_node, [])
5515-
for entry in l2vni_intf:
5516-
if isinstance(entry, dict):
5517-
for p in entry.get('ports', []):
5518-
used_ports.add(p)
5519-
else:
5520-
used_ports.add(entry)
5521-
5522-
dut_id = vars.dut_ids.get(leaf_node, '')
5523-
all_tgen_ports = sorted(
5524-
[k for k, v in vars.items()
5525-
if isinstance(k, str) and k.startswith('T1' + dut_id + 'P')])
5526-
st.log('All TGEN ports for {}: {}'.format(leaf_node, all_tgen_ports))
5527-
st.log('Ports already used by L2VNI topologies: {}'.format(used_ports))
5528-
5529-
bgp_port_name = None
5530-
for p in all_tgen_ports:
5531-
if p not in used_ports:
5532-
bgp_port_name = p
5533-
break
5499+
single_ports = sorted(
5500+
[k for k in leaf_topo_ports if 'portchannel' not in k.lower()])
5501+
st.log('Available single TGEN ports for {}: {}'.format(leaf_node, single_ports))
55345502

5535-
if not bgp_port_name:
5536-
summ += 'No unused TGEN port available for BGP on {}\n'.format(leaf_node)
5503+
if not single_ports:
5504+
summ += 'No single TGEN port available for BGP on {}\n'.format(leaf_node)
55375505
report_result(False, tc_id, summ)
55385506
return
55395507

5540-
st.log('Using dedicated BGP port: {} (not used by traffic topologies)'.format(
5541-
bgp_port_name))
5542-
tg_handle, port_handle = tgapi.get_handle_byname(bgp_port_name)
5543-
st.log('BGP port_handle: {}'.format(port_handle))
5508+
bgp_port_name = single_ports[-1] # last port, e.g. T1D5P3
5509+
port_info = leaf_topo_ports[bgp_port_name]
5510+
tg_handle = port_info['tg_handle']
5511+
port_handle = port_info['port_handle']
5512+
topo_handle = port_info.get('topology_handle')
5513+
st.log('Using BGP port: {} (topology_handle={})'.format(
5514+
bgp_port_name, topo_handle))
55445515

55455516
# --- Step 2: Get leaf ASN from BGP underlay info ---
55465517
st.banner('Step 2: Get leaf ASN and configure IXIA BGP session')
@@ -5588,12 +5559,13 @@ def test_base_dci_l3vni_type5_ipv4_prefix_advertisement(self):
55885559
ixia_ip=ixia_ip, vrf_name='Vrf101')
55895560

55905561
# --- Step 3b: Configure IXIA BGP session and advertise IPv4 prefixes ---
5591-
# Using a dedicated unused port avoids Error 6502 (no existing topology)
5592-
# and ValueError (tg_interface_config creates a fresh registered topology).
5562+
# Pass the existing topology_handle so the helper creates a device group
5563+
# on the existing topology instead of creating a new one (Error 6502).
55935564
st.banner('Step 3b: Configure IXIA BGP session per bgp_ixia.txt pattern')
55945565
ixia_result = vxlan_obj.configure_ixia_bgp_ipv4_session(
55955566
tg_handle=tg_handle,
55965567
port_handle=port_handle,
5568+
topology_handle=topo_handle,
55975569
ixia_ip=ixia_ip,
55985570
gateway=ixia_gateway,
55995571
netmask=ixia_netmask,

0 commit comments

Comments
 (0)