-
Notifications
You must be signed in to change notification settings - Fork 181
Add case to support nic bonding test #6675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Automate VIRT-95958 nic bonding test Signed-off-by: Lei Yang <[email protected]>
WalkthroughThis pull request adds a new NIC bonding test for libvirt. It introduces a configuration file that defines test parameters for bonding with four NICs, including bonding module settings, timeouts, and directories, with Linux-specific DHCP command overrides. Additionally, a new Python test script implements NIC bonding failover testing by configuring bonding in a guest VM, performing data transfers between host and guest while randomly toggling network interfaces up and down, and verifying transfer integrity through MD5 checksums. The script includes proper cleanup of bonding and SSH configurations. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
libvirt/tests/cfg/virtual_network/qemu/nic_bonding.cfg (1)
18-20: Align DHCP client choice with guest distro and Python cleanup
dhcp_cmddefaults todhcpcd -n bond0, but RHEL variants override todhclient -r bond0 && dhclient bond0, while the Python test always cleans up viakill -9 \pgrep dhclient`. On non‑RHEL guests withoutdhcpcdthis will likely fail, and even on RHEL you may kill unrelateddhclient` instances.Consider either narrowing this test to RHEL only and using
dhclientconsistently, or adding per‑distro overrides (including for non‑RHEL Linux) and updating the cleanup innic_bonding.pyto target the actually used client (or to scope the kill to the bond0 instance only).libvirt/tests/src/virtual_network/qemu/nic_bonding.py (4)
31-34: Optionally validate discovered NICs against the expected countYou rely on
utils_net.get_linux_ifname(session_serial)to return the NICs to enslave, but the config explicitly expects four NICs (nics = "nic1 nic2 nic3 nic4"). To catch misconfigured guests early, you could comparelen(ifnames)to the expected count fromparams["nics"]and fail fast if they diverge.
55-58: Make guest_path construction robust to tmp_dir formatting
guest_path = os.path.join(tmp_dir + "dst-%s" % utils_misc.generate_random_string(8))relies ontmp_dirending with a trailing slash. With the current cfg (/var/tmp/) this is fine, but it becomes fragile if another cfg reuses this test withtmp_dir = "/var/tmp".You can make it robust and mirror the host side by using two arguments to
os.path.join:- guest_path = os.path.join(tmp_dir + "dst-%s" % utils_misc.generate_random_string(8)) + guest_path = os.path.join( + tmp_dir, "dst-%s" % utils_misc.generate_random_string(8) + )
60-61:shell=Truefor dd is low‑risk here but flagged by S604
process.run(dd_cmd % host_path, shell=True)is usingdd_cmdfrom controlled params andhost_pathfromtest.tmpdir, so from a security perspective this is effectively trusted input in a test harness. However, Ruff’s S604 warning will keep firing.If you want to silence S604, consider invoking
ddwithout a shell, building the argv list directly fromfilesizeandhost_path, or explicitly documenting that this usage is intentional and adding an ignore comment (e.g.# noqa: S604).
117-120: Cleanup of DHCP client is broad and assumesdhclient
session_serial.sendline("kill -9 \pgrep dhclient`")will kill everydhclientin the guest, not just the one you started forbond0, and it does nothing ifdhcpcd` (from the default cfg) is used instead. Because the VM is killed after the test this is mostly cosmetic, but it’s a bit heavy‑handed.If you want more precise cleanup, consider either:
- targeting only the bond0 client (e.g.
pkill -9 -f "dhclient.*bond0"), or- aligning with the
dhcp_cmdin the cfg and cleaning up the matching client type.This also ties into the DHCP alignment comment in
nic_bonding.cfg.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
libvirt/tests/cfg/virtual_network/qemu/nic_bonding.cfg(1 hunks)libvirt/tests/src/virtual_network/qemu/nic_bonding.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
libvirt/tests/src/virtual_network/qemu/nic_bonding.py (1)
libvirt/tests/src/virsh_cmd/domain/virsh_domfsfreeze_domfsthaw.py (1)
generate_random_string(104-113)
🪛 Ruff (0.14.5)
libvirt/tests/src/virtual_network/qemu/nic_bonding.py
60-60: Function call with shell=True parameter identified, security issue
(S604)
77-77: Standard pseudo-random generators are not suitable for cryptographic purposes
(S311)
79-79: Standard pseudo-random generators are not suitable for cryptographic purposes
(S311)
105-105: Standard pseudo-random generators are not suitable for cryptographic purposes
(S311)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Python 3.12
- GitHub Check: Python 3.9
- GitHub Check: Python 3.8
- GitHub Check: Python 3.11
🔇 Additional comments (1)
libvirt/tests/src/virtual_network/qemu/nic_bonding.py (1)
69-80: Use ofrandom.randintfor sleep intervals is acceptable; optionally silence S311The failover loops use
random.randintonly to vary sleep durations while toggling links, which is not a cryptographic use case. The Ruff S311 warnings on these lines can safely be ignored.If you want a clean lint run, add a localized
# noqa: S311on therandom.randintcalls instead of switching to a cryptographic RNG, which would add overhead without improving test quality.Also applies to: 94-107
Automate VIRT-95958 nic bonding test
ID:LIBVIRTAT-22160
Signed-off-by: Lei Yang [email protected]
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.