Files
AIGC/demo/test-cleanup.ps1

61 lines
2.4 KiB
PowerShell
Raw Normal View History

# 任务清理功能测试脚本 (PowerShell版本)
Write-Host "=== 任务清理功能测试 ===" -ForegroundColor Green
# 1. 检查当前任务状态
Write-Host "`n1. 检查当前任务状态..." -ForegroundColor Yellow
try {
$response = Invoke-WebRequest -Uri "http://localhost:8080/api/diagnostic/queue-status" -Method GET
$status = $response.Content | ConvertFrom-Json
Write-Host "当前任务状态:" -ForegroundColor Cyan
$status | ConvertTo-Json -Depth 3
} catch {
Write-Host "获取任务状态失败: $($_.Exception.Message)" -ForegroundColor Red
}
# 2. 获取清理统计信息
Write-Host "`n2. 获取清理统计信息..." -ForegroundColor Yellow
try {
$response = Invoke-WebRequest -Uri "http://localhost:8080/api/cleanup/cleanup-stats" -Method GET
$stats = $response.Content | ConvertFrom-Json
Write-Host "清理统计信息:" -ForegroundColor Cyan
$stats | ConvertTo-Json -Depth 3
} catch {
Write-Host "获取清理统计失败: $($_.Exception.Message)" -ForegroundColor Red
}
# 3. 执行完整清理
Write-Host "`n3. 执行完整清理..." -ForegroundColor Yellow
try {
$response = Invoke-WebRequest -Uri "http://localhost:8080/api/cleanup/full-cleanup" -Method POST
$result = $response.Content | ConvertFrom-Json
Write-Host "清理结果:" -ForegroundColor Cyan
$result | ConvertTo-Json -Depth 3
} catch {
Write-Host "执行清理失败: $($_.Exception.Message)" -ForegroundColor Red
}
# 4. 再次检查任务状态
Write-Host "`n4. 清理后任务状态..." -ForegroundColor Yellow
try {
$response = Invoke-WebRequest -Uri "http://localhost:8080/api/diagnostic/queue-status" -Method GET
$status = $response.Content | ConvertFrom-Json
Write-Host "清理后任务状态:" -ForegroundColor Cyan
$status | ConvertTo-Json -Depth 3
} catch {
Write-Host "获取清理后状态失败: $($_.Exception.Message)" -ForegroundColor Red
}
# 5. 获取最终统计信息
Write-Host "`n5. 最终统计信息..." -ForegroundColor Yellow
try {
$response = Invoke-WebRequest -Uri "http://localhost:8080/api/cleanup/cleanup-stats" -Method GET
$stats = $response.Content | ConvertFrom-Json
Write-Host "最终统计信息:" -ForegroundColor Cyan
$stats | ConvertTo-Json -Depth 3
} catch {
Write-Host "获取最终统计失败: $($_.Exception.Message)" -ForegroundColor Red
}
Write-Host "`n=== 测试完成 ===" -ForegroundColor Green