pkg/listenmux: resolve deadlock in test

it was possible, because we spawned Run before we did any calls
to Route, that the listenmux would send multiple connections to
the default listener. Fix that by ensuring we call Route before
we call Run.

Change-Id: Ie8fd754997975969a99fd2a3f8d3010c24cdc73d
This commit is contained in:
Jeff Wendling 2019-09-20 14:42:14 -06:00
parent a20a7db793
commit d32d85a717

View File

@ -44,13 +44,14 @@ func TestMux(t *testing.T) {
mux := New(lis, len("prefixN"))
var muxGroup errgroup.Group
muxGroup.Go(func() error { return mux.Run(ctx) })
var lisGroup errgroup.Group
lisGroup.Go(expect(mux.Route("prefix1"), "data1"))
lisGroup.Go(expect(mux.Route("prefix2"), "data2"))
lisGroup.Go(expect(mux.Default(), "prefix3data3"))
var muxGroup errgroup.Group
muxGroup.Go(func() error { return mux.Run(ctx) })
require.NoError(t, lisGroup.Wait())
cancel()