Skip to content

Commit

Permalink
fix(trafficcontroller/internal/proxy): Reorganize test setup to preve…
Browse files Browse the repository at this point in the history
…nt race conditions
  • Loading branch information
ctlong committed Feb 22, 2024
1 parent 922e7fd commit d494079
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/trafficcontroller/internal/proxy/websocket_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ var _ = Describe("WebsocketHandler", func() {
keepAlive = 200 * time.Millisecond
count = metricemitter.NewCounter("egress", "")
wc = newWebsocketClient()
})

JustBeforeEach(func() {
wsh := proxy.NewWebsocketHandler(input, keepAlive, count)
handlerDone = make(chan struct{})
ts = httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
Expand All @@ -49,10 +46,13 @@ var _ = Describe("WebsocketHandler", func() {
u.Scheme = "ws"
c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
Expect(err).NotTo(HaveOccurred())
go wc.Start(c)
conn = c
})

JustBeforeEach(func() {
go wc.Start(conn)
})

AfterEach(func() {
select {
case _, ok := <-input:
Expand Down Expand Up @@ -127,7 +127,7 @@ var _ = Describe("WebsocketHandler", func() {
})

Context("when the client doesn't respond to pings for the keep-alive duration", func() {
JustBeforeEach(func() {
BeforeEach(func() {
conn.SetPingHandler(func(string) error { return nil })
})

Expand Down

0 comments on commit d494079

Please sign in to comment.