mirror of
https://github.com/golang/go
synced 2024-11-23 18:40:03 -07:00
net: make TestDNSThreadLimit execute at the end of tests
Because TestDNSThreadLimit consumes tons of file descriptors and makes other tests flaky when CGO_ENABLE=0 or being with netgo tag. Fixes #6580. R=golang-dev, bradfitz, adg, minux.ma CC=golang-dev https://golang.org/cl/14639044
This commit is contained in:
parent
8ce584c2aa
commit
f439e07b1b
@ -107,30 +107,6 @@ var googleaddrsipv4 = []string{
|
|||||||
"[0:0:0:0:0:ffff::%d.%d.%d.%d]:80",
|
"[0:0:0:0:0:ffff::%d.%d.%d.%d]:80",
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDNSThreadLimit(t *testing.T) {
|
|
||||||
if testing.Short() || !*testExternal {
|
|
||||||
t.Skip("skipping test to avoid external network")
|
|
||||||
}
|
|
||||||
|
|
||||||
const N = 10000
|
|
||||||
c := make(chan int, N)
|
|
||||||
for i := 0; i < N; i++ {
|
|
||||||
go func(i int) {
|
|
||||||
LookupIP(fmt.Sprintf("%d.net-test.golang.org", i))
|
|
||||||
c <- 1
|
|
||||||
}(i)
|
|
||||||
}
|
|
||||||
// Don't bother waiting for the stragglers; stop at 0.9 N.
|
|
||||||
for i := 0; i < N*9/10; i++ {
|
|
||||||
if i%100 == 0 {
|
|
||||||
//println("TestDNSThreadLimit:", i)
|
|
||||||
}
|
|
||||||
<-c
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we're still here, it worked.
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDialGoogleIPv4(t *testing.T) {
|
func TestDialGoogleIPv4(t *testing.T) {
|
||||||
if testing.Short() || !*testExternal {
|
if testing.Short() || !*testExternal {
|
||||||
t.Skip("skipping test to avoid external network")
|
t.Skip("skipping test to avoid external network")
|
||||||
|
34
src/pkg/net/z_last_test.go
Normal file
34
src/pkg/net/z_last_test.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDNSThreadLimit(t *testing.T) {
|
||||||
|
if testing.Short() || !*testExternal {
|
||||||
|
t.Skip("skipping test to avoid external network")
|
||||||
|
}
|
||||||
|
|
||||||
|
const N = 10000
|
||||||
|
c := make(chan int, N)
|
||||||
|
for i := 0; i < N; i++ {
|
||||||
|
go func(i int) {
|
||||||
|
LookupIP(fmt.Sprintf("%d.net-test.golang.org", i))
|
||||||
|
c <- 1
|
||||||
|
}(i)
|
||||||
|
}
|
||||||
|
// Don't bother waiting for the stragglers; stop at 0.9 N.
|
||||||
|
for i := 0; i < N*9/10; i++ {
|
||||||
|
if i%100 == 0 {
|
||||||
|
//println("TestDNSThreadLimit:", i)
|
||||||
|
}
|
||||||
|
<-c
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're still here, it worked.
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user