Path: blob/main/tests/integration_tests/functional/test_net.py
1958 views
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.1# SPDX-License-Identifier: Apache-2.02"""Tests for the net device."""3import time45import framework.utils as utils6import host_tools.network as net_tools78# The iperf version to run this tests with9IPERF_BINARY = 'iperf3'101112def test_high_ingress_traffic(test_microvm_with_ssh, network_config):13"""Run iperf rx with high UDP traffic."""14test_microvm = test_microvm_with_ssh15test_microvm.spawn()1617test_microvm.basic_config()1819# Create tap before configuring interface.20tap, _host_ip, guest_ip = test_microvm.ssh_network_config(21network_config,22'1'23)24# Set the tap's tx queue len to 5. This increases the probability25# of filling the tap under high ingress traffic.26tap.set_tx_queue_len(5)2728# Start the microvm.29test_microvm.start()3031# Start iperf3 server on the guest.32ssh_connection = net_tools.SSHConnection(test_microvm.ssh_config)33ssh_connection.execute_command('{} -sD\n'.format(IPERF_BINARY))34time.sleep(1)3536# Start iperf3 client on the host. Send 1Gbps UDP traffic.37# If the net device breaks, iperf will freeze. We have to use a timeout.38utils.run_cmd(39'timeout 30 {} {} -c {} -u -V -b 1000000000 -t 30'.format(40test_microvm.jailer.netns_cmd_prefix(),41IPERF_BINARY,42guest_ip,43),44ignore_return_code=True45)4647# Check if the high ingress traffic broke the net interface.48# If the net interface still works we should be able to execute49# ssh commands.50exit_code, _, _ = ssh_connection.execute_command('echo success\n')51assert exit_code == 0525354