Skip to content

dpdk-bond-mapping tests for DPDKTest bundle#1342

Draft
PanosKostopoulos wants to merge 1 commit into
openstack-charmers:masterfrom
PanosKostopoulos:master
Draft

dpdk-bond-mapping tests for DPDKTest bundle#1342
PanosKostopoulos wants to merge 1 commit into
openstack-charmers:masterfrom
PanosKostopoulos:master

Conversation

@PanosKostopoulos

Copy link
Copy Markdown

DPDK tests for dpdk-bond-mappings ovn-chassis config option. This first iteration includes only PCI addresses, but should include also MAC addresses (the difference is there should be an extra lookup to get the PCI addresses from the mac).

The tests have extended the test_enable_dpdk function, in this first iteration, to avoid a second setup for dpdk. This could be moved (and maybe should) in a seperate test function.

@PanosKostopoulos PanosKostopoulos changed the title first iteration pr dpdk-bond-mapping tests for DPDKTest bundle Apr 20, 2026
Comment thread zaza/openstack/charm_tests/ovn/tests.py Outdated
Comment on lines +584 to +587
logging.info(
'Verifying bond PCI addresses are whitelisted in dpdk-extra')
self._assert_dpdk_bond_pci_in_eal_args(bond_pci_addresses)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PCI address is put in EAL args regardless of the use of dpdk-bond-mappings configuration option.

How is this a valid assertion?

Comment thread zaza/openstack/charm_tests/ovn/tests.py Outdated
# self.disable_hugepages_vfio_on_hvs_in_vms()
# self._ovs_br_ex_port_is_system_interface()

def _test_dpdk_bond_mappings_pci_format(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a separate def test_XXX method instead of this covert piggy-backing on existing tests.

The charm code will only actually populate the OVS database with bond configuration when there are more than one interface [0], so you likely need to enable the test harness to add multiple ports to the test VM as well as interrogate the environment and ensure there are enough ports available to run the test.

0: https://github.com/openstack-charmers/charm-layer-ovn/blob/b0cee1d3b1bf7e7fc4236d9b2057419d3411771b/lib/charms/ovn_charm.py#L1324

Comment thread zaza/openstack/charm_tests/ovn/tests.py Outdated
"""
bond_pci_addresses = []
for unit in zaza.model.get_units(self.application_name):
pci = self._get_br_ex_dpdk_pci_address(unit)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basing input for your test assertion on data provided by the subject under test is not the safe thing to do, you should have the test code independently discover PCI addresses and/or MACs to use as input for the test so that you can accurately measure the output of the program.

Comment thread zaza/openstack/charm_tests/ovn/tests.py Outdated
logging.warning(
'Could not retrieve any PCI addresses for bond mapping test, '
'skipping')
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look safe, we'd likely want to know if this failed by having the test fail.

@PanosKostopoulos PanosKostopoulos force-pushed the master branch 17 times, most recently from 4019259 to 68c32da Compare April 28, 2026 07:36
Comment thread zaza/openstack/charm_tests/ovn/tests.py Outdated
logging.info('and is not in error.')
self._ovs_br_ex_interface_not_in_error()
instance_mac_map = self._add_second_interface()
self.bind_second_interface_to_dpdk(instance_mac_map)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensuring devices mentioned in the charm configuration are bound to a driver appropriate for use by DPDK is the responsibility of the charm.

The charm does this by updating /etc/dpdk/interfaces and restarting the dpdk service:

If this is not happening for you, I'd consider if configuration change is happening in the correct order or whether you have found an actual charm bug.

@PanosKostopoulos PanosKostopoulos force-pushed the master branch 10 times, most recently from 6ef7125 to 52af6db Compare April 29, 2026 10:51
@PanosKostopoulos PanosKostopoulos force-pushed the master branch 15 times, most recently from 4824e39 to a5869e1 Compare May 7, 2026 07:16
@PanosKostopoulos PanosKostopoulos force-pushed the master branch 5 times, most recently from 86c5c4f to f40eafe Compare May 11, 2026 12:07
Comment thread zaza/openstack/charm_tests/ovn/tests.py Outdated
Comment on lines +363 to +365
if not DPDKTest._hugepages_configured:
self.enable_hugepages_vfio_on_hvs_in_vms(4)
DPDKTest._hugepages_configured = True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use setUpClass / tearDownClass instead, which is designed for execution of once per class activities.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using setUpClass in the beginning since it was what we discussed. The issue is that enable_hugepages_vfio_on_hvs_in_vms is a self method, so in the setUpClass(cls) I do not have access to it. I could create a temp instance but I do not know if that is correct. Hence the use of SetUp(self). Am I missing something here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at enable_hugepages_vfio_on_hvs_in_vms, the only variables prefixed with self is model_name and test_config.

Both of these are already defined as class level variables in the parent setUpClass so they should be easily accessible.

Would passing cls as instance argument to the instance methods work directly perhaps?

Comment thread zaza/openstack/charm_tests/ovn/tests.py Outdated
Comment on lines +377 to +394
def _add_second_interface(self):
"""Add a second interface eth2 to networking charm units.

:returns: list of mac addresses(represented as strings).
"""

networking_data = openstack_utils.get_charm_networking_data()
ifname="eth2"
macs=[]
for instance in networking_data.unit_machine_ids:
openstack_utils.lxd_maybe_add_nic(instance, ifname,
"third")
macs.append(str(openstack_utils.lxd_get_nic_hwaddr(instance, ifname)))

if macs:
openstack_utils.configure_networking_charms(
networking_data, macs, use_juju_wait=False)
return macs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The act of adding an interface to test instances should be a deliberate action through configure / setup steps.

Either make zaza.openstack.charm_tests.neutron.setup.undercloud_and_charm_setup do what you want on the back of configuration influenced by environment variables, or add a new configure function for this purpose.

The use of the word second is also misleading as the instances likely already have two interfaces.

Comment thread zaza/openstack/charm_tests/ovn/tests.py Outdated
Comment on lines +631 to +638
if port_name == "dpdk-bond0":
if len(interfaces) == 2:
logging.info("DPDK bond was successfully created with 2 interfaces")
return
else:
logging.info("BOND FAILED")
raise Exception('Could not create DPDK bond with 2 interfaces')
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace this is one of the unittest assert methods: https://docs.python.org/3/library/unittest.html#assert-methods

@PanosKostopoulos PanosKostopoulos force-pushed the master branch 7 times, most recently from 2dd238c to 6c59083 Compare May 25, 2026 09:59
Adding tests for both mac and pci format of dpdk-bond-mappings config
option. Aslo adding a third interface to the chassis units, in order to
be able to create a bond.

Signed-off-by: Panos Kostopoulos Kyrimis <panos.kostopouloskyrimis@canonical.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants