aboutsummaryrefslogtreecommitdiff
path: root/plugin/proxy/proxy_test.go
diff options
context:
space:
mode:
authorGravatar Yong Tang <yong.tang.github@outlook.com> 2019-03-03 23:32:38 -0800
committerGravatar Miek Gieben <miek@miek.nl> 2019-03-04 07:32:38 +0000
commit9dd288943a778c19d5a798e1c1535cd0ba5d53c0 (patch)
tree2f555f01f74f41c005f75aa5a27659d6c5133410 /plugin/proxy/proxy_test.go
parentdfa413af096646e04882bb8312eef27fe1a160ef (diff)
downloadcoredns-9dd288943a778c19d5a798e1c1535cd0ba5d53c0.tar.gz
coredns-9dd288943a778c19d5a798e1c1535cd0ba5d53c0.tar.zst
coredns-9dd288943a778c19d5a798e1c1535cd0ba5d53c0.zip
Move *proxy* to external (#2651)
* Move *proxy* to external move the proxy plugin into coredns/proxy and remove it as a default plugin. Link the proxy to deprecated in plugin.cfg coredns/proxy doesn't compile because of the vendoring :( Signed-off-by: Miek Gieben <miek@miek.nl> * Add github.com/coredns/proxy Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'plugin/proxy/proxy_test.go')
-rw-r--r--plugin/proxy/proxy_test.go72
1 files changed, 0 insertions, 72 deletions
diff --git a/plugin/proxy/proxy_test.go b/plugin/proxy/proxy_test.go
deleted file mode 100644
index 0d29c2329..000000000
--- a/plugin/proxy/proxy_test.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package proxy
-
-import (
- "fmt"
- "net/http"
- "net/http/httptest"
- "strings"
- "sync/atomic"
- "testing"
- "time"
-
- "github.com/mholt/caddy/caddyfile"
-)
-
-func TestStop(t *testing.T) {
- config := "proxy . %s {\n health_check /healthcheck:%s %dms \n}"
- tests := []struct {
- intervalInMilliseconds int
- numHealthcheckIntervals int
- }{
- {5, 1},
- {5, 2},
- {5, 3},
- }
-
- for i, test := range tests {
- t.Run(fmt.Sprintf("Test %d", i), func(t *testing.T) {
-
- // Set up proxy.
- var counter int64
- backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- r.Body.Close()
- atomic.AddInt64(&counter, 1)
- }))
-
- defer backend.Close()
-
- port := backend.URL[17:] // Remove all crap up to the port
- back := backend.URL[7:] // Remove http://
- c := caddyfile.NewDispenser("Testfile", strings.NewReader(fmt.Sprintf(config, back, port, test.intervalInMilliseconds)))
- upstreams, err := NewStaticUpstreams(&c)
- if err != nil {
- t.Errorf("Test %d, expected no error. Got: %s", i, err)
- }
-
- // Give some time for healthchecks to hit the server.
- time.Sleep(time.Duration(test.intervalInMilliseconds*test.numHealthcheckIntervals) * time.Millisecond)
-
- for _, upstream := range upstreams {
- if err := upstream.Stop(); err != nil {
- t.Errorf("Test %d, expected no error stopping upstream, got: %s", i, err)
- }
- }
-
- counterAfterShutdown := atomic.LoadInt64(&counter)
-
- // Give some time to see if healthchecks are still hitting the server.
- time.Sleep(time.Duration(test.intervalInMilliseconds*test.numHealthcheckIntervals) * time.Millisecond)
-
- if counterAfterShutdown == 0 {
- t.Errorf("Test %d, Expected healthchecks to hit test server, got none", i)
- }
-
- // health checks are in a go routine now, so one may well occur after we shutdown,
- // but we only ever expect one more
- counterAfterWaiting := atomic.LoadInt64(&counter)
- if counterAfterWaiting > (counterAfterShutdown + 1) {
- t.Errorf("Test %d, expected no more healthchecks after shutdown. got: %d healthchecks after shutdown", i, counterAfterWaiting-counterAfterShutdown)
- }
- })
- }
-}