Commit graph

27 commits

Author SHA1 Message Date
Eng Zer Jun
b868350fc2
test: use t.TempDir to create temporary test directory (#6164) 2023-06-17 15:21:01 +02:00
Miek Gieben
6953ab2b4f
Metrics: expand coredns_dns_responses_total with plugin label (#4914)
* 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 b5c6655196.

* 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-11-12 16:07:05 +00:00
Zou Nengren
5191959bd7
cleanup deprecated package io/ioutil (#4920)
Signed-off-by: zounengren <zouyee1989@gmail.com>
2021-10-13 09:30:31 +02:00
Miek Gieben
6938dac21d
reduce sleeps (#4205)
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-10-15 04:19:39 -07:00
Li Zhijian
011686b344
Cleanup tempfiles (#3986)
* 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-07-02 09:10:36 +02:00
Ambrose Chua
ed1f42cf56
Fix mixed indentation within tests (#3855)
Signed-off-by: Ambrose Chua <ambrose@chua.family>
2020-04-25 08:08:36 +02:00
Zou Nengren
4ccd55e95e
correct metrics name of cache size (#3805)
Signed-off-by: zounengren <zounengren@cmss.chinamobile.com>
2020-04-03 09:30:06 -07:00
Miek Gieben
19cfa2960c
Cleanup metrics (#3776)
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-03-26 09:17:33 +01:00
Zou Nengren
99e7c3dee7 registry cache_miss logic (#3578)
Signed-off-by: zouyee <zounyee1989@gmail.com>
2020-01-03 10:06:37 +01:00
Xiao An
cb96ab9f4f Fully deprecate TIMEOUT and NO_RELOAD (#2742)
* 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-04-01 07:28:01 +01:00
Jiacheng Xu
0e137b23f1 plugin/metrics: Add a metric to monitor which plugin(s) is(are) enabled (#2700)
* 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-23 09:43:15 +00:00
Yong Tang
9dd288943a Move *proxy* to external (#2651)
* 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-03-04 07:32:38 +00:00
Ye Ben
0eff7f3797 some typo fix (#2512)
Signed-off-by: yeya24 <ben.ye@daocloud.io>
2019-01-29 10:21:19 -05:00
Miek Gieben
725becd134
Stop importing testing in the main binary (#2479)
* 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>
2019-01-19 11:23:13 +00:00
Francois Tur
05204ef142 Metrics registered on wrong prometheus registry (#2246)
* - 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-11-01 19:56:00 +00:00
Manuel Stocker
4b1b0ec9e6 Use filepath when manipulating file paths (#2221)
Automatically submitted.
2018-10-21 13:59:37 +00:00
Miek Gieben
f3134da45e
Clean up tests logging (#1979)
* 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>
2018-07-19 16:23:06 +01:00
Miek Gieben
d8714e64e4 Remove the word middleware (#1067)
* 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-09-14 09:36:06 +01:00
Miek Gieben
f901b0cefa tests: CoreDNSServerAndPorts (#972)
* 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-08-24 11:35:14 +01:00
Yong Tang
81af74aad0 Fix import path github.com/miekg/coredns -> github.com/coredns/coredns (#547)
This fix fixes import path from
`github.com/miekg/coredns`
->
`github.com/coredns/coredns`
2017-02-22 06:51:47 +00:00
Miek Gieben
94c59da577 Run tests in parallel (#478)
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.
2017-01-12 08:13:50 +00:00
Miek Gieben
d6902cd7a1 Disable metrics test (#380)
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-11-05 14:38:49 +00:00
Ben Kochie
775d26c5e2 Add metrics for cache hits/misses (#375)
* 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-31 18:50:50 +00:00
Miek Gieben
81d5baee28 middleware/cache: fix metrics test
Fix the metrics test, top-level test directory still referenced the
old metrics name.
2016-10-30 15:08:40 +00:00
Miek Gieben
cb867ff6bd middleware/metrics: export ListenAddr (#366)
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-28 12:57:10 +01:00
Miek Gieben
219bfd0493 middleware/metrics: cleanup (#355)
* 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-26 10:01:52 +01:00
Miek Gieben
db6c9a3f01 middleware/metrics: fix crash on startup (#318)
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.
2016-10-04 11:05:04 +01:00