8febe12d7d
真实本机 PG/ES/MinIO:v071 目录镜像 10 模式、结构引用/游标 15 模式、 8 表×2 外部范围身份矩阵、13 模式自然键(含软删除与合法同 parent 正例)、 备份期间三注入、收尾故障与授权撤销两个真实治理 PG 用例。 需隔离服务的用例在 test-scope.json 显式声明:普通 CI 跳过不算通过。
41 lines
929 B
Go
41 lines
929 B
Go
package librarysnapshot
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestArchiveOpenPersistsDirectoryEntriesAndPropagatesSyncFailure(t *testing.T) {
|
|
root := t.TempDir()
|
|
if err := os.Chmod(root, 0700); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
calls := 0
|
|
archive, err := openArchive(root, 1024*1024, func(r *os.Root) error { calls++; return syncRoot(r) })
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
archive.Close()
|
|
if calls != 2 {
|
|
t.Fatalf("root and root-parent durability missing: sync calls=%d", calls)
|
|
}
|
|
for _, failAt := range []int{1, 2} {
|
|
injected := errors.New("directory fsync failed")
|
|
n := 0
|
|
archive, err = openArchive(root, 1024*1024, func(r *os.Root) error {
|
|
n++
|
|
if n == failAt {
|
|
return injected
|
|
}
|
|
return syncRoot(r)
|
|
})
|
|
if !errors.Is(err, injected) || archive != nil {
|
|
if archive != nil {
|
|
archive.Close()
|
|
}
|
|
t.Fatal("directory fsync failure did not block archive publication", err)
|
|
}
|
|
}
|
|
}
|