aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/cache_test.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2022-06-17 15:48:57 -0400
committerGravatar GitHub <noreply@github.com> 2022-06-17 15:48:57 -0400
commitdded10420b8a477ebd86cd2ceed9207a42c226cc (patch)
tree6b0679260b212428c74a3fbdc6ee3013d6460e0b /plugin/cache/cache_test.go
parentd60ce0c8d4fd647e880a118f469e8239d6effc7d (diff)
downloadcoredns-dded10420b8a477ebd86cd2ceed9207a42c226cc.tar.gz
coredns-dded10420b8a477ebd86cd2ceed9207a42c226cc.tar.zst
coredns-dded10420b8a477ebd86cd2ceed9207a42c226cc.zip
plugin/cache: Add option to adjust SERVFAIL response cache TTL (#5320)
* add servfail cache opt Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/cache/cache_test.go')
-rw-r--r--plugin/cache/cache_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/plugin/cache/cache_test.go b/plugin/cache/cache_test.go
index 7299dc073..69bea61a4 100644
--- a/plugin/cache/cache_test.go
+++ b/plugin/cache/cache_test.go
@@ -258,6 +258,23 @@ func TestCacheZeroTTL(t *testing.T) {
}
}
+func TestCacheServfailTTL0(t *testing.T) {
+ c := New()
+ c.minpttl = minTTL
+ c.minnttl = minNTTL
+ c.failttl = 0
+ c.Next = servFailBackend(0)
+
+ req := new(dns.Msg)
+ req.SetQuestion("example.org.", dns.TypeA)
+ ctx := context.TODO()
+
+ c.ServeDNS(ctx, &test.ResponseWriter{}, req)
+ if c.ncache.Len() != 0 {
+ t.Errorf("SERVFAIL response should not have been cached")
+ }
+}
+
func TestServeFromStaleCache(t *testing.T) {
c := New()
c.Next = ttlBackend(60)