mirror of
https://github.com/golang/go
synced 2024-11-19 02:04:42 -07:00
net, runtime: skip flaky tests on OpenBSD
Flaky tests are a distraction and cover up real problems. File bugs instead and mark them as flaky. This moves the net/http flaky test flagging mechanism to internal/testenv. Updates #15156 Updates #15157 Updates #15158 Change-Id: I0e561cd2a09c0dec369cd4ed93bc5a2b40233dfe Reviewed-on: https://go-review.googlesource.com/21614 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
f38f43d029
commit
2cefd12a1b
@ -6,6 +6,7 @@ package context
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"internal/testenv"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@ -258,6 +259,9 @@ func TestDeadline(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTimeout(t *testing.T) {
|
func TestTimeout(t *testing.T) {
|
||||||
|
if runtime.GOOS == "openbsd" {
|
||||||
|
testenv.SkipFlaky(t, 15158)
|
||||||
|
}
|
||||||
c, _ := WithTimeout(Background(), 100*time.Millisecond)
|
c, _ := WithTimeout(Background(), 100*time.Millisecond)
|
||||||
if got, prefix := fmt.Sprint(c), "context.Background.WithDeadline("; !strings.HasPrefix(got, prefix) {
|
if got, prefix := fmt.Sprint(c), "context.Background.WithDeadline("; !strings.HasPrefix(got, prefix) {
|
||||||
t.Errorf("c.String() = %q want prefix %q", got, prefix)
|
t.Errorf("c.String() = %q want prefix %q", got, prefix)
|
||||||
|
@ -168,7 +168,7 @@ var pkgDeps = map[string][]string{
|
|||||||
"testing": {"L2", "flag", "fmt", "os", "runtime/debug", "runtime/pprof", "runtime/trace", "time"},
|
"testing": {"L2", "flag", "fmt", "os", "runtime/debug", "runtime/pprof", "runtime/trace", "time"},
|
||||||
"testing/iotest": {"L2", "log"},
|
"testing/iotest": {"L2", "log"},
|
||||||
"testing/quick": {"L2", "flag", "fmt", "reflect"},
|
"testing/quick": {"L2", "flag", "fmt", "reflect"},
|
||||||
"internal/testenv": {"L2", "OS", "testing"},
|
"internal/testenv": {"L2", "OS", "flag", "testing"},
|
||||||
|
|
||||||
// L4 is defined as L3+fmt+log+time, because in general once
|
// L4 is defined as L3+fmt+log+time, because in general once
|
||||||
// you're using L3 packages, use of fmt, log, or time is not a big deal.
|
// you're using L3 packages, use of fmt, log, or time is not a big deal.
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
package testenv
|
package testenv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -124,3 +125,11 @@ func MustHaveExternalNetwork(t *testing.T) {
|
|||||||
t.Skipf("skipping test: no external network in -short mode")
|
t.Skipf("skipping test: no external network in -short mode")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var flaky = flag.Bool("flaky", false, "run known-flaky tests too")
|
||||||
|
|
||||||
|
func SkipFlaky(t *testing.T, issue int) {
|
||||||
|
if !*flaky {
|
||||||
|
t.Skipf("skipping known flaky test without the -flaky flag; see golang.org/issue/%d", issue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -59,6 +59,8 @@ func TestDialTimeoutFDLeak(t *testing.T) {
|
|||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "plan9":
|
case "plan9":
|
||||||
t.Skipf("%s does not have full support of socktest", runtime.GOOS)
|
t.Skipf("%s does not have full support of socktest", runtime.GOOS)
|
||||||
|
case "openbsd":
|
||||||
|
testenv.SkipFlaky(t, 15157)
|
||||||
}
|
}
|
||||||
|
|
||||||
const T = 100 * time.Millisecond
|
const T = 100 * time.Millisecond
|
||||||
@ -126,6 +128,8 @@ func TestDialerDualStackFDLeak(t *testing.T) {
|
|||||||
t.Skipf("%s does not have full support of socktest", runtime.GOOS)
|
t.Skipf("%s does not have full support of socktest", runtime.GOOS)
|
||||||
case "windows":
|
case "windows":
|
||||||
t.Skipf("not implemented a way to cancel dial racers in TCP SYN-SENT state on %s", runtime.GOOS)
|
t.Skipf("not implemented a way to cancel dial racers in TCP SYN-SENT state on %s", runtime.GOOS)
|
||||||
|
case "openbsd":
|
||||||
|
testenv.SkipFlaky(t, 15157)
|
||||||
}
|
}
|
||||||
if !supportsIPv4 || !supportsIPv6 {
|
if !supportsIPv4 || !supportsIPv6 {
|
||||||
t.Skip("both IPv4 and IPv6 are required")
|
t.Skip("both IPv4 and IPv6 are required")
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
package http_test
|
package http_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -16,8 +15,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var flaky = flag.Bool("flaky", false, "run known-flaky tests too")
|
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
v := m.Run()
|
v := m.Run()
|
||||||
if v == 0 && goroutineLeaked() {
|
if v == 0 && goroutineLeaked() {
|
||||||
@ -91,12 +88,6 @@ func setParallel(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setFlaky(t *testing.T, issue int) {
|
|
||||||
if !*flaky {
|
|
||||||
t.Skipf("skipping known flaky test; see golang.org/issue/%d", issue)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func afterTest(t testing.TB) {
|
func afterTest(t testing.TB) {
|
||||||
http.DefaultTransport.(*http.Transport).CloseIdleConnections()
|
http.DefaultTransport.(*http.Transport).CloseIdleConnections()
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"internal/testenv"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
@ -2229,7 +2230,7 @@ func TestTransportTLSHandshakeTimeout(t *testing.T) {
|
|||||||
// Trying to repro golang.org/issue/3514
|
// Trying to repro golang.org/issue/3514
|
||||||
func TestTLSServerClosesConnection(t *testing.T) {
|
func TestTLSServerClosesConnection(t *testing.T) {
|
||||||
defer afterTest(t)
|
defer afterTest(t)
|
||||||
setFlaky(t, 7634)
|
testenv.SkipFlaky(t, 7634)
|
||||||
|
|
||||||
closedc := make(chan bool, 1)
|
closedc := make(chan bool, 1)
|
||||||
ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) {
|
ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) {
|
||||||
|
@ -6,6 +6,7 @@ package net
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"internal/testenv"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/internal/socktest"
|
"net/internal/socktest"
|
||||||
@ -112,6 +113,9 @@ var dialTimeoutMaxDurationTests = []struct {
|
|||||||
|
|
||||||
func TestDialTimeoutMaxDuration(t *testing.T) {
|
func TestDialTimeoutMaxDuration(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
if runtime.GOOS == "openbsd" {
|
||||||
|
testenv.SkipFlaky(t, 15157)
|
||||||
|
}
|
||||||
|
|
||||||
ln, err := newLocalListener("tcp")
|
ln, err := newLocalListener("tcp")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -8,6 +8,7 @@ package net
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"internal/testenv"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -20,6 +21,9 @@ func TestReadUnixgramWithUnnamedSocket(t *testing.T) {
|
|||||||
if !testableNetwork("unixgram") {
|
if !testableNetwork("unixgram") {
|
||||||
t.Skip("unixgram test")
|
t.Skip("unixgram test")
|
||||||
}
|
}
|
||||||
|
if runtime.GOOS == "openbsd" {
|
||||||
|
testenv.SkipFlaky(t, 15157)
|
||||||
|
}
|
||||||
|
|
||||||
addr := testUnixAddr()
|
addr := testUnixAddr()
|
||||||
la, err := ResolveUnixAddr("unixgram", addr)
|
la, err := ResolveUnixAddr("unixgram", addr)
|
||||||
|
@ -585,6 +585,9 @@ func func3(c chan int) { <-c }
|
|||||||
func func4(c chan int) { <-c }
|
func func4(c chan int) { <-c }
|
||||||
|
|
||||||
func TestGoroutineCounts(t *testing.T) {
|
func TestGoroutineCounts(t *testing.T) {
|
||||||
|
if runtime.GOOS == "openbsd" {
|
||||||
|
testenv.SkipFlaky(t, 15156)
|
||||||
|
}
|
||||||
c := make(chan int)
|
c := make(chan int)
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
if i%10 == 0 {
|
if i%10 == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user