Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/firecracker
Path: blob/main/tests/integration_tests/functional/test_net.py
1958 views
1
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
# SPDX-License-Identifier: Apache-2.0
3
"""Tests for the net device."""
4
import time
5
6
import framework.utils as utils
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
utils.run_cmd(
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
),
45
ignore_return_code=True
46
)
47
48
# Check if the high ingress traffic broke the net interface.
49
# If the net interface still works we should be able to execute
50
# ssh commands.
51
exit_code, _, _ = ssh_connection.execute_command('echo success\n')
52
assert exit_code == 0
53
54