diff --git a/.DS_Store b/.DS_Store index b1bc858..715c11d 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index e170af2..910f698 100644 --- a/.gitignore +++ b/.gitignore @@ -180,4 +180,7 @@ pyrightconfig.json nohup.out reports -conf/settings.local.yaml \ No newline at end of file +conf/settings.local.yaml + +CLAUDE.md +.claude diff --git a/Makefile b/Makefile index 7904fca..5bea8ff 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ timestamp := $(shell date +"%Y%m%d_%H%M%S") report_dir := $(if $(script),logs/$(script)/user_$(u)_loop_num_$(loop_num)_$(timestamp),) report_prefix := $(if $(report_dir),$(report_dir)/user_$(u)_loop_$(loop_num)_rdv_$(rendezvous_num)_$(timestamp),) -.PHONY: run clean stop +.PHONY: run clean stop mock-server examples test-data analyze-results help define LOCUST_ARGS $(if $(script),-f $(script),) --headless \ @@ -79,8 +79,101 @@ run-distributed-web: stop: @echo "正在停止所有 locust 进程..." - @./stop_locust.sh # 使用相对路径调用脚本 - @echo "所有 locust 进程已停止。" + @pkill -f "locust" || echo "没有找到运行中的locust进程" + @pkill -f "python.*mock_server" || echo "没有找到运行中的mock服务器" + @echo "所有 locust 和 mock 服务器进程已停止。" clean: @rm -rf logs/* # 清理所有日志目录下的文件 + +# 新增工具命令 + +# Mock服务器管理 +mock-server: + @echo "🚀 启动Mock HTTP服务器..." + @python scripts/start_mock_server.py + +mock-server-background: + @echo "🚀 后台启动Mock HTTP服务器..." + @nohup python scripts/start_mock_server.py > logs/mock_server.log 2>&1 & + @echo "Mock服务器已在后台启动,日志文件: logs/mock_server.log" + +# 示例运行 +examples: + @echo "📋 列出所有可用示例:" + @python scripts/run_examples.py --list + +run-example: + @echo "🧪 运行示例测试..." + @python scripts/run_examples.py $(if $(example),$(example),1) $(if $(web),--web,) $(if $(u),-u $(u),) $(if $(r),-r $(r),) $(if $(t),-t $(t),) + +run-example-web: + @echo "🌐 Web UI模式运行示例..." + @python scripts/run_examples.py $(if $(example),$(example),1) --web + +# 测试数据生成 +test-data: + @echo "🎲 生成测试数据..." + @python scripts/generate_test_data.py $(if $(type),--type $(type),) $(if $(count),--count $(count),) $(if $(format),--format $(format),) + +test-data-locust: + @echo "🎯 生成Locust专用测试数据..." + @python scripts/generate_test_data.py --type locust $(if $(count),--count $(count),) + +# 结果分析 +analyze-results: + @echo "📊 分析测试结果..." + @python scripts/analyze_results.py $(if $(results_dir),--results-dir $(results_dir),) $(if $(format),--format $(format),) --with-trends + +# 快速开始命令 +quick-start: + @echo "🚀 快速开始 - 启动Mock服务器和基础示例" + @echo "1. 启动Mock服务器..." + @python scripts/start_mock_server.py & + @sleep 3 + @echo "2. 运行基础示例..." + @python scripts/run_examples.py 1 --web + +# 完整测试流程 +full-test: + @echo "🔄 完整测试流程..." + @echo "1. 生成测试数据..." + @python scripts/generate_test_data.py --type locust --count 100 + @echo "2. 启动Mock服务器..." + @python scripts/start_mock_server.py & + @sleep 3 + @echo "3. 运行综合场景测试..." + @python scripts/run_examples.py 7 -u 10 -r 2 -t 30s + @echo "4. 分析结果..." + @python scripts/analyze_results.py --format both + +# 帮助信息 +help: + @echo "🔧 Locust框架 - 可用命令:" + @echo "" + @echo "📊 基础测试命令:" + @echo " make run script= u= r= t=