Fully deprecate TIMEOUT and NO_RELOAD (#2742)

* Fully deprecate NO_RELOAD

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Fully deprecate TIMEOUT

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Update CI tests to adapt to the deprecation of TIMEOUT

Signed-off-by: Xiao An <hac@zju.edu.cn>

* Add documents for directive transfer in plugin auto

Signed-off-by: Xiao An <hac@zju.edu.cn>
This commit is contained in:
Xiao An 2019-04-01 14:28:01 +08:00 committed by Miek Gieben
parent 99c3d065bc
commit cb96ab9f4f
9 changed files with 75 additions and 105 deletions

View file

@ -15,7 +15,6 @@ func TestAutoParse(t *testing.T) {
expectedTempl string
expectedRe string
expectedReloadInterval time.Duration
expectedDuration time.Duration
expectedTo []string
}{
{
@ -23,46 +22,33 @@ func TestAutoParse(t *testing.T) {
directory /tmp
transfer to 127.0.0.1
}`,
false, "/tmp", "${1}", `db\.(.*)`, 60 * time.Second, 60 * time.Second, []string{"127.0.0.1:53"},
false, "/tmp", "${1}", `db\.(.*)`, 60 * time.Second, []string{"127.0.0.1:53"},
},
{
`auto 10.0.0.0/24 {
directory /tmp
}`,
false, "/tmp", "${1}", `db\.(.*)`, 60 * time.Second, 60 * time.Second, nil,
false, "/tmp", "${1}", `db\.(.*)`, 60 * time.Second, nil,
},
{
`auto {
directory /tmp
no_reload
reload 0
}`,
false, "/tmp", "${1}", `db\.(.*)`, 0 * time.Second, 0 * time.Second, nil,
false, "/tmp", "${1}", `db\.(.*)`, 0 * time.Second, nil,
},
{
`auto {
directory /tmp (.*) bliep
}`,
false, "/tmp", "bliep", `(.*)`, 60 * time.Second, 60 * time.Second, nil,
},
{
`auto {
directory /tmp (.*) bliep 10
}`,
false, "/tmp", "bliep", `(.*)`, 10 * time.Second, 10 * time.Second, nil,
false, "/tmp", "bliep", `(.*)`, 60 * time.Second, nil,
},
{
`auto {
directory /tmp (.*) bliep
reload 10s
}`,
false, "/tmp", "bliep", `(.*)`, 10 * time.Second, 10 * time.Second, nil,
},
{
`auto {
directory /tmp (.*) bliep 20
reload 10s
}`,
false, "/tmp", "bliep", `(.*)`, 10 * time.Second, 20 * time.Second, nil,
false, "/tmp", "bliep", `(.*)`, 10 * time.Second, nil,
},
{
`auto {
@ -71,44 +57,44 @@ func TestAutoParse(t *testing.T) {
transfer to 127.0.0.2
upstream 8.8.8.8
}`,
false, "/tmp", "bliep", `(.*)`, 60 * time.Second, 60 * time.Second, []string{"127.0.0.1:53", "127.0.0.2:53"},
false, "/tmp", "bliep", `(.*)`, 60 * time.Second, []string{"127.0.0.1:53", "127.0.0.2:53"},
},
// errors
// NO_RELOAD has been deprecated.
{
`auto {
directory /tmp
no_reload
}`,
true, "/tmp", "${1}", `db\.(.*)`, 0 * time.Second, nil,
},
// TIMEOUT has been deprecated.
{
`auto {
directory /tmp (.*) bliep 10
}`,
true, "/tmp", "bliep", `(.*)`, 10 * time.Second, nil,
},
// no directory specified.
{
`auto example.org {
directory
}`,
true, "", "${1}", `db\.(.*)`, 60 * time.Second, 60 * time.Second, nil,
true, "", "${1}", `db\.(.*)`, 60 * time.Second, nil,
},
// illegal REGEXP.
{
`auto example.org {
directory /tmp * {1}
}`,
true, "", "${1}", ``, 60 * time.Second, 60 * time.Second, nil,
true, "/tmp", "${1}", ``, 60 * time.Second, nil,
},
// unexpected argument.
{
`auto example.org {
directory /tmp * {1} aa
directory /tmp (.*) {1} aa
}`,
true, "", "${1}", ``, 60 * time.Second, 60 * time.Second, nil,
},
{
`auto example.org {
directory /tmp .* {1}
}`,
true, "", "${1}", ``, 60 * time.Second, 60 * time.Second, nil,
},
{
`auto example.org {
directory /tmp .* {1}
}`,
true, "", "${1}", ``, 60 * time.Second, 60 * time.Second, nil,
},
{
`auto example.org {
directory /tmp .* {1}
}`,
true, "", "${1}", ``, 60 * time.Second, 60 * time.Second, nil,
true, "/tmp", "${1}", ``, 60 * time.Second, nil,
},
}
@ -133,9 +119,6 @@ func TestAutoParse(t *testing.T) {
if a.loader.ReloadInterval != test.expectedReloadInterval {
t.Fatalf("Test %d expected %v, got %v", i, test.expectedReloadInterval, a.loader.ReloadInterval)
}
if a.loader.duration != test.expectedDuration {
t.Fatalf("Test %d expected %v, got %v", i, test.expectedDuration, a.loader.duration)
}
if test.expectedTo != nil {
for j, got := range a.loader.transferTo {
if got != test.expectedTo[j] {