上一提交只给 libraryctl 加了 -source-s3-endpoint,agent 却不知道这个 flag, systemd 起不来(exit 2)。端点属于"这台主机怎么访问这个源的存储",必须由 agent 自己钉住并随固定声明传给 libraryctl;请求仍然不能改。没配置时不凭空加 flag。 试过:make verify 15 项全绿;新增 agent 声明用例(有端点必传、无端点不多传)。
This commit is contained in:
@@ -336,3 +336,47 @@ func TestNewRejectsIncompleteConfiguration(t *testing.T) {
|
||||
t.Fatal("non-writer declaration without a reason accepted")
|
||||
}
|
||||
}
|
||||
|
||||
// 宿主机可达的源对象存储端点必须由 agent 自己钉住:请求不能改,也不能被悄悄丢掉
|
||||
// (掉了就会退回"容器里那个解析不到的服务名",真实封存报 read library resource)。
|
||||
func TestAgentPinsTheHostSideObjectEndpoint(t *testing.T) {
|
||||
config := Config{
|
||||
Socket: "/tmp/agent.sock",
|
||||
Binary: "/bin/echo",
|
||||
ArchiveRoot: "/tmp/library",
|
||||
JournalRoot: "/tmp/freeze",
|
||||
SourceApp: "app-container",
|
||||
SourcePG: "pg",
|
||||
SourceES: "es",
|
||||
SourceS3Endpoint: "http://127.0.0.1:19100",
|
||||
GovernancePG: "gov",
|
||||
Project: "proj",
|
||||
Writers: "app",
|
||||
NonWriters: "postgres=database store",
|
||||
MaxDuration: time.Minute,
|
||||
}
|
||||
agent, err := New(config)
|
||||
if err != nil {
|
||||
t.Fatalf("new: %v", err)
|
||||
}
|
||||
args := agent.config.declaration()
|
||||
found := false
|
||||
for i := 0; i+1 < len(args); i++ {
|
||||
if args[i] == "-source-s3-endpoint" && args[i+1] == "http://127.0.0.1:19100" {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("声明里没有宿主侧对象存储端点:%v", args)
|
||||
}
|
||||
config.SourceS3Endpoint = ""
|
||||
bare, err := New(config)
|
||||
if err != nil {
|
||||
t.Fatalf("new without endpoint: %v", err)
|
||||
}
|
||||
for _, arg := range bare.config.declaration() {
|
||||
if arg == "-source-s3-endpoint" {
|
||||
t.Fatal("没有端点时不该凭空多一个 flag")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user