From fcbc168ae67fb418d36dfbe0062f888eee8f246d Mon Sep 17 00:00:00 2001 From: Cenk Alti Date: Tue, 25 Dec 2018 11:23:08 +0300 Subject: [PATCH] add test case for demonstrating panic --- frontend/udp/frontend_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 frontend/udp/frontend_test.go diff --git a/frontend/udp/frontend_test.go b/frontend/udp/frontend_test.go new file mode 100644 index 0000000..b4cff14 --- /dev/null +++ b/frontend/udp/frontend_test.go @@ -0,0 +1,28 @@ +package udp_test + +import ( + "testing" + + "github.com/chihaya/chihaya/frontend/udp" + "github.com/chihaya/chihaya/middleware" + "github.com/chihaya/chihaya/storage" + _ "github.com/chihaya/chihaya/storage/memory" +) + +func TestStartStopRaceIssue437(t *testing.T) { + ps, err := storage.NewPeerStore("memory", nil) + if err != nil { + t.Fatal(err) + } + var responseConfig middleware.ResponseConfig + lgc := middleware.NewLogic(responseConfig, ps, nil, nil) + fe, err := udp.NewFrontend(lgc, udp.Config{Addr: "127.0.0.1:0"}) + if err != nil { + t.Fatal(err) + } + errC := fe.Stop() + errs := <-errC + if len(errs) != 0 { + t.Fatal(errs[0]) + } +}