Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

metricsgateway ut panics because of testhelpers/websocket_handler #558 #559

Merged
merged 2 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/autoscaler/metricsgateway/helpers/ws_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ var _ = Describe("WsHelper", func() {
err = wsHelper.SetupConn()
Expect(err).NotTo(HaveOccurred())

err = wsHelper.Ping()
Expect(err).ShouldNot(HaveOccurred())
Eventually(pingPongChan, 5*time.Second, 1*time.Second).Should(Receive(Equal(1)))

})
It("close the websocket connection", func() {
wsHelper.CloseConn()
Expand Down
5 changes: 4 additions & 1 deletion src/autoscaler/testhelpers/websocket_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ func NewWebsocketHandler(m chan []byte, pingPongChan chan int, keepAlive time.Du
func (h *WebsocketHandler) CloseWSConnection() {
h.conLock.Lock()
defer h.conLock.Unlock()
h.wsConn.Close()
if h.wsConn != nil {
h.wsConn.Close()

}
}
func (h *WebsocketHandler) ServeWebsocket(rw http.ResponseWriter, r *http.Request) {
upgrader := websocket.Upgrader{
Expand Down