新增对象存储/账单/保留IP模块,删桶并发提速与成本增强
CI / test (push) Successful in 33s

This commit is contained in:
2026-07-21 12:11:05 +08:00
parent 9cfde8b702
commit f40f2a20e8
44 changed files with 7788 additions and 54 deletions
+30 -1
View File
@@ -16,7 +16,7 @@ func multiScopeClient() *fakeClient {
{Key: "AMS", Name: "eu-amsterdam-1", Status: "READY"},
},
compartments: []oci.Compartment{
{ID: "ocid1.compartment..a", Name: "instances", LifecycleState: "ACTIVE"},
{ID: "ocid1.compartment..a", Name: "instances", ParentID: "ocid1.tenancy..root", LifecycleState: "ACTIVE"},
},
}
}
@@ -154,6 +154,9 @@ func TestCachedCompartments(t *testing.T) {
if len(comps) != 1 || comps[0].ID != "ocid1.compartment..a" {
t.Errorf("comps = %+v, want 缓存中的 1 项", comps)
}
if comps[0].ParentID != "ocid1.tenancy..root" {
t.Errorf("ParentID = %q, want 缓存透传 parentId", comps[0].ParentID)
}
in := trialImportInput()
in.Alias = "未开启"
@@ -170,6 +173,32 @@ func TestCachedCompartments(t *testing.T) {
}
}
// TestCachedCompartmentsHealsLegacyRows 旧版缓存(未存 parentId)应实时刷新自愈并回写。
func TestCachedCompartmentsHealsLegacyRows(t *testing.T) {
client := multiScopeClient()
svc := newTestService(t, client)
cfg := importMultiConfig(t, svc)
// 模拟旧版残留:抹掉缓存行的 parentId
if err := svc.db.Model(&model.CompartmentCache{}).Where("oci_config_id = ?", cfg.ID).
Update("ParentOCID", "").Error; err != nil {
t.Fatalf("清空 parentId: %v", err)
}
comps, err := svc.CachedCompartments(context.Background(), cfg.ID)
if err != nil {
t.Fatalf("CachedCompartments: %v", err)
}
if len(comps) != 1 || comps[0].ParentID != "ocid1.tenancy..root" {
t.Errorf("comps = %+v, want 自愈刷新后带 parentId", comps)
}
var rows []model.CompartmentCache
svc.db.Where("oci_config_id = ?", cfg.ID).Find(&rows)
if len(rows) != 1 || rows[0].ParentOCID != "ocid1.tenancy..root" {
t.Errorf("cache rows = %+v, want 缓存已回写 parentId", rows)
}
}
func TestRegionSubscriptionsReconcilesCache(t *testing.T) {
client := multiScopeClient()
svc := newTestService(t, client)