From a2d271b1d38f55b88ec7d0fca553535f0e4b0fd1 Mon Sep 17 00:00:00 2001 From: smj01095381 Date: Tue, 12 Sep 2023 18:37:25 +0800 Subject: [PATCH] set bandwidth for network stress test by iperf3 --- ancert.spec | 1 + tests/stress/network/network_stress.sh | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ancert.spec b/ancert.spec index 7e00ef0..6eda36a 100644 --- a/ancert.spec +++ b/ancert.spec @@ -18,6 +18,7 @@ Requires: fio, nvme-cli, glx-utils, python3, rpm-build, bc, lvm2 Requires: alsa-lib, alsa-utils, virt-what, smartmontools, hdparm Requires: xorg-x11-utils, xorg-x11-server-utils, xorg-x11-apps Requires: OpenIPMI, ipmitool, freeipmi +Requires: iproute, ethtool, iperf3, sysstat, stress-ng, expect %if %(rpm -E %{?dist}|awk '{sub(".an","");print}') >= 8 Requires: python3-pyyaml, clang %endif diff --git a/tests/stress/network/network_stress.sh b/tests/stress/network/network_stress.sh index 523666b..9a9a588 100644 --- a/tests/stress/network/network_stress.sh +++ b/tests/stress/network/network_stress.sh @@ -38,6 +38,14 @@ function check_iperf3_stress_results() { fi } +function get_nic_bandwidth() { + local cur_nic cur_nic_bandwidth + + cur_nic="$(ip a show|grep -w "$1"|awk '{print $NF}')" + [ -n "$cur_nic" ] && cur_nic_bandwidth="$(ethtool "$cur_nic"|grep Speed|awk -F ":|/s" '{print $2}'|grep -Ewo '[0-9]+[a-zA-Z]+')" + [ -n "$cur_nic_bandwidth" ] && IPERF3_TRANSMIT_RATE="$cur_nic_bandwidth" +} + function get_all_sut_ip() { #exclude ssh interface ip local sut_ip="" @@ -95,7 +103,8 @@ function run_iperf3_stress_test() { local sut_ip="" local cur_avail_lts_ip="" - check_cmd "iperf3" + for _cmd in iperf3 ethtool ip;do check_cmd "$_cmd";done + echo "Iperf3 stress test satrt......" [ -z "$LTS_IPADDRESS" ] && { echo "Error: LTS IP are required, but none are given";exit 1; } get_online_use_network_interface && sut_ip="$(ifconfig $ONLINE_NET_FACE|grep -w inet|awk '{print $2}')" @@ -134,6 +143,7 @@ function run_iperf3_stress_test() { for map_info in $MAP_SIP_LIP;do cur_sut_ip="$(echo $map_info|awk -F ";" '{print $1}')" cur_lts_ip="$(echo $map_info|awk -F ";" '{print $2}')" + get_nic_bandwidth "$cur_sut_ip" # Connection mode is TCP and UDP, The default is TCP connection if test X"$IPERF3_CONNECT_MODE" == X"TCP";then cmd="iperf3 -c $cur_lts_ip -t $IPERF3_RUNTIME -i $IPERF3_INTERVAL -l $IPERF3_TRANSMIT_SIZE -b $IPERF3_TRANSMIT_RATE -B $cur_sut_ip -P $IPERF3_PROCESS_NUM -p $IPERF3_PORT" @@ -151,6 +161,7 @@ function run_iperf3_stress_test() { echo "sut ssh interface to lts all avail interfaces." for lts_ip in $cur_avail_lts_ip;do if [ -n "$sut_ip" ];then + get_nic_bandwidth "$sut_ip" for s_ip in $sut_ip;do if test X"$IPERF3_CONNECT_MODE" == X"TCP";then cmd="iperf3 -c $lts_ip -t $IPERF3_RUNTIME -i $IPERF3_INTERVAL -l $IPERF3_TRANSMIT_SIZE -b $IPERF3_TRANSMIT_RATE -B $sut_ip -P $IPERF3_PROCESS_NUM -p $IPERF3_PORT" -- Gitee