aboutsummaryrefslogtreecommitdiff
path: root/plugin/forward/persistent_test.go
diff options
context:
space:
mode:
authorGravatar Ruslan Drozhdzh <30860269+rdrozhdzh@users.noreply.github.com> 2018-04-06 15:41:48 +0300
committerGravatar Miek Gieben <miek@miek.nl> 2018-04-06 13:41:48 +0100
commite46ee9d9cc197d74dac0cb6e8432f83d4f43d1a6 (patch)
tree66ac38903d67d57f0a23552f0be7cea3bd3bdd93 /plugin/forward/persistent_test.go
parent848a5d7c7909afbc381a0708dc4893c28a1df61c (diff)
downloadcoredns-e46ee9d9cc197d74dac0cb6e8432f83d4f43d1a6.tar.gz
coredns-e46ee9d9cc197d74dac0cb6e8432f83d4f43d1a6.tar.zst
coredns-e46ee9d9cc197d74dac0cb6e8432f83d4f43d1a6.zip
plugin/forward: retry on cached tcp connection closed by peer (#1655)
* plugin/forward: retry on cached tcp connection closed by peer * fix linter warnings * fixed unit test * modify error message
Diffstat (limited to 'plugin/forward/persistent_test.go')
-rw-r--r--plugin/forward/persistent_test.go26
1 files changed, 20 insertions, 6 deletions
diff --git a/plugin/forward/persistent_test.go b/plugin/forward/persistent_test.go
index 5fa491a01..f4f476afa 100644
--- a/plugin/forward/persistent_test.go
+++ b/plugin/forward/persistent_test.go
@@ -19,9 +19,13 @@ func TestPersistent(t *testing.T) {
tr := newTransport(s.Addr, nil /* no TLS */)
defer tr.Stop()
- c1, _ := tr.Dial("udp")
- c2, _ := tr.Dial("udp")
- c3, _ := tr.Dial("udp")
+ c1, cache1, _ := tr.Dial("udp")
+ c2, cache2, _ := tr.Dial("udp")
+ c3, cache3, _ := tr.Dial("udp")
+
+ if cache1 || cache2 || cache3 {
+ t.Errorf("Expected non-cached connection")
+ }
tr.Yield(c1)
tr.Yield(c2)
@@ -31,13 +35,23 @@ func TestPersistent(t *testing.T) {
t.Errorf("Expected cache size to be 3, got %d", x)
}
- tr.Dial("udp")
+ c4, cache4, _ := tr.Dial("udp")
if x := tr.Len(); x != 2 {
t.Errorf("Expected cache size to be 2, got %d", x)
}
- tr.Dial("udp")
+ c5, cache5, _ := tr.Dial("udp")
if x := tr.Len(); x != 1 {
- t.Errorf("Expected cache size to be 2, got %d", x)
+ t.Errorf("Expected cache size to be 1, got %d", x)
+ }
+
+ if cache4 == false || cache5 == false {
+ t.Errorf("Expected cached connection")
+ }
+ tr.Yield(c4)
+ tr.Yield(c5)
+
+ if x := tr.Len(); x != 3 {
+ t.Errorf("Expected cache size to be 3, got %d", x)
}
}