test(library): 隔离数据契约与 r11 身份自然键矩阵
真实本机 PG/ES/MinIO:v071 目录镜像 10 模式、结构引用/游标 15 模式、 8 表×2 外部范围身份矩阵、13 模式自然键(含软删除与合法同 parent 正例)、 备份期间三注入、收尾故障与授权撤销两个真实治理 PG 用例。 需隔离服务的用例在 test-scope.json 显式声明:普通 CI 跳过不算通过。
This commit is contained in:
@@ -18,7 +18,8 @@ import (
|
||||
// 判据:换 operation_key ⇒ 新 operation(ID 不同、作业幂等键不同);
|
||||
// 同一个 operation_key ⇒ 同一 operation(重放)。
|
||||
func TestLibrarySyncNewIntentReExecutesInsteadOfReusingHistory(t *testing.T) {
|
||||
target := "snap-1"
|
||||
root := libraryFixtureRoot(t)
|
||||
target := sealSharedVersions(t, root, 1, 4)[0]
|
||||
digest, err := librarySyncParamsDigest("internal", target)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -36,14 +37,19 @@ func TestLibrarySyncNewIntentReExecutesInsteadOfReusingHistory(t *testing.T) {
|
||||
return store
|
||||
}
|
||||
config := func(store *fakeLibraryStore) Config {
|
||||
return Config{Store: store, ProductionReleaseRequestsEnabled: true, ProductionBackupRestoreVerified: true,
|
||||
c := Config{Store: store, LibraryArchiveRoot: root, ProductionReleaseRequestsEnabled: true, ProductionBackupRestoreVerified: true,
|
||||
LibraryProductionDatabaseURL: "postgres://prod.invalid/db", LibraryProductionInternalKB: "kb-int",
|
||||
LibraryCapacityBudgetBytes: 1 << 40}
|
||||
bindSourceFixture(t, &c, store, &target)
|
||||
return c
|
||||
}
|
||||
post := func(store *fakeLibraryStore, body string) *httptest.ResponseRecorder {
|
||||
c := config(store)
|
||||
id, _ := configuredLibrarySource(c, "internal").ID()
|
||||
body = sourceRequestBody(t, body, id)
|
||||
recorder := httptest.NewRecorder()
|
||||
librarySyncEnqueue(recorder, httptest.NewRequest(http.MethodPost, "/api/v1/library/syncs",
|
||||
strings.NewReader(body)), config(store))
|
||||
strings.NewReader(body)), c)
|
||||
return recorder
|
||||
}
|
||||
withKey := `{"scope":"internal","target_snapshot_id":"` + target + `","operation_key":"%s"}`
|
||||
@@ -85,7 +91,8 @@ func TestLibrarySyncNewIntentReExecutesInsteadOfReusingHistory(t *testing.T) {
|
||||
|
||||
// 同一个意图键配上不同快照 = 冲突,不能悄悄共享谱系。
|
||||
func TestLibrarySyncIntentKeyReusedWithAnotherSnapshotConflicts(t *testing.T) {
|
||||
target := "snap-1"
|
||||
root := libraryFixtureRoot(t)
|
||||
target := sealSharedVersions(t, root, 1, 4)[0]
|
||||
digest, _ := librarySyncParamsDigest("internal", target)
|
||||
now := time.Now().UTC()
|
||||
store := &fakeLibraryStore{current: &governance.LibraryVersion{ID: "ver-prod", Scope: "internal",
|
||||
@@ -101,7 +108,9 @@ func TestLibrarySyncIntentKeyReusedWithAnotherSnapshotConflicts(t *testing.T) {
|
||||
config := Config{Store: store, ProductionReleaseRequestsEnabled: true, ProductionBackupRestoreVerified: true,
|
||||
LibraryProductionDatabaseURL: "postgres://prod.invalid/db", LibraryProductionInternalKB: "kb-int",
|
||||
LibraryCapacityBudgetBytes: 1 << 40}
|
||||
body := `{"scope":"internal","target_snapshot_id":"` + target + `","operation_key":"intent-1"}`
|
||||
config.LibraryArchiveRoot = root
|
||||
sourceID := bindSourceFixture(t, &config, store, &target)
|
||||
body := sourceRequestBody(t, `{"scope":"internal","target_snapshot_id":"`+target+`","operation_key":"intent-1"}`, sourceID)
|
||||
recorder := httptest.NewRecorder()
|
||||
librarySyncEnqueue(recorder, httptest.NewRequest(http.MethodPost, "/api/v1/library/syncs", strings.NewReader(body)), config)
|
||||
if recorder.Code != http.StatusConflict {
|
||||
|
||||
Reference in New Issue
Block a user