Skip to content

Commit ef32246

Browse files
committed
tests/limit - Add a test verifying we can reach the new VIF limit of 16
Currently the test verifies that interfaces have been created correctly (that there were enough grant frames to allocate all the queues), and simply prints performance metrics. This should be integrated with whatever database we are going to use for performance monitoring in the future. Signed-off-by: Andrii Sultanov <[email protected]>
1 parent d4efcc1 commit ef32246

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

tests/limits/__init__.py

Whitespace-only changes.

tests/limits/test_vif_limit.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import ipaddress
2+
import os
3+
import pytest
4+
import logging
5+
6+
# Requirements:
7+
# - one XCP-ng host (--host) >= 8.2
8+
# - a VM (--vm)
9+
10+
vif_limit = 16
11+
interface_name = "enX"
12+
vcpus = '8'
13+
14+
# There is a ResourceWarning due to background=True on an ssh call
15+
# We do ensure the processes are killed
16+
@pytest.mark.filterwarnings("ignore::ResourceWarning")
17+
@pytest.mark.debian_uefi_vm
18+
class TestVIFLimit:
19+
def test_vif_limit(self, host, imported_vm):
20+
vm = imported_vm
21+
if (vm.is_running()):
22+
logging.info("VM already running, shutting it down first")
23+
vm.shutdown(verify=True)
24+
25+
network_uuid = vm.vifs()[0].param_get('network-uuid')
26+
existing_vifs = len(vm.vifs())
27+
28+
logging.info('Give some more vCPUs (default is 1)')
29+
vm.param_set('VCPUs-max', vcpus)
30+
vm.param_set('VCPUs-at-startup', vcpus)
31+
32+
logging.info('Create VIFs before starting the VM')
33+
for i in range(existing_vifs, vif_limit):
34+
vm.create_vif(i, network_uuid=network_uuid)
35+
36+
vm.start()
37+
vm.wait_for_os_booted()
38+
39+
logging.info('Verify the interfaces exist in the guest')
40+
for i in range(0, vif_limit):
41+
if vm.ssh_with_result([f'test -d /sys/class/net/{interface_name}{i}']).returncode != 0:
42+
guest_error = vm.ssh_with_result(['dmesg | grep -B1 -A3 xen_netfront']).stdout
43+
logging.error("dmesg:\n%s", guest_error)
44+
assert False, "The interface does not exist in the guest, check dmesg output for errors"
45+
46+
logging.info('Configure interfaces')
47+
config = '\n'.join([f'iface {interface_name}{i} inet dhcp\n'
48+
f'auto {interface_name}{i}'
49+
for i in range(1, vif_limit)])
50+
vm.ssh([f'echo "{config}" >> /etc/network/interfaces'])
51+
52+
logging.info('Install iperf3 on VM and host')
53+
if vm.ssh_with_result(['apt install iperf3 --assume-yes']).returncode != 0:
54+
assert False, "Failed to install iperf3 on the VM"
55+
host.yum_install(['iperf3'])
56+
57+
logging.info('Reconfigure VM networking')
58+
if vm.ssh_with_result(['systemctl restart networking']).returncode != 0:
59+
assert False, "Failed to configure networking"
60+
61+
# Test iperf on all interfaces in parallel
62+
# Clean up on exceptions
63+
try:
64+
logging.info('Create separate iperf servers on the host')
65+
host_script = [f'iperf3 -s -p {5100+i} &'
66+
for i in range(0, vif_limit)]
67+
host_script = '\n'.join(host_script)
68+
host.ssh([f'echo "{host_script}" > host_script'])
69+
host.ssh(['nohup bash -c "bash host_script" < /dev/null &>/dev/null &'],
70+
background=True)
71+
72+
logging.info('Start multiple iperfs on separate interfaces on the VM')
73+
vm_script = [f'iperf3 --no-delay -c {host.hostname_or_ip} '
74+
f'-p {5100+i} --bind-dev {interface_name}{i} '
75+
f'--interval 0 --parallel 1 --time 30 &'
76+
for i in range(0, vif_limit)]
77+
vm_script = '\n'.join(vm_script)
78+
vm.ssh([f'echo "{vm_script}" > vm_script'])
79+
stdout = vm.ssh(['bash vm_script'])
80+
81+
# TODO: log this into some performance time series DB
82+
logging.info(stdout)
83+
finally:
84+
vm.ssh(['kill -9 `pgrep iperf3` || true'])
85+
host.ssh('killall iperf3')

0 commit comments

Comments
 (0)