plugin/errors: 'consolidate' option (#2192)
- see more details at https://github.com/infobloxopen/coredns-plugin-errors/pull/3
This commit is contained in:
parent
b0a89452ef
commit
7b25d18019
5 changed files with 582 additions and 24 deletions
|
@ -10,24 +10,60 @@ func TestErrorsParse(t *testing.T) {
|
|||
tests := []struct {
|
||||
inputErrorsRules string
|
||||
shouldErr bool
|
||||
optCount int
|
||||
}{
|
||||
{`errors`, false},
|
||||
{`errors stdout`, false},
|
||||
{`errors errors.txt`, true},
|
||||
{`errors visible`, true},
|
||||
{`errors { log visible }`, true},
|
||||
{`errors`, false, 0},
|
||||
{`errors stdout`, false, 0},
|
||||
{`errors errors.txt`, true, 0},
|
||||
{`errors visible`, true, 0},
|
||||
{`errors { log visible }`, true, 0},
|
||||
{`errors
|
||||
errors `, true},
|
||||
{`errors a b`, true},
|
||||
errors `, true, 0},
|
||||
{`errors a b`, true, 0},
|
||||
|
||||
{`errors {
|
||||
consolidate
|
||||
}`, true, 0},
|
||||
{`errors {
|
||||
consolidate 1m
|
||||
}`, true, 0},
|
||||
{`errors {
|
||||
consolidate 1m .* extra
|
||||
}`, true, 0},
|
||||
{`errors {
|
||||
consolidate abc .*
|
||||
}`, true, 0},
|
||||
{`errors {
|
||||
consolidate 1 .*
|
||||
}`, true, 0},
|
||||
{`errors {
|
||||
consolidate 1m ())
|
||||
}`, true, 0},
|
||||
{`errors {
|
||||
consolidate 1m ^exact$
|
||||
}`, false, 1},
|
||||
{`errors {
|
||||
consolidate 1m error
|
||||
}`, false, 1},
|
||||
{`errors {
|
||||
consolidate 1m "format error"
|
||||
}`, false, 1},
|
||||
{`errors {
|
||||
consolidate 1m error1
|
||||
consolidate 5s error2
|
||||
}`, false, 2},
|
||||
}
|
||||
for i, test := range tests {
|
||||
c := caddy.NewTestController("dns", test.inputErrorsRules)
|
||||
_, err := errorsParse(c)
|
||||
h, err := errorsParse(c)
|
||||
|
||||
if err == nil && test.shouldErr {
|
||||
t.Errorf("Test %d didn't error, but it should have", i)
|
||||
} else if err != nil && !test.shouldErr {
|
||||
t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err)
|
||||
} else if h != nil && len(h.patterns) != test.optCount {
|
||||
t.Errorf("Test %d: pattern count mismatch, expected %d, got %d",
|
||||
i, test.optCount, len(h.patterns))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue