aboutsummaryrefslogtreecommitdiff
path: root/middleware/proxy/upstream_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'middleware/proxy/upstream_test.go')
-rw-r--r--middleware/proxy/upstream_test.go58
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.",