aboutsummaryrefslogtreecommitdiff
path: root/test/metrics_test.go (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-06-17test: use `t.TempDir` to create temporary test directory (#6164)Gravatar Eng Zer Jun 1-5/+1
2021-11-12Metrics: expand coredns_dns_responses_total with plugin label (#4914)Gravatar Miek Gieben 1-12/+13
* Metrics: expand coredns_dns_responses_total with plugin label This adds (somewhat hacky?) code to add a plugin label to the coredns_dns_responses_total metric. It's completely obvlious to the plugin as we just check who called the *recorder.WriteMsg method. We use runtime.Caller( 1 2 3) to get multiple levels of callers, this should be deep enough, but it depends on the dns.ResponseWriter wrapping that's occuring. README.md of metrics updates and test added in test/metrics_test.go to check for the label being set. I went through the plugin to see what metrics could be removed, but actually didn't find any, the plugin push out metrics that make sense. Due to the path fiddling to figure out the plugin name I doubt this works (out-of-the-box) for external plugins, but I haven't tested that. Signed-off-by: Miek Gieben <miek@miek.nl> * better comment Signed-off-by: Miek Gieben <miek@miek.nl> * Metrics: expand coredns_dns_responses_total with plugin label This adds (somewhat hacky?) code to add a plugin label to the coredns_dns_responses_total metric. It's completely obvlious to the plugin as we just check who called the *recorder.WriteMsg method. We use runtime.Caller( 1 2 3) to get multiple levels of callers, this should be deep enough, but it depends on the dns.ResponseWriter wrapping that's occuring. README.md of metrics updates and test added in test/metrics_test.go to check for the label being set. I went through the plugin to see what metrics could be removed, but actually didn't find any, the plugin push out metrics that make sense. Due to the path fiddling to figure out the plugin name I doubt this works (out-of-the-box) for external plugins, but I haven't tested that. Signed-off-by: Miek Gieben <miek@miek.nl> * Update core/dnsserver/server.go Co-authored-by: dilyevsky <ilyevsky@gmail.com> * Use [3]string Signed-off-by: Miek Gieben <miek@miek.nl> * imports Signed-off-by: Miek Gieben <miek@miek.nl> * remove dnstest changes Signed-off-by: Miek Gieben <miek@miek.nl> * revert Signed-off-by: Miek Gieben <miek@miek.nl> * Add some sleeps to make it less flaky Signed-off-by: Miek Gieben <miek@miek.nl> * Revert "Add some sleeps to make it less flaky" This reverts commit b5c6655196e3ad570555f086832ceb1f48f6f2d5. * Remove forward when not needed Signed-off-by: Miek Gieben <miek@miek.nl> * remove newline Signed-off-by: Miek Gieben <miek@miek.nl> Co-authored-by: dilyevsky <ilyevsky@gmail.com>
2021-10-13cleanup deprecated package io/ioutil (#4920)Gravatar Zou Nengren 1-3/+2
Signed-off-by: zounengren <zouyee1989@gmail.com>
2020-10-15reduce sleeps (#4205)Gravatar Miek Gieben 1-4/+3
This reduces the amount of sleep time to speed up testing. master: PASS ok github.com/coredns/coredns/test 42.088s 12,33s user 1,30s system 44,29s elapsed 30%CPU () this branch: PASS ok github.com/coredns/coredns/test 33.527s Signed-off-by: Miek Gieben <miek@miek.nl>
2020-07-02Cleanup tempfiles (#3986)Gravatar Li Zhijian 1-0/+1
* cleanup tempfiles for auto_test Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> * cleanup tempfiles for metrics_test Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
2020-04-25Fix mixed indentation within tests (#3855)Gravatar Ambrose Chua 1-45/+40
Signed-off-by: Ambrose Chua <ambrose@chua.family>
2020-04-03correct metrics name of cache size (#3805)Gravatar Zou Nengren 1-2/+2
Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
2020-03-26Cleanup metrics (#3776)Gravatar Miek Gieben 1-2/+2
Cleanup a variety of metric issues. * Eliminate department of redundancy "count_total" naming. * Use the plural of the unit when appropriate. (ex, "requests") * Remove label names from metric names where appropriate. (ex, "rcode") * Simplify request metrics by consolidating type label in to the base request counter. * Re-generate man pages. Signed-off-by: Ben Kochie <superq@gmail.com> Co-authored-by: Ben Kochie <superq@gmail.com>
2020-01-03registry cache_miss logic (#3578)Gravatar Zou Nengren 1-0/+37
Signed-off-by: zouyee <zounyee1989@gmail.com>
2019-04-01Fully deprecate TIMEOUT and NO_RELOAD (#2742)Gravatar Xiao An 1-1/+2
* Fully deprecate NO_RELOAD Signed-off-by: Xiao An <hac@zju.edu.cn> * Fully deprecate TIMEOUT Signed-off-by: Xiao An <hac@zju.edu.cn> * Update CI tests to adapt to the deprecation of TIMEOUT Signed-off-by: Xiao An <hac@zju.edu.cn> * Add documents for directive transfer in plugin auto Signed-off-by: Xiao An <hac@zju.edu.cn>
2019-03-23plugin/metrics: Add a metric to monitor which plugin(s) is(are) enabled (#2700)Gravatar Jiacheng Xu 1-0/+36
* Add a GaugeVec for enabled plugins monitoring. Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com> * Add server label and zone label for enable_plugin matric. * Add a test for PluginEnabled metric * Add description for enabledPlugin metric. * Change the description for the enabledPlugin metric. * Reset the enabledPlugin metric when restart the server. * Add the bug session for enabledPlugin metric. * Remove the resolveTCPAddr
2019-03-04Move *proxy* to external (#2651)Gravatar Yong Tang 1-2/+2
* 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>
2019-01-29some typo fix (#2512)Gravatar Ye Ben 1-1/+1
Signed-off-by: yeya24 <ben.ye@daocloud.io>
2019-01-19Stop importing testing in the main binary (#2479)Gravatar Miek Gieben 1-71/+9
* 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-11-01Metrics registered on wrong prometheus registry (#2246)Gravatar Francois Tur 1-13/+79
* - UT on metrics verifying that all plugins of all blocs have their metrics collectors declared * - fix error msg * - redirect Registry of metric to the one that handle the listener - allow duplicate of metrics collector on the same Registry (case of same plugin in 2 blocs listening metrics on the same address) * - fix change of signature * - ensure cleaning metrics before starting the test (metrics collectors are global vars .. and re-used by several tests) * - I think I fixed this test. Ensure correct mn of hits and clean metrics before test. * - fix typo in error msg - proposed at review * - fix typo in comment * - remove ResetMetrics functions - change a way to test the numeric metrics : get the diff between begin and end of test * - oops. removing debug logs
2018-10-21Use filepath when manipulating file paths (#2221)Gravatar Manuel Stocker 1-3/+3
Automatically submitted.
2018-07-19Clean up tests logging (#1979)Gravatar Miek Gieben 1-3/+0
* Clean up tests logging This cleans up the travis logs so you can see the failures better. Older tests in tests/ would call log.SetOutput(ioutil.Discard) in a haphazard way. This add log.Discard and put an `init` function in each package's dir (no way to do this globally). The cleanup in tests/ is clear. All plugins also got this init function to have some uniformity and kill any (future) logging there in the tests as well. There is a one-off in pkg/healthcheck because that does log. Signed-off-by: Miek Gieben <miek@miek.nl> * bring back original log_test.go Signed-off-by: Miek Gieben <miek@miek.nl> * suppress logging here as well Signed-off-by: Miek Gieben <miek@miek.nl>
2017-09-14Remove the word middleware (#1067)Gravatar Miek Gieben 1-4/+4
* 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
2017-08-24tests: CoreDNSServerAndPorts (#972)Gravatar Miek Gieben 1-3/+1
* tests: CoreDNSServerAndPorts Copy from kubernetes.go and renamed to fit the style, adapted almost all callers. This is a mechanicl change, no testdata was changed. * typos
2017-02-22Fix import path `github.com/miekg/coredns` -> `github.com/coredns/coredns` ↵Gravatar Yong Tang 1-4/+4
(#547) This fix fixes import path from `github.com/miekg/coredns` -> `github.com/coredns/coredns`
2017-01-12Run tests in parallel (#478)Gravatar Miek Gieben 1-0/+2
Create a small speedup running the tests: PASS ok github.com/miekg/coredns/test 10.329s PASS ok github.com/miekg/coredns/test 6.079s Skip the etcd ones. Doing the middleware/*/*_test ones doesn't yield any speedup as these are still done on a per directory basis.
2016-11-05Disable metrics test (#380)Gravatar Miek Gieben 1-4/+5
Disable this test (for now), it fails weirdly on travis (and not locally). Initial suspicion that another server is still reporting (or something). Anyway hard to replicate locally - disable it for now.
2016-10-31Add metrics for cache hits/misses (#375)Gravatar Ben Kochie 1-4/+18
* Add metrics for cache hits/misses Add counters for cache middleware hits and misses. * Add test for cache middleware hit/miss counters. * Fix cache hit metric incrementing. * Add cache hit/miss metrics to dnssec middleware. * Update README metric documentation.
2016-10-30middleware/cache: fix metrics testGravatar Miek Gieben 1-2/+2
Fix the metrics test, top-level test directory still referenced the old metrics name.
2016-10-28middleware/metrics: export ListenAddr (#366)Gravatar Miek Gieben 1-10/+9
ListenAddr is the address where the prometheus metric are exported. This can be used in tests to listen on "localhost:0" and then later retrieve the metrics from there. It makes the tests indepent on each other.
2016-10-26middleware/metrics: cleanup (#355)Gravatar Miek Gieben 1-3/+159
* middleware/metrics: add more metrics middleware/cache: Add metrics for number of elements in the cache. Also export the total size. Update README to detail the new metrics. middleware/metrics Move metrics into subpackage called "vars". This breaks the import cycle and is cleaner. This allows vars.Report to be used in the the dnsserver to log refused queries. middleware/metrics: tests Add tests to the metrics framework. The metrics/test subpackage allows scraping of the local server. Do a few test scrape of the metrics that are defined in the metrics middleware. This also allows metrics integration tests to check if the caching and dnssec middleware export their metrics correctly. * update README * typos * fix tests
2016-10-04middleware/metrics: fix crash on startup (#318)Gravatar Miek Gieben 1-0/+17
Make the methods that handle Metrics all use pointer receivers to fix sync.Once not being initialized. Finish the setup_test to test for failures. And make the check for the address more strict and return an error when it does not have a port number. Add a toplevel test that starts a CoreDNS server with metrics enabled so we catch these errors in the future.