Revert "Implement notifies for transfer plugin (#3972)" (#3995)

This reverts commit 68f1dd5ddf.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang
2020-07-08 09:00:26 -07:00
committed by GitHub
parent 68f1dd5ddf
commit 614d08cba2
42 changed files with 988 additions and 707 deletions

View File

@@ -15,38 +15,48 @@ func TestAutoParse(t *testing.T) {
expectedTempl string
expectedRe string
expectedReloadInterval time.Duration
expectedTo []string
}{
{
`auto example.org {
directory /tmp
transfer to 127.0.0.1
}`,
false, "/tmp", "${1}", `db\.(.*)`, 60 * time.Second,
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,
false, "/tmp", "${1}", `db\.(.*)`, 60 * time.Second, nil,
},
{
`auto {
directory /tmp
reload 0
}`,
false, "/tmp", "${1}", `db\.(.*)`, 0 * time.Second,
false, "/tmp", "${1}", `db\.(.*)`, 0 * time.Second, nil,
},
{
`auto {
directory /tmp (.*) bliep
}`,
false, "/tmp", "bliep", `(.*)`, 60 * time.Second,
false, "/tmp", "bliep", `(.*)`, 60 * time.Second, nil,
},
{
`auto {
directory /tmp (.*) bliep
reload 10s
}`,
false, "/tmp", "bliep", `(.*)`, 10 * time.Second,
false, "/tmp", "bliep", `(.*)`, 10 * time.Second, nil,
},
{
`auto {
directory /tmp (.*) bliep
transfer to 127.0.0.1
transfer to 127.0.0.2
}`,
false, "/tmp", "bliep", `(.*)`, 60 * time.Second, []string{"127.0.0.1:53", "127.0.0.2:53"},
},
// errors
// NO_RELOAD has been deprecated.
@@ -55,50 +65,42 @@ func TestAutoParse(t *testing.T) {
directory /tmp
no_reload
}`,
true, "/tmp", "${1}", `db\.(.*)`, 0 * time.Second,
true, "/tmp", "${1}", `db\.(.*)`, 0 * time.Second, nil,
},
// TIMEOUT has been deprecated.
{
`auto {
directory /tmp (.*) bliep 10
}`,
true, "/tmp", "bliep", `(.*)`, 10 * time.Second,
},
// TRANSFER has been deprecated.
{
`auto {
directory /tmp (.*) bliep 10
transfer to 127.0.0.1
}`,
true, "/tmp", "bliep", `(.*)`, 10 * time.Second,
true, "/tmp", "bliep", `(.*)`, 10 * time.Second, nil,
},
// no template specified.
{
`auto {
directory /tmp (.*)
}`,
true, "/tmp", "", `(.*)`, 60 * time.Second,
true, "/tmp", "", `(.*)`, 60 * time.Second, nil,
},
// no directory specified.
{
`auto example.org {
directory
}`,
true, "", "${1}", `db\.(.*)`, 60 * time.Second,
true, "", "${1}", `db\.(.*)`, 60 * time.Second, nil,
},
// illegal REGEXP.
{
`auto example.org {
directory /tmp * {1}
}`,
true, "/tmp", "${1}", ``, 60 * time.Second,
true, "/tmp", "${1}", ``, 60 * time.Second, nil,
},
// unexpected argument.
{
`auto example.org {
directory /tmp (.*) {1} aa
}`,
true, "/tmp", "${1}", ``, 60 * time.Second,
true, "/tmp", "${1}", ``, 60 * time.Second, nil,
},
}
@@ -123,6 +125,13 @@ 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 test.expectedTo != nil {
for j, got := range a.loader.transferTo {
if got != test.expectedTo[j] {
t.Fatalf("Test %d expected %v, got %v", i, test.expectedTo[j], got)
}
}
}
}
}
}