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

New Test: add 4 tdx guest stress TCs #200

Merged
merged 1 commit into from
Mar 8, 2024
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
11 changes: 10 additions & 1 deletion tdx-guest/guest-tests
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,13 @@
# case info: [NA for upstream kernel yet] tdx guest kdump functional check with vcpu 128 sockets 1 and memory size 32 GB
./tdx-guest/tdx_kdump_test_entry.sh -v 128 -m 32 -r /abs/path/to/kdump_test/kenrel_rpm/kernel-x-version-under-test.rpm
# case info: [NA for upstream kernel yet] tdx guest kdump functional check with vcpu 128 sockets 1 and memory size 96 GB
./tdx-guest/tdx_kdump_test_entry.sh -v 128 -m 96 -r /abs/path/to/kdump_test/kenrel_rpm/kernel-x-version-under-test.rpm
./tdx-guest/tdx_kdump_test_entry.sh -v 128 -m 96 -r /abs/path/to/kdump_test/kenrel_rpm/kernel-x-version-under-test.rpm
# case implemented by tdx_stress_test.sh
# case info: In TDVM, stress test on memory with stress-ng memrate stressor under config of 1VCPU + 16G MEM + 8 stressors
./guest-test/guest.test_launcher.sh -v 1 -s 1 -m 16 -d on -t tdx -e tdx-guest -f tdx -x TD_STRESS_MEMRATE_1C_16G_8W -c "accept_memory=lazy" -p off
# case info: In TDVM, stress test on memory with stress-ng memrate stressor under config of 1VCPU + 96G MEM + 48 stressors
./guest-test/guest.test_launcher.sh -v 1 -s 1 -m 96 -d on -t tdx -e tdx-guest -f tdx -x TD_STRESS_MEMRATE_1C_96G_48W -c "accept_memory=lazy" -p off
# case info: In TDVM, stress test on memory with stress-ng network socket + iomix stressor under config of 1VCPU + 16G MEM + 8 stressors
./guest-test/guest.test_launcher.sh -v 1 -s 1 -m 16 -d on -t tdx -e tdx-guest -f tdx -x TD_STRESS_SOCK_IOMIX_1C_16G_8W -c "accept_memory=lazy" -p off
# case info: In TDVM, stress test on memory with stress-ng network socket + iomix stressor under config of 1VCPU + 96G MEM + 48 stressors
./guest-test/guest.test_launcher.sh -v 1 -s 1 -m 96 -d on -t tdx -e tdx-guest -f tdx -x TD_STRESS_SOCK_IOMIX_1C_96G_48W -c "accept_memory=lazy" -p off
32 changes: 32 additions & 0 deletions tdx-guest/tdx.guest_test_executor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,38 @@ case "$TESTCASE" in
guest_test_close
fi
;;
TD_STRESS_MEMRATE_1C_16G_8W)
guest_test_prepare tdx_stress_test.sh
guest_test_entry tdx_stress_test.sh "-t STRESS_MEMRATE -w 8" || \
die "Failed on $TESTCASE tdx_stress_test.sh -t STRESS_MEMRATE -w 8"
if [[ "$GCOV" == "off" ]]; then
guest_test_close
fi
;;
TD_STRESS_MEMRATE_1C_96G_48W)
guest_test_prepare tdx_stress_test.sh
guest_test_entry tdx_stress_test.sh "-t STRESS_MEMRATE -w 48" || \
die "Failed on $TESTCASE tdx_stress_test.sh -t STRESS_MEMRATE -w 48"
if [[ "$GCOV" == "off" ]]; then
guest_test_close
fi
;;
TD_STRESS_SOCK_IOMIX_1C_16G_8W)
guest_test_prepare tdx_stress_test.sh
guest_test_entry tdx_stress_test.sh "-t STRESS_SOCK_IOMIX -w 4" || \
die "Failed on $TESTCASE tdx_stress_test.sh -t STRESS_SOCK_IOMIX -w 4"
if [[ "$GCOV" == "off" ]]; then
guest_test_close
fi
;;
TD_STRESS_SOCK_IOMIX_1C_96G_48W)
guest_test_prepare tdx_stress_test.sh
guest_test_entry tdx_stress_test.sh "-t STRESS_SOCK_IOMIX -w 24" || \
die "Failed on $TESTCASE tdx_stress_test.sh -t STRESS_SOCK_IOMIX -w 24"
if [[ "$GCOV" == "off" ]]; then
guest_test_close
fi
;;
:)
test_print_err "Must specify the test scenario option by [-t]"
usage && exit 1
Expand Down
104 changes: 104 additions & 0 deletions tdx-guest/tdx_stress_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2024 Intel Corporation

