aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/cache_test.go (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-09-28plugin/cache: Fix filtering (#4148)Gravatar Miek Gieben 1-2/+2
The filtering of DNSSEC records in the cache plugin was not done correctly. Also the change to introduced this bug didn't take into account that the cache - by virtue of differentiating between DNSSEC and no-DNSSEC - relied on not copying the data from the cache. This change copies and then filters the data and factors the filtering into a function that is used in two places (albeit with on ugly boolean parameters to prevent copying things twice). Add tests, do_test.go is moved to test/cache_test.go because the OPT handing is done outside of the cache plugin. The core server re-attaches the correct OPT when replying, so that makes for a better e2e test. Added small unit test for filterRRslice and an explicit test that asks for DNSSEC first and then plain, and vice versa to test cache behavior. Fixes: #4146 Signed-off-by: Miek Gieben <miek@miek.nl>
2020-09-17cache: default to DNSSEC (#4085)Gravatar Miek Gieben 1-8/+12
* cache: default to DNSSEC This change does away with the DNS/DNSSEC distinction the cache currently makes. Cache will always make coredns perform a DNSSEC query and store that result. If a client just needs plain DNS, the DNSSEC records are stripped from the response. It should also be more memory efficient, because we store a reply once and not one DNS and another for DNSSEC. Fixes: #3836 Signed-off-by: Miek Gieben <miek@miek.nl> * Change OPT RR when one is present in the msg. Signed-off-by: Miek Gieben <miek@miek.nl> * Fix comment for isDNSSEC Signed-off-by: Miek Gieben <miek@miek.nl> * Update plugin/cache/handler.go Co-authored-by: Chris O'Haver <cohaver@infoblox.com> * Update plugin/cache/item.go Co-authored-by: Chris O'Haver <cohaver@infoblox.com> * Code review; fix comment for isDNSSEC Signed-off-by: Miek Gieben <miek@miek.nl> * Update doc and set AD to false Set Authenticated Data to false when DNSSEC was not wanted. Also update the readme with the new behavior. Signed-off-by: Miek Gieben <miek@miek.nl> * Update plugin/cache/handler.go Co-authored-by: Chris O'Haver <cohaver@infoblox.com> Co-authored-by: Chris O'Haver <cohaver@infoblox.com>
2020-03-20plugin/cache: fix negative cache masking cases (#3744)Gravatar Chris O'Haver 1-0/+100
* fix negative cache masking cases Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * remove unecessary param Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2019-11-29Add a serve_stale option for plugin/cache (#3468)Gravatar Gonzalo Paniagua Javier 1-3/+51
Automatically submitted.
2019-10-04Make request.Request smaller (#3351)Gravatar Miek Gieben 1-1/+1
* Make request.Request smaller This makes the request struct smaller and removes the pointer to the do boolean (tri-bool) as size == 0 will indicate if we have cached it. Family can be a int8 because it only carries 3 values, Size itself is just a uint16 under the covers. This is a more comprehensive fix than #3292 Closes #3292 Signed-off-by: Miek Gieben <miek@miek.nl> * cache: fix test this now needs a valid response writter Signed-off-by: Miek Gieben <miek@miek.nl>
2019-06-13plugin/cache: remove item.Autoritative (#2885)Gravatar Miek Gieben 1-9/+8
* plugin/cache: remove item.Autoritative Confuses clients if not set; remove it. Signed-off-by: Miek Gieben <miek@miek.nl> * Add extra comments on why we do this Signed-off-by: Miek Gieben <miek@miek.nl>
2019-04-08[plugin/cache] cache failures (#2720)Gravatar Kun Chang 1-0/+28
* cache failures * use ServerError
2019-01-19Stop importing testing in the main binary (#2479)Gravatar Miek Gieben 1-9/+8
* Stop importing testing in the main binary Stop importing "testing" into the main binary: * test/helpers.go imported it; remote that and change function signature * update all tests that use this Signed-off-by: Miek Gieben <miek@miek.nl> * Drop import testing from metrics plugin Signed-off-by: Miek Gieben <miek@miek.nl> * more fiddling Signed-off-by: Miek Gieben <miek@miek.nl>
2018-10-29cache: some optimizations (#2247)Gravatar Miek Gieben 1-3/+2
Remove some optimization and lowercasing of the qname (in the end miekg/dns should provide a fast and OK function for it). * remove the make([]byte, 2) allocation in the key() * use already lowercased qname in hash key calculation. % benchcmp old.txt new.txt benchmark old ns/op new ns/op delta BenchmarkCacheResponse-4 9599 8735 -9.00% Signed-off-by: Miek Gieben <miek@miek.nl>
2018-09-03Add MINTTL parameter to cache configuration. (#2055)Gravatar Aaron Riekenberg 1-0/+22
* Add success min TTL parameter to cache. * Add MINTTL to README. * Update README. * Add MINTTL to negative cache. * Remove unnecessary variable name. * Address review comments. * Configure cache in TestCacheZeroTTL to have 0 min ttl.
2018-08-31Move cache Keys to 64bit for a better dispersion and lower collision ↵Gravatar Francois Tur 1-2/+4
frequency (#2077) * - change Key for cache to 64bits. * - change Key for cache to 64bits.
2018-06-02presubmit: Check errorf as well (#1845)Gravatar Miek Gieben 1-1/+1
Uppercase all these test errors as well. And extend the presubmit to check for these in the future. Also do a slightly smarter grep to only get t.<something>. as (because dump regexp) this also grep over non test files.
2018-04-30plugin/cache: fix benchmark (#1758)Gravatar Miek Gieben 1-9/+9
2018-04-27Cache metrics server (#1746)Gravatar Miek Gieben 1-7/+6
* plugin/cache: per server metrics Use per server metrics in the cache plugin as well. This required some plumbing changes. Also use request.Request more. * fix cherry-pick
2018-04-22all: fix plugin import ordering (#1717)Gravatar Miek Gieben 1-2/+1
Got a bit messed up with stb lib "context" usage.
2018-04-20global: move to context (#1699)Gravatar Miek Gieben 1-1/+1
* global: move to context Move from golang.org/x/net/context to std lib's context. Change done with: for i in $(grep -l '/context' **/*.go); do sed -e 's|golang.org/x/net/context|context|' -i $i; echo $i; done for i in **/*.go; do goimports -w $i; done * drop from dns.pb.go as well
2018-04-19Update all plugins to use plugin/pkg/log (#1694)Gravatar Miek Gieben 1-4/+0
* Update all plugins to use plugin/pkg/log I wish this could have been done with sed. Alas manually changed all callers to use the new plugin/pkg/log package. * Error -> Info * Add docs to debug plugin as well
2018-02-17Type.extra (#1538)Gravatar Miek Gieben 1-11/+0
* Revert "pkg/typify: empty messages are OtherError (#1531)" This reverts commit fc1d73ffa9ae193c4cfca4adc194ae43f9360dbb. * plugin/cache: add failsafeTTL If we can not see what TTL we should put on a message to be cached, use 5 seconds as minimal TTL. We used to apply the maximum TTL to these messages.
2018-02-16pkg/typify: empty messages are OtherError (#1531)Gravatar Miek Gieben 1-0/+11
Messages with nothing in them are considered OtherError, they can not serve any purpose for normal clients (i.e. dyn update or notifies might have a use for them). Also update a test in the cache plugin, so that we explicitaly test for this case.
2018-01-17plugin/cache: Fix prefetching issues (#1363)Gravatar Tobias Schmidt 1-12/+6
* Improve plugin/cache metrics * Add coredns_cache_prefetch_total metric to track number of prefetches. * Remove unnecessary Cache.get() call which would incorrectly increment cache counters. * Initialize all counters and gauges at zero. * Allow prefetching of a single request per ttl The original implementation didn't allow prefetching queries which are only requested once during the duration of a TTL. The minimum amount of queries which had to be seen was therefore capped at 2. This change also implements a real prefetch test. The existing test was a noop and always passed regardless of any prefetch implementation. * Fix prefetching for items with a short TTL The default prefetch threshold (percentage) is 10% of the lifetime of a cache item. With the previous implementation, this disabled prefetching for all items with a TTL < 10s (the resulting percentage would be 0, at which point a cached item is already discarded). This change uses a time based threshold calculation and ensures that a prefetch is triggered at a TTL of 1 at the latest. * Fix wrong duration reporting of cached responses The logging and metrics plugins (among others) included the duration of a cache prefetch in the request latency of client request. This change fixes this wrong reporting and executes the prefetch request in a goroutine in the background.
2017-09-28plugin/cache: don't cache msg with TTL=0 in them (#1116)Gravatar Miek Gieben 1-0/+31
Don't cache these - may be lead to weird side effects. Fixes #1113
2017-09-14Remove the word middleware (#1067)Gravatar Miek Gieben 1-0/+251
* Rename middleware to plugin first pass; mostly used 'sed', few spots where I manually changed text. This still builds a coredns binary. * fmt error * Rename AddMiddleware to AddPlugin * Readd AddMiddleware to remain backwards compat