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.
This commit is contained in:
Miek Gieben 2017-01-12 08:13:50 +00:00 committed by GitHub
parent 0c3ad499d8
commit 94c59da577
14 changed files with 46 additions and 32 deletions

View file

@ -16,6 +16,7 @@ import (
)
func TestAuto(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns")
if err != nil {
t.Fatal(err)
@ -81,6 +82,7 @@ func TestAuto(t *testing.T) {
}
func TestAutoNonExistentZone(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns")
if err != nil {
t.Fatal(err)
@ -119,6 +121,7 @@ func TestAutoNonExistentZone(t *testing.T) {
}
func TestAutoAXFR(t *testing.T) {
t.Parallel()
log.SetOutput(ioutil.Discard)
tmpdir, err := ioutil.TempDir(os.TempDir(), "coredns")

View file

@ -14,6 +14,7 @@ import (
)
func TestLookupCache(t *testing.T) {
t.Parallel()
// Start auth. CoreDNS holding the auth zone.
name, rm, err := test.TempFile(".", exampleOrg)
if err != nil {

View file

@ -32,6 +32,7 @@ var dsTestCases = []mtest.Case{
}
func TestLookupDS(t *testing.T) {
t.Parallel()
name, rm, err := TempFile(".", miekNL)
if err != nil {
t.Fatalf("failed to created zone: %s", err)

View file

@ -31,7 +31,7 @@ func etcdMiddleware() *etcd.Etcd {
// This test starts two coredns servers (and needs etcd). Configure a stubzones in both (that will loop) and
// will then test if we detect this loop.
func TestEtcdStubForwarding(t *testing.T) {
func TestEtcdStubLoop(t *testing.T) {
// TODO(miek)
}

View file

@ -13,6 +13,7 @@ import (
)
func TestZoneReload(t *testing.T) {
t.Parallel()
log.SetOutput(ioutil.Discard)
name, rm, err := TempFile(".", exampleOrg)

View file

@ -3,6 +3,7 @@ package test
import "testing"
func TestTempFile(t *testing.T) {
t.Parallel()
_, f, e := TempFile(".", "test")
if e != nil {
t.Fatalf("failed to create temp file: %s", e)

View file

@ -242,6 +242,7 @@ func createTestServer(t *testing.T, corefile string) (*caddy.Instance, string) {
}
func TestKubernetesIntegration(t *testing.T) {
t.Parallel()
corefile :=
`.:0 {
kubernetes cluster.local 0.0.10.in-addr.arpa {

View file

@ -16,6 +16,8 @@ import (
"github.com/miekg/dns"
)
// fail when done in parallel
// Start test server that has metrics enabled. Then tear it down again.
func TestMetricsServer(t *testing.T) {
corefile := `example.org:0 {

View file

@ -12,6 +12,7 @@ import (
)
func TestLookupBalanceRewriteCacheDnssec(t *testing.T) {
t.Parallel()
name, rm, err := test.TempFile(".", exampleOrg)
if err != nil {
t.Fatalf("failed to created zone: %s", err)

View file

@ -13,6 +13,7 @@ import (
)
func TestLookupProxy(t *testing.T) {
t.Parallel()
name, rm, err := test.TempFile(".", exampleOrg)
if err != nil {
t.Fatalf("failed to created zone: %s", err)

View file

@ -3,6 +3,7 @@ package test
import (
"io/ioutil"
"log"
"sync"
"github.com/miekg/coredns/core/dnsserver"
@ -12,8 +13,12 @@ import (
"github.com/mholt/caddy"
)
var mu sync.Mutex
// CoreDNSServer returns a CoreDNS test server. It just takes a normal Corefile as input.
func CoreDNSServer(corefile string) (*caddy.Instance, error) {
mu.Lock()
defer mu.Unlock()
caddy.Quiet = true
dnsserver.Quiet = true
log.SetOutput(ioutil.Discard)

View file

@ -8,6 +8,7 @@ import (
// Start 2 tests server, server A will proxy to B, server B is an CH server.
func TestProxyToChaosServer(t *testing.T) {
t.Parallel()
corefile := `.:0 {
chaos CoreDNS-001 miek@miek.nl
}

View file

@ -13,6 +13,7 @@ import (
)
func TestLookupWildcard(t *testing.T) {
t.Parallel()
name, rm, err := test.TempFile(".", exampleOrg)
if err != nil {
t.Fatalf("failed to created zone: %s", err)