# Author: Hongyu Ning <[email protected]>
#
# History: 5, Mar., 2024 - Hongyu Ning - creation


# @desc This script do multiple types of stress tests in TDX Guest VM

###################### Variables ######################
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
echo "$SCRIPT_DIR"
source common.sh

# general stress time set as 300 seconds
STRESS_TIME=300

while getopts :t:w: arg; do
case $arg in
t)
STRESS_CASE=$OPTARG
;;
w)
WORKERS=$OPTARG
;;
*)
test_print_err "Must supply an argument to -$OPTARG."
exit 1
;;
esac
done

###################### Functions ######################
# function based on stress-ng memrate stressor to stress
# mememory by read and write
stress_memrate() {
local stress_result
local pass_result
local fail_result
local skip_result
stress_result=$(stress-ng --memrate "$WORKERS" --memrate-bytes 1G --memrate-rd-mbs 1000 --memrate-wr-mbs 1000 -t "$STRESS_TIME")
pass_result=$(echo "$stress_result" | grep -oP '(?<=passed: )\d+')
fail_result=$(echo "$stress_result" | grep -oP '(?<=failed: )\d+')
skip_result=$(echo "$stress_result" | grep -oP '(?<=skipped: )\d+')
test_print_trc "stress-ng memrate stressor results:"
echo "$stress_result"
if [[ "$fail_result" -gt 0 ]]; then
die "stress-ng with memrate stressor failed $fail_result out of $WORKERS"
elif [[ "$skip_result" -gt 0 ]]; then
test_print_wrg "stress-ng with memrate stressor skipped $skip_result out of $WORKERS"
else
test_print_trc "stress-ng with memrate stressor passed $pass_result out of $WORKERS"
fi
}

# function based on stress-ng sock(et) and iomix stressors
# to stress socket handling and IO
stress_sock_iomix () {
local stress_result
local pass_result
local fail_result
local skip_result
stress_result=$(stress-ng --sock "$WORKERS" --iomix "$WORKERS" -t "$STRESS_TIME")
pass_result=$(echo "$stress_result" | grep -oP '(?<=passed: )\d+')
fail_result=$(echo "$stress_result" | grep -oP '(?<=failed: )\d+')
skip_result=$(echo "$stress_result" | grep -oP '(?<=skipped: )\d+')
test_print_trc "stress-ng sock + iomix stressor results:"
echo "$stress_result"
if [[ "$fail_result" -gt 0 ]]; then
die "stress-ng with sock + iomix stressor failed $fail_result out of $((WORKERS * 2))"
elif [[ "$skip_result" -gt 0 ]]; then
test_print_wrg "stress-ng with sock + iomix stressor skipped $skip_result out of $((WORKERS * 2))"
else
test_print_trc "stress-ng with sock + iomix stressor passed $pass_result out of $((WORKERS * 2))"
fi
}

###################### Do Works ######################
# prepare for stress prerequisites
if [ ! "$(which stress-ng)" ]; then
dnf install -y stress-ng > /dev/null
apt install -y stress-ng > /dev/null
else
test_print_trc "stress-ng prerequisites is ready for use"
fi

case "$STRESS_CASE" in
STRESS_MEMRATE)
stress_memrate
;;
STRESS_SOCK_IOMIX)
stress_sock_iomix
;;
:)
test_print_err "Must specify the memory case option by [-t]"
exit 1
;;
\?)
test_print_err "Input test case option $STRESS_CASE is not supported"
exit 1
;;
esac
Loading