Commit graph

18 commits

Author SHA1 Message Date
Fish-pro
156da74ad3
Close the body after reading the response body information (#5907)
Signed-off-by: Fish-pro <zechun.chen@daocloud.io>
2023-02-15 12:41:51 -05:00
Chris O'Haver
29f3dcfa10
plugin/ready: Reset list of readiness plugins on startup (#5492)
* reset readiness plugins list on startup

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
2022-07-18 09:50:15 -04: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
c840caf1ef
Speed up testing (#4239)
* Speed up testing

* make notification run in the background, this recudes the test_readme
time from 18s to 0.10s
* reduce time for zone reload

* TestServeDNSConcurrent remove entirely. This took a whopping 58s for
  ... ? A few minutes staring didn't reveal wth it is actually testing.
  Making values smaller revealed race conditions in the tests. Remove
  entirely.

* Move many interval values to variables so we can reset them to short
  values for the tests.

* test_large_axfr: make the zone smaller. The number used 64K has no
  rational, make it 64/10 to speed up.
* TestProxyThreeWay: use client with shorter timeout

A few random tidbits in other tests.

Total time saved: 177s (almost 3m) - which makes it worthwhile again to
run the test locally:

this branch:

~~~
ok  	github.com/coredns/coredns/test	10.437s
cd plugin; time go t ./...
5,51s user 7,51s system 11,15s elapsed 744%CPU (
~~~

master:

~~~
ok  	github.com/coredns/coredns/test	35.252s
cd plugin; time go t ./...
157,64s user 15,39s system 50,05s elapsed 345%CPU ()
~~~
tests/ -25s
plugins/ -40s

This brings the total on 20s, and another 10s can be saved by fixing
dnstapio. Moving this to 5s would be even better, but 10s is also nice.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Also 0.01

Signed-off-by: Miek Gieben <miek@miek.nl>
2020-10-30 10:27:04 +01: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
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
xieyanker
9fe7fb95c6 return standardized text for ready and health endpoint (#3195) 2019-08-26 10:31:24 +00:00
Francois Tur
f9bdd382dd Ensure Re-register of metrics variables after a reload (#2080)
* - ensure plugins that use prometheus.MustRegister, re-register after reload
- removing once.Do on the startup function was simplest way to do it.

* - fix underscored names (advice of bot)

* - tune existing UT for reload, and add a test verifying failing reload does not prevent correct registering for metrics

* - ensure different ports for tests that can run in same time ..
2018-09-19 02:11:24 -07:00
Zach Eddy
8aa55c5ff2 Metrics listener fix (#2036)
* Create test to verify correct listener behavior

* Create Unset function to remove todo items

* Reset address for prometheus listener before restarting

* Add inline documentation for Unset function

* Make shutdownTimeout a constant and change to five seconds

* Revert ForEach behavior in uniq package
2018-08-21 11:52:25 -04:00
Miek Gieben
2b9d2d6c3a
reload: don't fail test on addr in use (#1804)
A bit meh, but we *need* hardcoded addresses in these tests, because
we can't get them from a running coredns. These may be in-use and this
fails the tests then. Do an ugly err.Error() string match if this is the
case to prevent failing the test for something not in our control.

A better fix would be to retreive the listening address from coredns via
some api, so we could listen on :0 for these as well. No such API exists
as of yet.
2018-05-18 07:26:45 +01:00
Miek Gieben
a466bb6fc6
Export metrics in setup; so it also works after reload (#1715)
* brr; a sleep

* Shouldnt need a query
2018-04-21 18:59:35 +01:00
Miek Gieben
acbcad7b4e
reload: use OnRestart (#1709)
* reload: use OnRestart

Close the listener on OnRestart for health and metrics so the default
setup function can setup the listener when the plugin is "starting up".

Lightly test with some SIGUSR1-ing. Also checked the reload plugin with
this, seems fine:

.com.:1043
.:1043
2018/04/20 15:01:25 [INFO] CoreDNS-1.1.1
2018/04/20 15:01:25 [INFO] linux/amd64, go1.10,
CoreDNS-1.1.1
linux/amd64, go1.10,
2018/04/20 15:01:25 [INFO] Running configuration MD5 = aa8b3f03946fb60546ca1f725d482714
2018/04/20 15:02:01 [INFO] Reloading
2018/04/20 15:02:01 [INFO] Running configuration MD5 = b34a96d99e01db4015a892212560155f
2018/04/20 15:02:01 [INFO] Reloading complete
^C2018/04/20 15:02:06 [INFO] SIGINT: Shutting down

With this corefile:
.com {
  proxy . 127.0.0.1:53
  prometheus :9054
  whoami
  reload
}

. {
  proxy . 127.0.0.1:53
  prometheus :9054
  whoami
  reload
}

The prometheus port was 9053, changed that to 54 so reload would pick it
up.

From a cursory look it seems this also fixes:
Fixes #1604 #1618 #1686 #1492

* At least make it test

* Use onfinalshutdown

* reload: add reload test

This test #1604 adn right now fails.

* Address review comments

* Add bug section explaining things a bit

* compile tests

* Fix tests

* fixes

* slightly less crazy

* try to make prometheus setup less confusing

* Use ephermal port for test

* Don't use the listener

* These are shared between goroutines, just use the boolean in the main
  structure.
* Fix text in the reload README,
* Set addr to TODO once stopping it
* Morph fturb's comment into test, to test reload and scrape health and
  metric endpoint
2018-04-21 17:43:02 +01:00
Yong Tang
102cfbd7fe Use gometalinter and enforcing go fmt/lint/vet (#1108)
* Use gometalinter and enforcing go fmt/lint/vet

Before this PR go fmt is enabled, go lint is suggest only.
From time to time we have to manually check for go lint and go vet
for any issues.

This fix uses gometalinter and enforcing go fmt/lint/vet.
Several reasons:
- gometalinter could handle multiple linters concurrently
- gometalinter supports suppression with `// nolint[: <linter>]`

Previously one reason we didn't enable go lint was due to the
```
warning: context.Context should be the first parameter of a function (golint)
```
this is now possible with gometalinter and `// nolint: golint` (See changes).

This fix also discovered several go vet issues and fixes it.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Fix several issues reported by gometalinter (go vet)

This commit fixes several issues reported by gometalinter (go vet).

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Increase deadline

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-09-24 11:59:04 +01:00
Miek Gieben
9c56805d38 mw/etcd: use context.TODO() in tests (#1000)
Go vet warning: fix use of context.

Fixes #997

Also make *auto*'s reload test less flaky by retrying
and then giving up.
2017-08-27 07:39:44 +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
Miek Gieben
e49ca86ce4 cleanup: go vet and golint run (#736)
* cleanup: go vet and golint run

Various cleanups trickered by go vet and golint.

* Fix tests and lowercase all errors

Lowercase all errors, some tests in kubernetes use errors from
kubernetes which do start with a capital letter.
2017-06-14 09:37:10 -07:00
Miek Gieben
3b6eab2256 core: add reload tests (#622)
This adds a simple reload test for the UDP socket.
2017-04-18 11:25:21 +01:00