Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve on osv_sanity common.json and add new TC of guest speed test #134

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 1 addition & 3 deletions guest-test/osv_sanity/common.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"kernel_img": "/boot/vmlinuz-xxx-yyy",
"initrd_img": "/boot/initramfs-xxx-yyy",
"bios_img": "/path/to/EDKII/OVMF.fd or other virtual BIOS",
"qemu_img": "/path/to/qemu-kvm with proper capabilty of VM test",
"guest_img": "/path/to/prepared/guest_os_image, in qcow2 or raw image format",
"guest_img_format": "raw",
"guest_img_format": "raw or qcow2",
"boot_pattern": "*Kernel*on*an*x86_64*",
"guest_root_passwd": "123456"
}
10 changes: 8 additions & 2 deletions guest-test/qemu_get_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@
qemu_config = json.loads(raw_config)

# pre-config G-list variables' values confirmed by common.json
kernel_img = image_config["kernel_img"]
initrd_img = image_config["initrd_img"]
if os.path.isfile(image_config["kernel_img"]):
kernel_img = image_config["kernel_img"]
else:
kernel_img = "not_use"
if os.path.isfile(image_config["initrd_img"]):
initrd_img = image_config["initrd_img"]
else:
initrd_img = "not_use"
bios_img = image_config["bios_img"]
qemu_img = image_config["qemu_img"]
guest_img = image_config["guest_img"]
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