Skip to content

Commit

Permalink
[guest-test] New Test: add TDVM guest network speed test
Browse files Browse the repository at this point in the history
to address potential network performance regression, add TDVM guest
network bandwidth test based on speedtest-cli

[Test Components] tdx
[Test Types] func
[Supported Devices] spr,emr,gnr,srf

Signed-off-by: Hongyu Ning <[email protected]>
  • Loading branch information
hongyuni authored and ysun committed Nov 16, 2023
1 parent e91e0c5 commit 2632e2a
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
8 changes: 8 additions & 0 deletions guest-test/guest.test_executor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ case "$TESTCASE" in
guest_test_close
fi
;;
TD_NET_SPEED)
guest_test_prepare tdx/tdx_speed_test.sh
guest_test_entry tdx_speed_test.sh || \
die "Failed on TD_NET_SPEED tdx_speed_test.sh"
if [[ $GCOV == "off" ]]; then
guest_test_close
fi
;;
:)
test_print_err "Must specify the test scenario option by [-t]"
usage && exit 1
Expand Down
72 changes: 72 additions & 0 deletions guest-test/tdx/tdx_speed_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2023 Intel Corporation

# Author: Hongyu Ning <[email protected]>
#
# History: 15, Nov., 2023 - Hongyu Ning - creation


# @desc This script do basic internet BW test in TDX Guest VM
# test tool based on speedtest-cli

###################### Variables ######################
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
echo "$SCRIPT_DIR"
source common.sh
ID=0
DOWNLOAD=0
DOWNLOAD_DATA=0
UPLOAD=0
UPLOAD_DATA=0

###################### Functions ######################
float_num_compare() {
if awk -v n1="$1" -v n2="1" 'BEGIN {if (n1>n2) exit 0; exit 1}'
then
return 0
else
return 1
fi
}

###################### Do Works ######################
# prepare speedtest-cli
if [ ! "$(which speedtest-cli)" ]; then
dnf install -y speedtest-cli > /dev/null
apt install -y speedtest-cli > /dev/null
else
test_print_trc "speedtest-cli prerequisites is ready for use"
test_print_trc "TDVM internet BW test is starting now..."
fi

# get nearest server ID for test
ID=$(speedtest-cli --list | awk -F')' 'NR==2 {print $1; exit}')
if [ "$ID" -gt 0 ]; then
test_print_trc "BW test server ID: $ID"
else
test_print_err "BW test get server failed"
exit 1
fi

# get download bandwidth
DOWNLOAD=$(speedtest-cli --single --bytes --simple --server "$ID" | awk -F':' 'NR==2 {print $2; exit}')
DOWNLOAD_DATA=$(echo "$DOWNLOAD" | awk '{print $1; exit}')
if float_num_compare "$DOWNLOAD_DATA"; then
test_print_trc "BW test download result: $DOWNLOAD"
else
test_print_trc "BW test download result: $DOWNLOAD"
test_print_err "BW test download test failed"
exit 1
fi

# get upload bandwidth
UPLOAD=$(speedtest-cli --single --bytes --simple --server "$ID" | awk -F':' 'NR==3 {print $2; exit}')
UPLOAD_DATA=$(echo "$UPLOAD" | awk '{print $1; exit}')
if float_num_compare "$UPLOAD_DATA"; then
test_print_trc "BW test upload result: $UPLOAD"
else
test_print_trc "BW test upload result: $UPLOAD"
test_print_err "BW test upload test failed"
exit 1
fi
6 changes: 5 additions & 1 deletion guest-test/tdx/tests
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ guest.test_launcher.sh -v 4 -s 2 -m 96 -d on -t tdx -x TD_BOOT -c "accept_memory
guest.test_launcher.sh -v 64 -s 8 -m 96 -d on -t tdx -x TD_BOOT -c "accept_memory=lazy" -p off
guest.test_launcher.sh -v 288 -s 1 -m 1 -d on -t tdx -x TD_BOOT -c "accept_memory=lazy" -p off
guest.test_launcher.sh -v 288 -s 8 -m 96 -d on -t tdx -x TD_BOOT -c "accept_memory=lazy" -p off
guest.test_launcher.sh -v 1 -s 1 -m 1 -d off -t tdx -x TD_BOOT -c "accept_memory=lazy" -p off
# case implemented by tdx_attest_check.sh
guest.test_launcher.sh -v 1 -s 1 -m 1 -d on -t tdx -x TD_ATTEST_VERIFY_REPORT -c "accept_memory=lazy" -p off
guest.test_launcher.sh -v 1 -s 1 -m 1 -d on -t tdx -x TD_ATTEST_VERITY_REPORTMAC -c "accept_memory=lazy" -p off
guest.test_launcher.sh -v 1 -s 1 -m 1 -d on -t tdx -x TD_ATTEST_VERIFY_RTMR_EXTEND -c "accept_memory=lazy" -p off
guest.test_launcher.sh -v 1 -s 1 -m 1 -d on -t tdx -x TD_ATTEST_VERIFY_QUOTE -c "accept_memory=lazy" -p off
guest.test_launcher.sh -v 1 -s 1 -m 1 -d on -t tdx -x TD_ATTEST_VERIFY_QUOTE -c "accept_memory=lazy" -p off
# case implemented by tdx_speed_test.sh
guest.test_launcher.sh -v 1 -s 1 -m 1 -d on -t tdx -x TD_NET_SPEED -c "accept_memory=lazy" -p off

0 comments on commit 2632e2a

Please sign in to comment.