var apiEndpoint = "127.0.0.1:9091" BeforeEach(func() { logger := loggertesthelper.Logger() cfcomponent.Logger = logger wsReceivedChan = make(chan []byte) server = websocketserver.New(apiEndpoint, sinkManager, 100*time.Millisecond, 100, "dropsonde-origin", logger) go server.Start() serverUrl := fmt.Sprintf("ws://%s/apps/%s/stream", apiEndpoint, appId) websocket.DefaultDialer = &websocket.Dialer{HandshakeTimeout: 10 * time.Millisecond} Eventually(func() error { _, _, err := websocket.DefaultDialer.Dial(serverUrl, http.Header{}); return err }, 1).ShouldNot(HaveOccurred()) }) AfterEach(func() { server.Stop() time.Sleep(time.Millisecond * 10) }) Describe("failed connections", func() { It("fails without an appId", func() { _, connectionDropped = AddWSSink(wsReceivedChan, fmt.Sprintf("ws://%s/apps//stream", apiEndpoint)) Expect(connectionDropped).To(BeClosed()) }) It("fails with bad path", func() { _, connectionDropped = AddWSSink(wsReceivedChan, fmt.Sprintf("ws://%s/apps/my-app/junk", apiEndpoint)) Expect(connectionDropped).To(BeClosed()) }) })
services.Add(1) goRoutineSpawned.Add(1) go func() { goRoutineSpawned.Done() defer services.Done() TestWebsocketServer.Start() }() goRoutineSpawned.Wait() }) AfterEach(func() { sinkManager.Stop() TestMessageRouter.Stop() TestWebsocketServer.Stop() services.Wait() }) It("dumps all messages for an app user", func() { expectedFirstMessageString := "Some data 1" lm := factories.NewLogMessage(events.LogMessage_OUT, expectedFirstMessageString, "myOtherApp", "APP") env1, _ := emitter.Wrap(lm, "ORIGIN") expectedSecondMessageString := "Some data 2" lm = factories.NewLogMessage(events.LogMessage_OUT, expectedSecondMessageString, "myOtherApp", "APP") env2, _ := emitter.Wrap(lm, "ORIGIN") dataReadChannel <- env1 dataReadChannel <- env2