Files
membank/auto-check/docker/stress-test/scripts/run.sh
12600k-rog-d4 b673ed62f9 docker
2026-08-24 00:35:30 +08:00

49 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 压力测试入口脚本(打包在镜像内)
# auto-check 启动容器时通过环境变量传参,执行完整测试流程:
# 系统信息 → 温度监控启动 → 各项压测(先单项、后综合)→ 温度监控收尾 → 内核日志
set -e
# 默认值docker -e 传入时覆盖)
export AUTOCHECK_TYPES="${AUTOCHECK_TYPES:-cpu,memory}"
export AUTOCHECK_DURATION="${AUTOCHECK_DURATION:-30}"
export AUTOCHECK_THREADS="${AUTOCHECK_THREADS:-4}"
export AUTOCHECK_MEM_SIZE_MB="${AUTOCHECK_MEM_SIZE_MB:-0}"
export AUTOCHECK_DISK_SIZE_MB="${AUTOCHECK_DISK_SIZE_MB:-1024}"
export AUTOCHECK_TEMP_INTERVAL="${AUTOCHECK_TEMP_INTERVAL:-10}"
export AUTOCHECK_SAMPLE_INTERVAL="${AUTOCHECK_SAMPLE_INTERVAL:-2}"
if [ -n "$AUTOCHECK_DISK_DIR" ]; then export AUTOCHECK_DISK_DIR; fi
# 1. 系统信息
source /scripts/sysinfo.sh
# 2. 温度监控(后台周期采样)
source /scripts/temp_start.sh
# 未知类型输出 skip保证报告完整
for T in $(echo "$AUTOCHECK_TYPES" | tr ',' ' '); do
case "$T" in
cpu|memory|disk|memnative|full) ;;
*)
echo "===TEST:$T==="
echo "status:skip"
echo "output:未知测试类型"
echo ""
;;
esac
done
# 3. 按固定顺序执行请求的测试(先单项、综合 full 最后)
REQ_TYPES=",${AUTOCHECK_TYPES// /},"
for TYPE in cpu memory disk memnative full; do
case "$REQ_TYPES" in
*",$TYPE,"*) source "/scripts/$TYPE.sh" ;;
esac
done
# 4. 温度监控收尾
source /scripts/temp_end.sh
# 5. 内核日志 + 结束标记
source /scripts/dmesg.sh