diff --git a/app/multitenant/consul_pipe_router_internal_test.go b/app/multitenant/consul_pipe_router_internal_test.go index 32e05466d..2d77132bb 100644 --- a/app/multitenant/consul_pipe_router_internal_test.go +++ b/app/multitenant/consul_pipe_router_internal_test.go @@ -2,14 +2,14 @@ package multitenant import ( "bytes" + "context" "fmt" "io" "log" "math/rand" - "sync" "testing" - "context" + "golang.org/x/sync/errgroup" "github.com/weaveworks/scope/app" "github.com/weaveworks/scope/common/xfer" @@ -38,37 +38,34 @@ type pipeconn struct { func (p *pipeconn) test(t *testing.T) { msg := []byte("hello " + p.id) - wait := sync.WaitGroup{} - wait.Add(2) - - go func() { - defer wait.Done() + wait := errgroup.Group{} + wait.Go(func() error { // write something to the probe end _, err := p.probeIO.Write(msg) - if err != nil { - t.Fatal(err) - } - }() - - go func() { - defer wait.Done() + return err + }) + wait.Go(func() error { // read it back off the other end buf := make([]byte, len(msg)) n, err := p.uiIO.Read(buf) - if n != len(buf) { - t.Fatalf("only read %d", n) - } if err != nil { - t.Fatal(err) + return err + } + if n != len(buf) { + return fmt.Errorf("only read %d", n) } if !bytes.Equal(buf, msg) { - t.Fatalf("Got: %v, Expected: %v", buf, msg) + return fmt.Errorf("Got: %v, Expected: %v", buf, msg) } - }() + return nil + }) - wait.Wait() + err := wait.Wait() + if err != nil { + t.Fatal(err) + } } type pipeTest struct { diff --git a/go.mod b/go.mod index ac29a4c22..5b6f2cf06 100644 --- a/go.mod +++ b/go.mod @@ -82,6 +82,7 @@ require ( github.com/weaveworks/weave v2.3.1-0.20180427133448-4da998ab4507+incompatible github.com/willdonnelly/passwd v0.0.0-20141013001024-7935dab3074c golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 + golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 golang.org/x/text v0.3.1-0.20171227012246-e19ae1496984 // indirect golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 diff --git a/go.sum b/go.sum index d1555f25f..3cc599787 100644 --- a/go.sum +++ b/go.sum @@ -364,6 +364,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180824143301-4910a1d54f87/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/vendor/modules.txt b/vendor/modules.txt index ec9178b07..7d617d60c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -379,6 +379,8 @@ golang.org/x/net/trace # golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be golang.org/x/oauth2 golang.org/x/oauth2/internal +# golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e +golang.org/x/sync/errgroup # golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 golang.org/x/sys/unix golang.org/x/sys/windows