mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	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:
		| @@ -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") | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -13,6 +13,7 @@ import ( | ||||
| ) | ||||
|  | ||||
| func TestZoneReload(t *testing.T) { | ||||
| 	t.Parallel() | ||||
| 	log.SetOutput(ioutil.Discard) | ||||
|  | ||||
| 	name, rm, err := TempFile(".", exampleOrg) | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
| @@ -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 { | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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 | ||||
| } | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user