Commit 2cefd12a authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

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/21614Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
parent f38f43d0
......@@ -6,6 +6,7 @@ package context
import (
"fmt"
"internal/testenv"
"math/rand"
"runtime"
"strings"
......@@ -258,6 +259,9 @@ func TestDeadline(t *testing.T) {
}
func TestTimeout(t *testing.T) {
if runtime.GOOS == "openbsd" {
testenv.SkipFlaky(t, 15158)
}
c, _ := WithTimeout(Background(), 100*time.Millisecond)
if got, prefix := fmt.Sprint(c), "context.Background.WithDeadline("; !strings.HasPrefix(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/iotest": {"L2", "log"},
"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
// you're using L3 packages, use of fmt, log, or time is not a big deal.
......
......@@ -11,6 +11,7 @@
package testenv
import (
"flag"
"os"
"os/exec"
"path/filepath"
......@@ -124,3 +125,11 @@ func MustHaveExternalNetwork(t *testing.T) {
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 {
case "plan9":
t.Skipf("%s does not have full support of socktest", runtime.GOOS)
case "openbsd":
testenv.SkipFlaky(t, 15157)
}
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)
case "windows":
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 {
t.Skip("both IPv4 and IPv6 are required")
......
......@@ -5,7 +5,6 @@
package http_test
import (
"flag"
"fmt"
"net/http"
"os"
......@@ -16,8 +15,6 @@ import (
"time"
)
var flaky = flag.Bool("flaky", false, "run known-flaky tests too")
func TestMain(m *testing.M) {
v := m.Run()
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) {
http.DefaultTransport.(*http.Transport).CloseIdleConnections()
if testing.Short() {
......
......@@ -18,6 +18,7 @@ import (
"crypto/tls"
"errors"
"fmt"
"internal/testenv"
"io"
"io/ioutil"
"log"
......@@ -2229,7 +2230,7 @@ func TestTransportTLSHandshakeTimeout(t *testing.T) {
// Trying to repro golang.org/issue/3514
func TestTLSServerClosesConnection(t *testing.T) {
defer afterTest(t)
setFlaky(t, 7634)
testenv.SkipFlaky(t, 7634)
closedc := make(chan bool, 1)
ts := httptest.NewTLSServer(HandlerFunc(func(w ResponseWriter, r *Request) {
......
......@@ -6,6 +6,7 @@ package net
import (
"fmt"
"internal/testenv"
"io"
"io/ioutil"
"net/internal/socktest"
......@@ -112,6 +113,9 @@ var dialTimeoutMaxDurationTests = []struct {
func TestDialTimeoutMaxDuration(t *testing.T) {
t.Parallel()
if runtime.GOOS == "openbsd" {
testenv.SkipFlaky(t, 15157)
}
ln, err := newLocalListener("tcp")
if err != nil {
......
......@@ -8,6 +8,7 @@ package net
import (
"bytes"
"internal/testenv"
"os"
"reflect"
"runtime"
......@@ -20,6 +21,9 @@ func TestReadUnixgramWithUnnamedSocket(t *testing.T) {
if !testableNetwork("unixgram") {
t.Skip("unixgram test")
}
if runtime.GOOS == "openbsd" {
testenv.SkipFlaky(t, 15157)
}
addr := testUnixAddr()
la, err := ResolveUnixAddr("unixgram", addr)
......
......@@ -585,6 +585,9 @@ func func3(c chan int) { <-c }
func func4(c chan int) { <-c }
func TestGoroutineCounts(t *testing.T) {
if runtime.GOOS == "openbsd" {
testenv.SkipFlaky(t, 15156)
}
c := make(chan int)
for i := 0; i < 100; i++ {
if i%10 == 0 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment