Skip to content

Commit 5135356

Browse files
Serban Iorgadianpopa
Serban Iorga
authored andcommitted
add regression integration test for #1754
Validate that the RX queue won't freeze under high stateless ingress traffic when encountering bottlenecks on the tap. Signed-off-by: Serban Iorga <[email protected]>
1 parent 1ea6301 commit 5135356

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

tests/host_tools/network.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,16 @@ def netns(self):
320320
"""Return the network namespace of this tap."""
321321
return self._netns
322322

323+
def set_tx_queue_len(self, tx_queue_len):
324+
"""Set the length of the tap's TX queue."""
325+
utils.run_cmd(
326+
'ip netns exec {} ip link set {} txqueuelen {}'.format(
327+
self.netns,
328+
self.name,
329+
tx_queue_len
330+
)
331+
)
332+
323333
def __del__(self):
324334
"""Destructor doing tap interface clean up."""
325335
# pylint: disable=subprocess-run-check
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
"""Tests for the net device."""
4+
from subprocess import run, PIPE
5+
import time
6+
7+
import host_tools.network as net_tools
8+
9+
# The iperf version to run this tests with
10+
IPERF_BINARY = 'iperf3'
11+
12+
13+
def test_high_ingress_traffic(test_microvm_with_ssh, network_config):
14+
"""Run iperf rx with high UDP traffic."""
15+
test_microvm = test_microvm_with_ssh
16+
test_microvm.spawn()
17+
18+
test_microvm.basic_config()
19+
20+
# Create tap before configuring interface.
21+
tap, _host_ip, guest_ip = test_microvm.ssh_network_config(
22+
network_config,
23+
'1'
24+
)
25+
# Set the tap's tx queue len to 5. This increases the probability
26+
# of filling the tap under high ingress traffic.
27+
tap.set_tx_queue_len(5)
28+
29+
# Start the microvm.
30+
test_microvm.start()
31+
32+
# Start iperf3 server on the guest.
33+
ssh_connection = net_tools.SSHConnection(test_microvm.ssh_config)
34+
ssh_connection.execute_command('{} -sD\n'.format(IPERF_BINARY))
35+
time.sleep(1)
36+
37+
# Start iperf3 client on the host. Send 1Gbps UDP traffic.
38+
# If the net device breaks, iperf will freeze. We have to use a timeout.
39+
run(
40+
'timeout 30 {} {} -c {} -u -V -b 1000000000 -t 30'.format(
41+
test_microvm.jailer.netns_cmd_prefix(),
42+
IPERF_BINARY,
43+
guest_ip,
44+
), stdout=PIPE, shell=True, check=False
45+
)
46+
47+
# Check if the high ingress traffic broke the net interface.
48+
# If the net interface still works we should be able to execute
49+
# ssh commands.
50+
exit_code, _, _ = ssh_connection.execute_command('echo success\n')
51+
assert exit_code == 0

0 commit comments

Comments
 (0)