-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_test.ps1
More file actions
45 lines (40 loc) · 1.47 KB
/
load_test.ps1
File metadata and controls
45 lines (40 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# PowerShell 负载测试脚本
Write-Host "开始负载测试..." -ForegroundColor Green
# 测试车辆服务
Write-Host "测试车辆服务健康检查..." -ForegroundColor Yellow
for ($i = 1; $i -le 100; $i++) {
try {
$response = Invoke-WebRequest -Uri "http://localhost:3001/health" -UseBasicParsing -TimeoutSec 5
if ($i % 20 -eq 0) {
Write-Host "已发送 $i 个请求到车辆服务" -ForegroundColor Cyan
}
}
catch {
Write-Host "请求 $i 失败: $($_.Exception.Message)" -ForegroundColor Red
}
}
Write-Host "测试预订服务..." -ForegroundColor Yellow
for ($i = 1; $i -le 50; $i++) {
try {
$response = Invoke-WebRequest -Uri "http://localhost:3002/health" -UseBasicParsing -TimeoutSec 5
if ($i % 10 -eq 0) {
Write-Host "已发送 $i 个请求到预订服务" -ForegroundColor Cyan
}
}
catch {
Write-Host "请求 $i 失败: $($_.Exception.Message)" -ForegroundColor Red
}
}
Write-Host "测试通知服务..." -ForegroundColor Yellow
for ($i = 1; $i -le 30; $i++) {
try {
$response = Invoke-WebRequest -Uri "http://localhost:3003/health" -UseBasicParsing -TimeoutSec 5
if ($i % 10 -eq 0) {
Write-Host "已发送 $i 个请求到通知服务" -ForegroundColor Cyan
}
}
catch {
Write-Host "请求 $i 失败: $($_.Exception.Message)" -ForegroundColor Red
}
}
Write-Host "负载测试完成!" -ForegroundColor Green