aboutsummaryrefslogtreecommitdiff
path: root/plugin/forward/proxy_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-04-26 09:34:58 +0100
committerGravatar GitHub <noreply@github.com> 2018-04-26 09:34:58 +0100
commit270da8299525d3f3139f1b2395b366b8344ceec9 (patch)
treec218d88a67915eae7f525cf1a0d4d1e5858ebe5a /plugin/forward/proxy_test.go
parent4c7ae4ea95082941cde6236133c84229cd386ed5 (diff)
downloadcoredns-270da8299525d3f3139f1b2395b366b8344ceec9.tar.gz
coredns-270da8299525d3f3139f1b2395b366b8344ceec9.tar.zst
coredns-270da8299525d3f3139f1b2395b366b8344ceec9.zip
plugin/forward: move Dial goroutine out (#1738)
Rework the TestProxyClose - close the proxy in the *same* goroutine as where we started it. Close channels as long as we don't get dataraces (this may need another fix). Move the Dial goroutine out of the connManager - this simplifies things *and* makes another goroutine go away and removes the need for connErr channels - can now just be dns.Conn. Also: Revert "plugin/forward: gracefull stop (#1701)" This reverts commit 135377bf776295d8ef86081c1ef581e7b41d26f0. Revert "rework TestProxyClose (#1735)" This reverts commit 9e8893a0b5325a76b2784958bbe743ff3e831401.
Diffstat (limited to 'plugin/forward/proxy_test.go')
-rw-r--r--plugin/forward/proxy_test.go51
1 files changed, 7 insertions, 44 deletions
diff --git a/plugin/forward/proxy_test.go b/plugin/forward/proxy_test.go
index acd3d240c..d473d6881 100644
--- a/plugin/forward/proxy_test.go
+++ b/plugin/forward/proxy_test.go
@@ -2,9 +2,7 @@ package forward
import (
"context"
- "runtime"
"testing"
- "time"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/test"
@@ -28,50 +26,15 @@ func TestProxyClose(t *testing.T) {
ctx := context.TODO()
for i := 0; i < 100; i++ {
- p := NewProxy(s.Addr, nil /* no TLS */)
+ p := NewProxy(s.Addr, nil)
p.start(hcDuration)
- doneCnt := 0
- doneCh := make(chan bool)
- timeCh := time.After(10 * time.Second)
- go func() {
- p.connect(ctx, state, false, false)
- doneCh <- true
- }()
- go func() {
- p.connect(ctx, state, true, false)
- doneCh <- true
- }()
- go func() {
- p.close()
- doneCh <- true
- }()
- go func() {
- p.connect(ctx, state, false, false)
- doneCh <- true
- }()
- go func() {
- p.connect(ctx, state, true, false)
- doneCh <- true
- }()
-
- for doneCnt < 5 {
- select {
- case <-doneCh:
- doneCnt++
- case <-timeCh:
- t.Error("TestProxyClose is running too long, dumping goroutines:")
- buf := make([]byte, 100000)
- stackSize := runtime.Stack(buf, true)
- t.Fatal(string(buf[:stackSize]))
- }
- }
- if p.inProgress != 0 {
- t.Errorf("unexpected query in progress")
- }
- if p.state != stopped {
- t.Errorf("unexpected proxy state, expected %d, got %d", stopped, p.state)
- }
+ go func() { p.connect(ctx, state, false, false) }()
+ go func() { p.connect(ctx, state, true, false) }()
+ go func() { p.connect(ctx, state, false, false) }()
+ go func() { p.connect(ctx, state, true, false) }()
+
+ p.close()
}
}