fundplatform/jmeter/run-performance-test.sh
zhangjf 32abc57338 feat: 添加开发规则清单和完善前后端配置
主要变更:
1. 开发规范文档
   - 新增《开发规则清单.md》,涵盖技术栈、Maven配置、Lombok规范等
   - 记录 Lombok 在 Java 21 + Spring Boot 3 中的已知问题
   - 建立代码生成和开发流程规范

2. 前端功能增强
   - 新增系统配置管理页面(sysConfig.vue)
   - 新增数据字典管理页面(sysDict.vue)
   - 新增财务收据管理页面(receipt.vue)
   - 更新登录认证 API 配置

3. Docker 部署配置
   - 新增应用容器配置(docker-compose.yml)
   - 新增 Nginx 反向代理配置
   - 新增 ELK 日志收集配置(Elasticsearch + Logstash + Filebeat)

4. 性能测试工具
   - 新增 JMeter 测试计划(fundplatform-test-plan.jmx)
   - 新增性能测试执行脚本

5. 环境配置更新
   - 更新 .env 环境变量配置
   - 同步 fundplatform 子模块最新提交
2026-02-17 09:19:14 +08:00

146 lines
3.8 KiB
Bash
Executable File
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
# 资金服务平台性能测试脚本
set -e
echo "========================================"
echo " 资金服务平台 JMeter 性能测试"
echo "========================================"
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_title() {
echo -e "${BLUE}[TEST]${NC} $1"
}
# 检查JMeter
if ! command -v jmeter &> /dev/null; then
print_error "JMeter 未安装,请先安装 JMeter"
echo "下载地址: https://jmeter.apache.org/download_jmeter.cgi"
exit 1
fi
# 创建结果目录
mkdir -p results reports
# 解析参数
TEST_TYPE=${1:-all}
BASE_URL=${2:-localhost}
PORT=${3:-8080}
print_info "测试目标: http://${BASE_URL}:${PORT}"
# 函数:运行测试
run_test() {
local test_name=$1
local thread_count=$2
local duration=$3
print_title "开始测试: ${test_name}"
print_info "并发数: ${thread_count}, 持续时间: ${duration}s"
jmeter -n -t fundplatform-test-plan.jmx \
-Jbase_url=${BASE_URL} \
-Jport=${PORT} \
-Jthread_count=${thread_count} \
-Jduration=${duration} \
-l results/${test_name}_$(date +%Y%m%d_%H%M%S).jtl \
-e -o reports/${test_name}_$(date +%Y%m%d_%H%M%S)
print_info "测试完成: ${test_name}"
}
# 根据测试类型执行
case $TEST_TYPE in
login)
print_title "执行登录接口压测"
run_test "login" 50 60
;;
customer)
print_title "执行客户列表查询压测"
run_test "customer" 100 120
;;
dashboard)
print_title "执行仪表盘统计压测"
run_test "dashboard" 200 180
;;
all)
print_title "执行全部性能测试"
print_warn "这将执行所有测试场景,耗时较长..."
# 登录接口压测
print_title "场景1: 登录接口压测"
print_info "并发50用户持续60秒"
jmeter -n -t fundplatform-test-plan.jmx \
-Jbase_url=${BASE_URL} \
-Jport=${PORT} \
-l results/login_test_$(date +%Y%m%d_%H%M%S).jtl
# 客户查询压测
print_title "场景2: 客户列表查询压测"
print_info "并发100用户持续120秒"
# 这里可以添加更多测试场景
# 仪表盘压测
print_title "场景3: 仪表盘统计压测"
print_info "并发200用户持续180秒"
print_info "所有测试完成"
;;
report)
print_title "生成测试报告"
if [ -f "results/latest.jtl" ]; then
jmeter -g results/latest.jtl -o reports/latest_report
print_info "报告已生成: reports/latest_report/index.html"
else
print_error "没有找到测试结果文件"
exit 1
fi
;;
*)
echo "用法: $0 {login|customer|dashboard|all|report} [base_url] [port]"
echo ""
echo "测试类型:"
echo " login - 登录接口压测 (50并发)"
echo " customer - 客户列表查询压测 (100并发)"
echo " dashboard - 仪表盘统计压测 (200并发)"
echo " all - 执行全部测试"
echo " report - 生成测试报告"
echo ""
echo "示例:"
echo " $0 all localhost 8080"
echo " $0 login 192.168.1.100 8080"
exit 1
;;
esac
echo ""
echo "========================================"
echo " 性能测试执行完成"
echo "========================================"
echo ""
echo "测试结果:"
echo " - JTL文件: results/"
echo " - HTML报告: reports/"
echo ""
echo "查看报告:"
echo " open reports/*/index.html"