Add destination takeover config policy
This commit is contained in:
@@ -39,6 +39,9 @@ pipelines:
|
||||
if got, want := destination.State.Mode, StateModeSingleOwner; got != want {
|
||||
t.Fatalf("state mode default = %q, want %q", got, want)
|
||||
}
|
||||
if got, want := destination.Takeover.Mode, TakeoverModeSamePipeline; got != want {
|
||||
t.Fatalf("takeover mode default = %q, want %q", got, want)
|
||||
}
|
||||
if destination.Retention.Prune.Enabled {
|
||||
t.Fatal("retention.prune.enabled default = true, want false")
|
||||
}
|
||||
@@ -231,6 +234,50 @@ pipelines:
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadFileAcceptsExplicitTakeoverModes(t *testing.T) {
|
||||
cfg := loadConfig(t, `
|
||||
pipelines:
|
||||
- id: reports
|
||||
source:
|
||||
backend: local
|
||||
path: /source
|
||||
destinations:
|
||||
- id: same-pipeline
|
||||
backend: local
|
||||
path: /same-pipeline
|
||||
takeover:
|
||||
mode: same_pipeline
|
||||
- id: same-source
|
||||
backend: local
|
||||
path: /same-source
|
||||
takeover:
|
||||
mode: same_source
|
||||
- id: any-managed
|
||||
backend: local
|
||||
path: /any-managed
|
||||
takeover:
|
||||
mode: any_managed
|
||||
- id: never
|
||||
backend: local
|
||||
path: /never
|
||||
takeover:
|
||||
mode: never
|
||||
`)
|
||||
|
||||
destinations := cfg.Pipelines[0].Destinations
|
||||
wants := []string{
|
||||
TakeoverModeSamePipeline,
|
||||
TakeoverModeSameSource,
|
||||
TakeoverModeAnyManaged,
|
||||
TakeoverModeNever,
|
||||
}
|
||||
for index, want := range wants {
|
||||
if got := destinations[index].Takeover.Mode; got != want {
|
||||
t.Fatalf("destinations[%d].takeover.mode = %q, want %q", index, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadFileAcceptsRetentionPruneConfig(t *testing.T) {
|
||||
cfg := loadConfig(t, `
|
||||
pipelines:
|
||||
@@ -868,6 +915,38 @@ pipelines:
|
||||
`, "on_destination_older must be replace or fail")
|
||||
}
|
||||
|
||||
func TestLoadFileRejectsInvalidTakeoverMode(t *testing.T) {
|
||||
assertLoadError(t, `
|
||||
pipelines:
|
||||
- id: reports
|
||||
source:
|
||||
backend: local
|
||||
path: /source
|
||||
destinations:
|
||||
- id: archive
|
||||
backend: local
|
||||
path: /archive
|
||||
takeover:
|
||||
mode: unmanaged
|
||||
`, "takeover.mode must be same_pipeline, same_source, any_managed, or never")
|
||||
}
|
||||
|
||||
func TestLoadFileRejectsUnknownTakeoverFields(t *testing.T) {
|
||||
assertLoadError(t, `
|
||||
pipelines:
|
||||
- id: reports
|
||||
source:
|
||||
backend: local
|
||||
path: /source
|
||||
destinations:
|
||||
- id: archive
|
||||
backend: local
|
||||
path: /archive
|
||||
takeover:
|
||||
surprise: true
|
||||
`, "field surprise not found")
|
||||
}
|
||||
|
||||
func TestLoadFileRejectsInvalidValidationAction(t *testing.T) {
|
||||
assertLoadError(t, `
|
||||
pipelines:
|
||||
|
||||
Reference in New Issue
Block a user