diff options
author | 2022-05-24 14:36:36 +0200 | |
---|---|---|
committer | 2022-05-24 14:36:36 +0200 | |
commit | 91bcbc2e3ada7c034e0cca022a717871684dd5ca (patch) | |
tree | dca40addd6e613bba2cef090455fa08ca1330e4b /plugin/errors/setup_test.go | |
parent | b7e4f05f08e761fc71d7e7d2c85afd3ee6ef3542 (diff) | |
download | coredns-91bcbc2e3ada7c034e0cca022a717871684dd5ca.tar.gz coredns-91bcbc2e3ada7c034e0cca022a717871684dd5ca.tar.zst coredns-91bcbc2e3ada7c034e0cca022a717871684dd5ca.zip |
recover from panic log including stacktrace to help finding the origin (#5392)
Diffstat (limited to 'plugin/errors/setup_test.go')
-rw-r--r-- | plugin/errors/setup_test.go | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/plugin/errors/setup_test.go b/plugin/errors/setup_test.go index 72fdbcd0a..6af6aea57 100644 --- a/plugin/errors/setup_test.go +++ b/plugin/errors/setup_test.go @@ -7,55 +7,64 @@ import ( "testing" "github.com/coredns/caddy" + "github.com/coredns/coredns/core/dnsserver" clog "github.com/coredns/coredns/plugin/pkg/log" ) func TestErrorsParse(t *testing.T) { tests := []struct { - inputErrorsRules string - shouldErr bool - optCount int + inputErrorsRules string + shouldErr bool + optCount int + stacktrace bool }{ - {`errors`, false, 0}, - {`errors stdout`, false, 0}, - {`errors errors.txt`, true, 0}, - {`errors visible`, true, 0}, - {`errors { log visible }`, true, 0}, + {`errors`, false, 0, false}, + {`errors stdout`, false, 0, false}, + {`errors errors.txt`, true, 0, false}, + {`errors visible`, true, 0, false}, + {`errors { log visible }`, true, 0, false}, {`errors - errors `, true, 0}, - {`errors a b`, true, 0}, + errors `, true, 0, false}, + {`errors a b`, true, 0, false}, {`errors { consolidate - }`, true, 0}, + }`, true, 0, false}, {`errors { consolidate 1m - }`, true, 0}, + }`, true, 0, false}, {`errors { consolidate 1m .* extra - }`, true, 0}, + }`, true, 0, false}, {`errors { consolidate abc .* - }`, true, 0}, + }`, true, 0, false}, {`errors { consolidate 1 .* - }`, true, 0}, + }`, true, 0, false}, {`errors { consolidate 1m ()) - }`, true, 0}, + }`, true, 0, false}, + {`errors { + stacktrace + }`, false, 0, true}, {`errors { + stacktrace consolidate 1m ^exact$ - }`, false, 1}, + }`, false, 1, true}, + {`errors { + consolidate 1m ^exact$ + }`, false, 1, false}, {`errors { consolidate 1m error - }`, false, 1}, + }`, false, 1, false}, {`errors { consolidate 1m "format error" - }`, false, 1}, + }`, false, 1, false}, {`errors { consolidate 1m error1 consolidate 5s error2 - }`, false, 2}, + }`, false, 2, false}, } for i, test := range tests { c := caddy.NewTestController("dns", test.inputErrorsRules) @@ -69,6 +78,10 @@ func TestErrorsParse(t *testing.T) { t.Errorf("Test %d: pattern count mismatch, expected %d, got %d", i, test.optCount, len(h.patterns)) } + if dnsserver.GetConfig(c).Stacktrace != test.stacktrace { + t.Errorf("Test %d: stacktrace, expected %t, got %t", + i, test.stacktrace, dnsserver.GetConfig(c).Stacktrace) + } } } |