功能:完善云管助手与GPU故障恢复核对

This commit is contained in:
songyiming committed 2026-11-13 19:08:40 +08:00
1 parent b6026f9759
commit 9f7b01e4db
42 files changed
+3576 -120

No files matched your search

+31 -1
View File
@@ -97,7 +97,7 @@ func fakeCatalogPVE(t *testing.T, f *fixture, outcome string) *catalogPVE {
}
func registerCatalog(t *testing.T, f *fixture, admin string) (string, string) {
t.Helper()
status, out := f.request("POST", "/templates", admin, map[string]any{"name": "Ubuntu base", "version": "1.0", "os": "Ubuntu", "node": "node-a", "vmid": 8000}, "")
status, out := f.request("POST", "/templates", admin, map[string]any{"name": "Ubuntu base", "version": "1.0", "os": "Ubuntu", "node": "node-a", "vmid": 8000, "hardwareEncodingVerified": true}, "")
expect(t, 201, status, out)
tpl := out["id"].(string)
status, out = f.request("POST", "/pools", admin, map[string]any{"name": "Engineering", "type": "dedicated", "maxCount": 1, "templateId": tpl, "enabled": true}, "")
@@ -218,6 +218,36 @@ func TestClonePreflightAndCatalogRBAC(t *testing.T) {
status, out = f.request("POST", "/desktops/clone", admin, body, "disabled")
expect(t, 409, status, out)
}
func TestTemplateValidationRequiresHardwareReacceptanceAfterSourceChange(t *testing.T) {
f := newFixture(t)
p := fakeCatalogPVE(t, f, "success")
admin := f.login("admin")
tpl, _ := registerCatalog(t, f, admin)
status, out := f.request("POST", "/templates/"+tpl+"/validate", admin, nil, "")
expect(t, 200, status, out)
if out["hardwareEncodingVerified"] != true {
t.Fatal("unchanged template lost hardware encoding acceptance", out)
}
p.changed.Store(true)
status, out = f.request("POST", "/templates/"+tpl+"/validate", admin, nil, "")
expect(t, 200, status, out)
var digest string
if err := f.db.Get(&digest, "SELECT digest FROM image_templates WHERE id=$1", tpl); err != nil {
t.Fatal(err)
}
if out["hardwareEncodingVerified"] != false || digest != "v2" {
t.Fatal("changed template remained accepted", out)
}
status, out = f.request("POST", "/desktops/clone/check", admin, cloneBody(tpl, ""), "")
expect(t, 200, status, out)
if out["available"] != false {
t.Fatal("unverified changed template passed clone preflight", out)
}
}
func TestAmbiguousAndFailedCloneRetainPoolCapacity(t *testing.T) {
for _, outcome := range []string{"ambiguous", "failed"} {
t.Run(outcome, func(t *testing.T) {