From ee1c90650bf9f11ad86ef5e6d7282b21d05e12b1 Mon Sep 17 00:00:00 2001 From: Hongyu Ning Date: Thu, 7 Mar 2024 10:59:54 +0800 Subject: [PATCH] New Test: add 4 tdx guest stress TCs add 4 tdx guest stress TCs based on stress-ng for memory stress and network socket + iomix combined stress under difference TD VM configs [Test Components] tdx-guest [Test Types] stress [Supported Devices] spr,emr,gnr,srf Signed-off-by: Hongyu Ning --- tdx-guest/guest-tests | 11 ++- tdx-guest/tdx.guest_test_executor.sh | 32 +++++++++ tdx-guest/tdx_stress_test.sh | 104 +++++++++++++++++++++++++++ 3 files changed, 146 insertions(+), 1 deletion(-) create mode 100755 tdx-guest/tdx_stress_test.sh diff --git a/tdx-guest/guest-tests b/tdx-guest/guest-tests index 3eb3f52..8b98bb8 100644 --- a/tdx-guest/guest-tests +++ b/tdx-guest/guest-tests @@ -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 \ No newline at end of file +./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 diff --git a/tdx-guest/tdx.guest_test_executor.sh b/tdx-guest/tdx.guest_test_executor.sh index dcfbadf..0d3d0f9 100755 --- a/tdx-guest/tdx.guest_test_executor.sh +++ b/tdx-guest/tdx.guest_test_executor.sh @@ -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 diff --git a/tdx-guest/tdx_stress_test.sh b/tdx-guest/tdx_stress_test.sh new file mode 100755 index 0000000..e8b9c75 --- /dev/null +++ b/tdx-guest/tdx_stress_test.sh @@ -0,0 +1,104 @@ +#!/usr/bin/bash +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (c) 2024 Intel Corporation + +# Author: Hongyu Ning +# +# 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 \ No newline at end of file