mirror of
https://github.com/coredns/coredns.git
synced 2025-11-10 22:12:21 -05:00
Do not interrupt querying readiness probes for plugins (#6975)
* Do not interrupt querying readiness probes for plugins Signed-off-by: Gleb Kogtev <gleb.kogtev@gmail.com> * Add monitor param for ready plugin Signed-off-by: Gleb Kogtev <gleb.kogtev@gmail.com> * Update ready docs Signed-off-by: Gleb Kogtev <gleb.kogtev@gmail.com> * Update ready docs Signed-off-by: Gleb Kogtev <gleb.kogtev@gmail.com> --------- Signed-off-by: Gleb Kogtev <gleb.kogtev@gmail.com>
This commit is contained in:
@@ -8,18 +8,82 @@ import (
|
||||
|
||||
func TestSetupReady(t *testing.T) {
|
||||
tests := []struct {
|
||||
input string
|
||||
input string
|
||||
|
||||
expectedAddr string
|
||||
expectedMonitorType monitorType
|
||||
|
||||
shouldErr bool
|
||||
}{
|
||||
{`ready`, false},
|
||||
{`ready localhost:1234`, false},
|
||||
{`ready localhost:1234 b`, true},
|
||||
{`ready bla`, true},
|
||||
{`ready bla bla`, true},
|
||||
{
|
||||
input: `ready`,
|
||||
expectedAddr: ":8181",
|
||||
expectedMonitorType: monitorTypeUntilReady,
|
||||
shouldErr: false,
|
||||
},
|
||||
{
|
||||
input: `ready localhost:1234`,
|
||||
expectedAddr: "localhost:1234",
|
||||
expectedMonitorType: monitorTypeUntilReady,
|
||||
shouldErr: false,
|
||||
},
|
||||
{
|
||||
input: `
|
||||
ready {
|
||||
monitor until-ready
|
||||
}`,
|
||||
expectedAddr: ":8181",
|
||||
expectedMonitorType: monitorTypeUntilReady,
|
||||
shouldErr: false,
|
||||
},
|
||||
{
|
||||
input: `
|
||||
ready {
|
||||
monitor continuously
|
||||
}`,
|
||||
expectedAddr: ":8181",
|
||||
expectedMonitorType: monitorTypeContinuously,
|
||||
shouldErr: false,
|
||||
},
|
||||
{
|
||||
input: `
|
||||
ready localhost:1234 {
|
||||
monitor continuously
|
||||
}`,
|
||||
expectedAddr: "localhost:1234",
|
||||
expectedMonitorType: monitorTypeContinuously,
|
||||
shouldErr: false,
|
||||
},
|
||||
{
|
||||
input: `
|
||||
ready localhost:1234 {
|
||||
monitor 404
|
||||
}`,
|
||||
shouldErr: true,
|
||||
},
|
||||
{
|
||||
input: `ready localhost:1234 b`,
|
||||
shouldErr: true,
|
||||
},
|
||||
{
|
||||
input: `ready bla`,
|
||||
shouldErr: true,
|
||||
},
|
||||
{
|
||||
input: `ready bla bla`,
|
||||
shouldErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
_, err := parse(caddy.NewTestController("dns", test.input))
|
||||
actualAddress, actualMonitorType, err := parse(caddy.NewTestController("dns", test.input))
|
||||
|
||||
if actualAddress != test.expectedAddr {
|
||||
t.Errorf("Test %d: Expected address %s but found %s for input %s", i, test.expectedAddr, actualAddress, test.input)
|
||||
}
|
||||
if actualMonitorType != test.expectedMonitorType {
|
||||
t.Errorf("Test %d: Expected monitor type %s but found %s for input %s", i, test.expectedMonitorType, actualMonitorType, test.input)
|
||||
}
|
||||
|
||||
if test.shouldErr && err == nil {
|
||||
t.Errorf("Test %d: Expected error but found none for input %s", i, test.input)
|
||||
|
||||
Reference in New Issue
Block a user