更新日志的中文说明

This commit is contained in:
wangjiming
2026-08-21 09:42:03 +08:00
parent 8455d99d49
commit 29d8a506cd
12 changed files with 1923 additions and 168 deletions

123
scripts/test_api.ps1 Normal file
View File

@@ -0,0 +1,123 @@
$ErrorActionPreference = "Continue"
$BaseUrl = "http://localhost:17861/modelTF"
$Token = "platform-token-u_admin.sess_665d17a01f05"
$Headers = @{ Authorization = "Bearer $Token" }
$results = @()
$passCount = 0
$failCount = 0
function Test-Api {
param(
[string]$Name,
[string]$Method = "GET",
[string]$Url,
[object]$Body = $null,
[string]$ContentType = "application/json"
)
try {
$params = @{
Uri = "$BaseUrl$Url"
Method = $Method
Headers = $Headers
ContentType = $ContentType
ErrorAction = "Stop"
}
if ($Body -and $Method -ne "GET") {
$params.Body = if ($Body -is [string]) { $Body } else { $Body | ConvertTo-Json -Depth 5 }
}
$resp = Invoke-RestMethod @params
$code = $resp.code
$msg = $resp.message
$dataLen = if ($resp.data) {
if ($resp.data -is [array]) { "$($resp.data.Count) items" }
elseif ($resp.data -is [string]) { "str(len=$($resp.data.Length))" }
else { "obj" }
} else { "null" }
$status = if ($code -eq 0) { "PASS" } else { "FAIL(code=$code)" }
if ($code -eq 0) { $script:passCount++ } else { $script:failCount++ }
$script:results += [PSCustomObject]@{
Module = ($Name -split '/')[0]
Name = $Name
Method = $Method
Url = $Url
Status = $status
Message = $msg
DataLen = $dataLen
}
}
catch {
$script:failCount++
$errMsg = $_.Exception.Message.Substring(0, [Math]::Min(120, $_.Exception.Message.Length))
$script:results += [PSCustomObject]@{
Module = ($Name -split '/')[0]
Name = $Name
Method = $Method
Url = $Url
Status = "ERROR"
Message = $errMsg
DataLen = "-"
}
}
}
# ==================== 1. 基础 ====================
Test-Api "基础/健康检查" -Url "/health"
Test-Api "基础/系统信息" -Url "/system-info"
Test-Api "基础/当前用户" -Url "/me"
Test-Api "基础/Dashboard总览" -Url "/dashboard/overview"
Test-Api "基础/Dashboard统计" -Url "/dashboard/stats"
# ==================== 2. 用户管理 ====================
Test-Api "用户管理/用户列表" -Url "/users"
Test-Api "用户管理/创建用户" -Method POST -Url "/users" -Body @{ username="test_user_$([DateTime]::Now.Ticks)"; password="Test1234!"; display_name="Test User"; role="viewer" }
Test-Api "用户管理/修改密码" -Method POST -Url "/users/me/password" -Body @{ old_password="admin123"; new_password="admin123" }
# ==================== 3. 模型管理 ====================
Test-Api "模型管理/模型列表" -Url "/model-manage"
Test-Api "模型管理/本地模型" -Url "/model-manage/local-models"
Test-Api "模型管理/训练产出模型" -Url "/model-manage/trained-models"
Test-Api "模型管理/导出任务" -Url "/model-manage/export-jobs"
Test-Api "模型管理/创建模型" -Method POST -Url "/model-manage" -Body @{ name="test_model_$([DateTime]::Now.Ticks)"; source="local"; model_path="/tmp/test"; description="test model" }
# ==================== 4. 数据集管理 ====================
Test-Api "数据集/数据集列表" -Url "/dataset-manage"
Test-Api "数据集/创建数据集" -Method POST -Url "/dataset-manage" -Body @{ name="test_dataset_$([DateTime]::Now.Ticks)"; description="test dataset" }
# ==================== 5. 模型训练 ====================
Test-Api "模型训练/训练任务列表" -Url "/fine-tune"
Test-Api "模型训练/名称检查" -Url "/fine-tune/check-name?name=test_task"
Test-Api "模型训练/预检" -Method POST -Url "/fine-tune/preflight" -Body @{ model_id="m_test"; dataset_id="ds_test"; epochs=1 }
# ==================== 6. 模型评测 ====================
Test-Api "模型评测/评测任务列表" -Url "/model-eval"
Test-Api "模型评测/评测维度列表" -Url "/dimension"
# ==================== 7. 模型推理/对比 ====================
Test-Api "模型推理/对比列表" -Url "/model-compare"
Test-Api "模型推理/本地状态" -Url "/model-chat/local/status"
# ==================== 8. 数据处理 ====================
Test-Api "数据处理/任务列表" -Url "/data-process"
Test-Api "数据处理/算力节点" -Url "/compute/nodes"
# ==================== 9. 算力节点 ====================
Test-Api "算力节点/GPU列表" -Url "/compute/gpus"
Test-Api "算力节点/任务队列" -Url "/compute/queue"
Test-Api "算力节点/同步任务" -Url "/compute/sync-jobs/sync_test"
# ==================== 10. 治理/审计 ====================
Test-Api "治理/操作日志" -Url "/log-files"
Test-Api "治理/训练日志" -Url "/training-log-files"
Test-Api "治理/Web日志" -Method POST -Url "/web-log" -Body @{ level="info"; message="test log entry" }
# ==================== 11. 数据转换 ====================
Test-Api "数据转换/任务列表" -Url "/data-convert"
# ==================== 输出结果 ====================
Write-Host ""
Write-Host "========== Test Summary =========="
Write-Host "PASS: $passCount FAIL: $failCount TOTAL: $($passCount + $failCount)"
Write-Host ""
$results | Format-Table -AutoSize -Property Module, Name, Method, Status, DataLen, Message | Out-String -Width 200