diff options
author | 2017-08-09 09:21:33 -0700 | |
---|---|---|
committer | 2017-08-09 09:21:33 -0700 | |
commit | a1b175ef78783df180dffe50d756a85c66cfb1b7 (patch) | |
tree | 19821a7943943677529ff92c31940335cf9e009e /middleware/proxy/upstream_test.go | |
parent | 57692bbccf59aa3eff71ce65739ae195973e5e61 (diff) | |
download | coredns-a1b175ef78783df180dffe50d756a85c66cfb1b7.tar.gz coredns-a1b175ef78783df180dffe50d756a85c66cfb1b7.tar.zst coredns-a1b175ef78783df180dffe50d756a85c66cfb1b7.zip |
Move Healthcheck to middleware/pkg/healthcheck (#854)
* Move healthcheck out
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
* Move healthcheck to middleware/pkg/healthcheck
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'middleware/proxy/upstream_test.go')
-rw-r--r-- | middleware/proxy/upstream_test.go | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/middleware/proxy/upstream_test.go b/middleware/proxy/upstream_test.go index 06c229f39..3aa4104e8 100644 --- a/middleware/proxy/upstream_test.go +++ b/middleware/proxy/upstream_test.go @@ -2,74 +2,16 @@ package proxy import ( "io/ioutil" - "log" "os" "path/filepath" "strings" "testing" - "time" "github.com/coredns/coredns/middleware/test" "github.com/mholt/caddy" ) -func TestHealthCheck(t *testing.T) { - log.SetOutput(ioutil.Discard) - - upstream := &staticUpstream{ - from: ".", - Hosts: testPool(), - Policy: &Random{}, - Spray: nil, - FailTimeout: 10 * time.Second, - Future: 60 * time.Second, - MaxFails: 1, - } - - upstream.healthCheck() - // sleep a bit, it's async now - time.Sleep(time.Duration(2 * time.Second)) - - if upstream.Hosts[0].Down() { - t.Error("Expected first host in testpool to not fail healthcheck.") - } - if !upstream.Hosts[1].Down() { - t.Error("Expected second host in testpool to fail healthcheck.") - } -} - -func TestSelect(t *testing.T) { - upstream := &staticUpstream{ - from: ".", - Hosts: testPool()[:3], - Policy: &Random{}, - FailTimeout: 10 * time.Second, - Future: 60 * time.Second, - MaxFails: 1, - } - upstream.Hosts[0].OkUntil = time.Unix(0, 0) - upstream.Hosts[1].OkUntil = time.Unix(0, 0) - upstream.Hosts[2].OkUntil = time.Unix(0, 0) - if h := upstream.Select(); h != nil { - t.Error("Expected select to return nil as all host are down") - } - upstream.Hosts[2].OkUntil = time.Time{} - if h := upstream.Select(); h == nil { - t.Error("Expected select to not return nil") - } -} - -func TestRegisterPolicy(t *testing.T) { - name := "custom" - customPolicy := &customPolicy{} - RegisterPolicy(name, func() Policy { return customPolicy }) - if _, ok := supportedPolicies[name]; !ok { - t.Error("Expected supportedPolicies to have a custom policy.") - } - -} - func TestAllowedDomain(t *testing.T) { upstream := &staticUpstream{ from: "miek.nl.", |