Ejemplo n.º 1
0
func TestThatItSendsAllDataToAllSinks(t *testing.T) {
	client1ReceivedChan := make(chan []byte)
	client2ReceivedChan := make(chan []byte)

	testhelpers.AddWSSink(t, client1ReceivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp", testhelpers.VALID_SPACE_AUTHENTICATION_TOKEN)
	testhelpers.AddWSSink(t, client2ReceivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp", testhelpers.VALID_SPACE_AUTHENTICATION_TOKEN)
	WaitForWebsocketRegistration()

	expectedMessageString := "Some Data"
	expectedMarshalledProtoBuffer := testhelpers.MarshalledLogMessage(t, expectedMessageString, "myApp")

	dataReadChannel <- expectedMarshalledProtoBuffer

	select {
	case <-time.After(200 * time.Millisecond):
		t.Errorf("Did not get message from client 1.")
	case message := <-client1ReceivedChan:
		testhelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, message)
	}

	select {
	case <-time.After(200 * time.Millisecond):
		t.Errorf("Did not get message from client 2.")
	case message := <-client2ReceivedChan:
		testhelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, message)
	}
}
func TestThatItSendsAllDataToAllSinks(t *testing.T) {
	client1ReceivedChan := make(chan []byte)
	client2ReceivedChan := make(chan []byte)

	_, stopKeepAlive1, _ := testhelpers.AddWSSink(t, client1ReceivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp")
	_, stopKeepAlive2, _ := testhelpers.AddWSSink(t, client2ReceivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp")
	WaitForWebsocketRegistration()

	expectedMessageString := "Some Data"
	logEnvelope := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString, "myApp", SECRET)
	dataReadChannel <- logEnvelope

	select {
	case <-time.After(200 * time.Millisecond):
		t.Errorf("Did not get message from client 1.")
	case message := <-client1ReceivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, message)
	}

	select {
	case <-time.After(200 * time.Millisecond):
		t.Errorf("Did not get message from client 2.")
	case message := <-client2ReceivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, message)
	}

	stopKeepAlive1 <- true
	WaitForWebsocketRegistration()

	stopKeepAlive2 <- true
	WaitForWebsocketRegistration()
}
Ejemplo n.º 3
0
func TestQueryStringCombinationsThatDropSinkButContinueToWork(t *testing.T) {
	receivedChan := make(chan []byte, 2)
	_, _, droppedChannel := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?", testhelpers.VALID_SPACE_AUTHENTICATION_TOKEN)
	assert.Equal(t, true, <-droppedChannel)

	TestThatItSends(t)
}
func TestItDumpsAllMessagesForAnAppUser(t *testing.T) {
	expectedMessageString := "Some data"
	logMessage := messagetesthelpers.NewLogMessage(expectedMessageString, "myOtherApp")
	envelope := messagetesthelpers.MarshalledLogEnvelope(t, logMessage, SECRET)

	dataReadChannel <- envelope
	dataReadChannel <- envelope

	time.Sleep(100 * time.Millisecond)

	receivedChan := make(chan []byte, 2)
	_, stopKeepAlive, droppedChannel := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, RECENT_LOGS_PATH+"?app=myOtherApp")

	logMessages := dumpAllMessages(receivedChan)

	assert.Equal(t, len(logMessages), 2)
	messagetesthelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, logMessages[len(logMessages)-1])
	select {
	case <-droppedChannel:
		// we should have been dropped
	case <-time.After(10 * time.Millisecond):
		t.Error("we should have been dropped")
	}
	stopKeepAlive <- true
}
func TestThatItSendsLogsToProperAppSink(t *testing.T) {
	receivedChan := make(chan []byte)

	otherLogMessage := messagetesthelpers.NewLogMessage("Some other message", "otherApp")
	otherLogEnvelope := messagetesthelpers.MarshalledLogEnvelope(t, otherLogMessage, SECRET)

	expectedMessageString := "My important message"
	logEnvelope := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString, "myApp02", SECRET)

	_, stopKeepAlive, _ := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp02")
	WaitForWebsocketRegistration()

	dataReadChannel <- otherLogEnvelope
	dataReadChannel <- logEnvelope

	select {
	case <-time.After(1 * time.Second):
		t.Errorf("Did not get message from app sink.")
	case message := <-receivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, message)
	}

	stopKeepAlive <- true
	WaitForWebsocketRegistration()
}
func TestThatItSends(t *testing.T) {
	receivedChan := make(chan []byte, 2)

	expectedMessageString := "Some data"
	message := messagetesthelpers.NewMessage(t, expectedMessageString, "myApp01")
	otherMessageString := "Some more stuff"
	otherMessage := messagetesthelpers.NewMessage(t, otherMessageString, "myApp01")

	_, dontKeepAliveChan, _ := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, "/tail/?app=myApp01")
	WaitForWebsocketRegistration()

	dataReadChannel <- message
	dataReadChannel <- otherMessage

	select {
	case <-time.After(1 * time.Second):
		t.Errorf("Did not get message 1.")
	case message := <-receivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, message)
	}

	select {
	case <-time.After(1 * time.Second):
		t.Errorf("Did not get message 2.")
	case message := <-receivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, otherMessageString, message)
	}

	dontKeepAliveChan <- true
}
Ejemplo n.º 7
0
func TestThatItDoesNotRegisterADrainIfItsURLIsBlacklisted(t *testing.T) {
	receivedChan := make(chan []byte, 2)
	testhelpers.AddWSSink(t, receivedChan, BLACKLIST_SERVER_PORT, TAIL_PATH+"?app=myApp01")
	WaitForWebsocketRegistration()

	clientReceivedChan := make(chan []byte)

	blackListedSyslogDrain, err := NewFakeService(clientReceivedChan, "127.0.0.1:34570")
	defer blackListedSyslogDrain.Stop()
	assert.NoError(t, err)
	go blackListedSyslogDrain.Serve()
	<-blackListedSyslogDrain.ReadyChan

	logEnvelope1 := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, "Some Data", "myApp01", SECRET, "syslog://127.0.0.1:34570")
	blackListDataReadChannel <- logEnvelope1

	assertMessageNotOnChannel(t, 1000, clientReceivedChan, "Should not have received message on blacklisted Syslog drain")

	select {
	case <-time.After(1 * time.Second):
		t.Errorf("Did not get the real message.")
	case <-receivedChan:
	}

	select {
	case <-time.After(1 * time.Second):
		t.Errorf("Did not get the error message about the blacklisted syslog drain.")
	case receivedMessage := <-receivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, "MessageRouter: Syslog drain url is blacklisted: syslog://127.0.0.1:34570", receivedMessage)
	}
}
func TestThatItDumpsLogsBeforeTailing(t *testing.T) {
	receivedChan := make(chan []byte)

	expectedMessageString := "My important message"
	logEnvelope := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString, "myApp06", SECRET)

	dataReadChannel <- logEnvelope

	_, stopKeepAlive, _ := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp06")
	WaitForWebsocketRegistration()

	select {
	case <-time.After(1 * time.Second):
		t.Errorf("Did not get message from app sink.")
	case message := <-receivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, message)
	}

	expectedMessageString2 := "My Other important message"
	logEnvelope = messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString2, "myApp06", SECRET)

	dataReadChannel <- logEnvelope

	select {
	case <-time.After(1 * time.Second):
		t.Errorf("Did not get message from app sink.")
	case message := <-receivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, expectedMessageString2, message)
	}

	stopKeepAlive <- true
	WaitForWebsocketRegistration()
}
Ejemplo n.º 9
0
func TestThatItSends(t *testing.T) {
	receivedChan := make(chan []byte, 2)

	expectedMessageString := "Some data"
	expectedMessage := testhelpers.MarshalledLogMessage(t, expectedMessageString, "myApp")
	otherMessageString := "Some more stuff"
	otherMessage := testhelpers.MarshalledLogMessage(t, otherMessageString, "myApp")

	testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp", testhelpers.VALID_SPACE_AUTHENTICATION_TOKEN)
	WaitForWebsocketRegistration()

	dataReadChannel <- expectedMessage
	dataReadChannel <- otherMessage

	select {
	case <-time.After(1 * time.Second):
		t.Errorf("Did not get message 1.")
	case message := <-receivedChan:
		testhelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, message)
	}

	select {
	case <-time.After(1 * time.Second):
		t.Errorf("Did not get message 2.")
	case message := <-receivedChan:
		testhelpers.AssertProtoBufferMessageEquals(t, otherMessageString, message)
	}
}
Ejemplo n.º 10
0
func TestDropUnmarshallableMessage(t *testing.T) {
	receivedChan := make(chan []byte)

	sink, stopKeepAlive, _ := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp03")
	WaitForWebsocketRegistration()

	dataReadChannel <- make([]byte, 10)

	time.Sleep(1 * time.Millisecond)
	select {
	case msg1, ok := <-receivedChan:
		if ok {
			t.Errorf("We should not have received a message, but got: %v", msg1)
		}
	default:
		//no communication. That's good!
	}

	sink.Close()
	expectedMessageString := "My important message"
	logEnvelope := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString, "myApp03", SECRET)
	dataReadChannel <- logEnvelope

	stopKeepAlive <- true
	WaitForWebsocketRegistration()
}
Ejemplo n.º 11
0
func TestAuthTokenCombinationsThatDropSinkButContinueToWork(t *testing.T) {
	for _, test := range authTokenFailingCombinationTests {
		receivedChan := make(chan []byte, 2)
		_, _, droppedChannel := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp", test.authToken)
		assert.Equal(t, true, <-droppedChannel)

		TestThatItSends(t)
	}
}
Ejemplo n.º 12
0
func TestDontDropSinkThatWorks(t *testing.T) {
	receivedChan := make(chan []byte, 2)
	_, _, droppedChannel := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp", testhelpers.VALID_SPACE_AUTHENTICATION_TOKEN)

	select {
	case <-time.After(200 * time.Millisecond):
	case <-droppedChannel:
		t.Errorf("Channel drop, but shouldn't have.")
	}

	TestThatItSends(t)
}
func TestItDoesntHangWhenThereAreNoMessages(t *testing.T) {
	receivedChan := make(chan []byte, 1)
	testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, RECENT_LOGS_PATH+"?app=myOtherApp")

	doneChan := make(chan bool)
	go func() {
		dumpAllMessages(receivedChan)
		close(doneChan)
	}()
	select {
	case <-doneChan:
		break
	case <-time.After(10 * time.Millisecond):
		t.Error("Should have returned by now")
	}
}
Ejemplo n.º 14
0
func TestEndtoEndEnvelopeToMessage(t *testing.T) {
	receivedChan := make(chan []byte)
	ws, _, _ := testhelpers.AddWSSink(t, receivedChan, "8083", "/tail/?app=myApp")
	defer ws.Close()
	time.Sleep(50 * time.Millisecond)

	connection, err := net.Dial("udp", "localhost:3456")

	expectedMessageString := "Some Data"
	unmarshalledLogMessage := messagetesthelpers.NewLogMessage(expectedMessageString, "myApp")

	expectedMessage := messagetesthelpers.MarshalledLogEnvelope(t, unmarshalledLogMessage, "secret")

	_, err = connection.Write(expectedMessage)
	assert.NoError(t, err)

	messagetesthelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, <-receivedChan)
}
func TestKeepAlive(t *testing.T) {
	receivedChan := make(chan []byte, 10)

	_, killKeepAliveChan, connectionDroppedChannel := testhelpers.AddWSSink(t, receivedChan, FAST_TIMEOUT_SERVER_PORT, "/tail/?app=myApp05")
	WaitForWebsocketRegistration()

	go func() {
		for {
			expectedMessageString := "My important message"
			message := messagetesthelpers.NewMessage(t, expectedMessageString, "myApp05")
			dataReadChannel <- message
			time.Sleep(2 * time.Millisecond)
		}
	}()

	time.Sleep(10 * time.Millisecond) //wait a little bit to make sure some messages are sent

	killKeepAliveChan <- true

	go func() {
		for {
			select {

			case _, ok := <-receivedChan:
				if !ok {
					// channel closed good!
					break
				}
			case <-time.After(10 * time.Millisecond):
				//no communication. That's good!
				break
			}
		}
	}()

	select {
	case fu := <-connectionDroppedChannel:
		assert.True(t, fu, "We should have been dropped since we stopped the keepalive")
	case <-time.After(1 * time.Second):
		t.Fatal("Should have read from connnectionDropppedChannel by now")
	}

}
Ejemplo n.º 16
0
func TestEndtoEndMessageShouldNotWork(t *testing.T) {
	receivedChan := make(chan []byte)
	ws, _, _ := testhelpers.AddWSSink(t, receivedChan, "8083", "/tail/?app=myApp")
	defer ws.Close()
	time.Sleep(50 * time.Millisecond)

	connection, err := net.Dial("udp", "localhost:3456")

	expectedMessageString := "Some Data"
	expectedMessage := messagetesthelpers.MarshalledLogMessage(t, expectedMessageString, "myApp")

	_, err = connection.Write(expectedMessage)
	assert.NoError(t, err)

	select {
	case _ = <-receivedChan:
		t.Error("Message should have been dropped")
	case <-time.After(2 * time.Second):
		//success
	}
}
Ejemplo n.º 17
0
func TestDropUnmarshallableMessage(t *testing.T) {
	receivedChan := make(chan []byte)

	sink, _, _ := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp", testhelpers.VALID_SPACE_AUTHENTICATION_TOKEN)
	WaitForWebsocketRegistration()

	dataReadChannel <- make([]byte, 10)

	time.Sleep(1 * time.Millisecond)
	select {
	case msg1 := <-receivedChan:
		t.Errorf("We should not have received a message, but got: %v", msg1)
	default:
		//no communication. That's good!
	}

	sink.Close()
	expectedMessageString := "My important message"
	mySpaceMarshalledMessage := testhelpers.MarshalledLogMessage(t, expectedMessageString, "myApp")
	dataReadChannel <- mySpaceMarshalledMessage
}
Ejemplo n.º 18
0
func TestKeepAlive(t *testing.T) {
	receivedChan := make(chan []byte)

	_, killKeepAliveChan, _ := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp", testhelpers.VALID_SPACE_AUTHENTICATION_TOKEN)
	WaitForWebsocketRegistration()

	killKeepAliveChan <- true

	time.Sleep(60 * time.Millisecond) //wait a little bit to make sure the keep-alive has successfully been stopped

	expectedMessageString := "My important message"
	myAppsMarshalledMessage := testhelpers.MarshalledLogMessage(t, expectedMessageString, "myApp")
	dataReadChannel <- myAppsMarshalledMessage

	time.Sleep(10 * time.Millisecond) //wait a little bit to give a potential message time to arrive

	select {
	case msg1 := <-receivedChan:
		t.Errorf("We should not have received a message, but got: %v", msg1)
	default:
		//no communication. That's good!
	}
}
Ejemplo n.º 19
0
func TestEndtoEndMessage(t *testing.T) {
	logger := gosteno.NewLogger("TestLogger")
	listener := agentlistener.NewAgentListener("localhost:3456", logger)
	dataChannel := listener.Start()
	sinkServer := sinkserver.NewSinkServer(messagestore.NewMessageStore(10), logger, testhelpers.SuccessfulAuthorizer, 30*time.Second)
	go sinkServer.Start(dataChannel, "localhost:8081")
	time.Sleep(1 * time.Millisecond)

	receivedChan := make(chan []byte)
	ws, _, _ := testhelpers.AddWSSink(t, receivedChan, "8081", "/tail/?app=myApp", testhelpers.VALID_SPACE_AUTHENTICATION_TOKEN)
	defer ws.Close()
	time.Sleep(50 * time.Millisecond)

	connection, err := net.Dial("udp", "localhost:3456")

	expectedMessageString := "Some Data"
	expectedMessage := testhelpers.MarshalledLogMessage(t, expectedMessageString, "myApp")

	_, err = connection.Write(expectedMessage)
	assert.NoError(t, err)

	testhelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, <-receivedChan)
}
func TestThatItDoesNotDumpLogsBeforeTailing(t *testing.T) {
	receivedChan := make(chan []byte)

	expectedMessageString := "My important message"
	message := messagetesthelpers.NewMessage(t, expectedMessageString, "myApp06")

	dataReadChannel <- message

	_, stopKeepAlive, _ := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, "/tail/?app=myApp06")
	WaitForWebsocketRegistration()

	select {
	case <-time.After(1 * time.Second):
		break
	case _, ok := <-receivedChan:
		if ok {
			t.Errorf("Recieved unexpected message from app sink")
		}
	}

	stopKeepAlive <- true
	WaitForWebsocketRegistration()
}
func TestKeepAlive(t *testing.T) {
	receivedChan := make(chan []byte)

	_, killKeepAliveChan, _ := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp05")
	WaitForWebsocketRegistration()

	killKeepAliveChan <- true

	time.Sleep(60 * time.Millisecond) //wait a little bit to make sure the keep-alive has successfully been stopped

	expectedMessageString := "My important message"
	logEnvelope := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString, "myApp05", SECRET)
	dataReadChannel <- logEnvelope

	select {
	case msg1, ok := <-receivedChan:
		if ok {
			t.Errorf("We should not have received a message, but got: %v", msg1)
		}
	case <-time.After(10 * time.Millisecond):
		//no communication. That's good!
	}
}
Ejemplo n.º 22
0
func TestKeepAlive(t *testing.T) {
	receivedChan := make(chan []byte, 10)

	_, killKeepAliveChan, connectionDroppedChannel := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp05")
	WaitForWebsocketRegistration()

	go func() {
		for {
			expectedMessageString := "My important message"
			logEnvelope := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString, "myApp05", SECRET)
			dataReadChannel <- logEnvelope
			time.Sleep(2 * time.Millisecond)
		}
	}()

	time.Sleep(10 * time.Millisecond) //wait a little bit to make sure some messages are sent

	killKeepAliveChan <- true

	go func() {
		for {
			select {

			case _, ok := <-receivedChan:
				if !ok {
					// channel closed good!
					break
				}
			case <-time.After(10 * time.Millisecond):
				//no communication. That's good!
				break
			}
		}
	}()

	assert.True(t, <-connectionDroppedChannel, "We should have been dropped since we stopped the keepalive")
}
func TestDontDropSinkThatWorks(t *testing.T) {
	receivedChan := make(chan []byte, 2)
	_, stopKeepAlive, droppedChannel := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, "/tail/?app=myApp04")

	select {
	case <-time.After(200 * time.Millisecond):
	case <-droppedChannel:
		t.Errorf("Channel drop, but shouldn't have.")
	}

	expectedMessageString := "Some data"
	message := messagetesthelpers.NewMessage(t, expectedMessageString, "myApp04")
	dataReadChannel <- message

	select {
	case <-time.After(1 * time.Second):
		t.Errorf("Did not get message.")
	case message := <-receivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, message)
	}

	stopKeepAlive <- true
	WaitForWebsocketRegistration()
}
Ejemplo n.º 24
0
func TestItDumpsAllMessagesForAnAppUser(t *testing.T) {
	expectedMessageString := "Some data"
	message := messagetesthelpers.NewMessage(t, expectedMessageString, "myOtherApp")

	dataReadChannel <- message
	dataReadChannel <- message

	receivedChan := make(chan []byte, 2)
	_, stopKeepAlive, droppedChannel := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, "/dump/?app=myOtherApp")

	select {
	case <-droppedChannel:
		// we should have been dropped
	case <-time.After(10 * time.Millisecond):
		t.Error("we should have been dropped")
	}

	logMessages := dumpAllMessages(receivedChan)

	assert.Equal(t, len(logMessages), 2)
	messagetesthelpers.AssertProtoBufferMessageEquals(t, expectedMessageString, logMessages[len(logMessages)-1])

	stopKeepAlive <- true
}
func TestQueryStringCombinationsThatDropSinkButContinueToWork(t *testing.T) {
	receivedChan := make(chan []byte, 2)
	_, _, droppedChannel := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?")
	assert.Equal(t, true, <-droppedChannel)
}
Ejemplo n.º 26
0
func TestMetrics(t *testing.T) {
	oldDumpSinksCounter := TestMessageRouter.Emit().Metrics[0].Value.(int)
	oldSyslogSinksCounter := TestMessageRouter.Emit().Metrics[1].Value.(int)
	oldWebsocketSinksCounter := TestMessageRouter.Emit().Metrics[2].Value.(int)

	clientReceivedChan := make(chan []byte)
	fakeSyslogDrain, err := NewFakeService(clientReceivedChan, "127.0.0.1:32564")
	assert.NoError(t, err)
	go fakeSyslogDrain.Serve()
	<-fakeSyslogDrain.ReadyChan

	assert.Equal(t, TestMessageRouter.Emit().Metrics[0].Name, "numberOfDumpSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[0].Value, oldDumpSinksCounter)

	assert.Equal(t, TestMessageRouter.Emit().Metrics[1].Name, "numberOfSyslogSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[1].Value, oldSyslogSinksCounter)

	assert.Equal(t, TestMessageRouter.Emit().Metrics[2].Name, "numberOfWebsocketSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[2].Value, oldWebsocketSinksCounter)

	logEnvelope := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, "expectedMessageString", "myMetricsApp", SECRET, "syslog://localhost:32564")
	dataReadChannel <- logEnvelope

	select {
	case <-time.After(1000 * time.Millisecond):
		t.Errorf("Did not get message 1")
	case <-clientReceivedChan:
	}

	assert.Equal(t, TestMessageRouter.Emit().Metrics[0].Name, "numberOfDumpSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[0].Value, oldDumpSinksCounter+1)

	assert.Equal(t, TestMessageRouter.Emit().Metrics[1].Name, "numberOfSyslogSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[1].Value, oldSyslogSinksCounter+1)

	assert.Equal(t, TestMessageRouter.Emit().Metrics[2].Name, "numberOfWebsocketSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[2].Value, oldWebsocketSinksCounter)

	dataReadChannel <- logEnvelope

	select {
	case <-time.After(1000 * time.Millisecond):
		t.Errorf("Did not get message 1")
	case <-clientReceivedChan:
	}

	assert.Equal(t, TestMessageRouter.Emit().Metrics[0].Name, "numberOfDumpSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[0].Value, oldDumpSinksCounter+1)

	assert.Equal(t, TestMessageRouter.Emit().Metrics[1].Name, "numberOfSyslogSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[1].Value, oldSyslogSinksCounter+1)

	assert.Equal(t, TestMessageRouter.Emit().Metrics[2].Name, "numberOfWebsocketSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[2].Value, oldWebsocketSinksCounter)

	receivedChan := make(chan []byte, 2)

	_, dontKeepAliveChan, _ := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myMetricsApp")
	WaitForWebsocketRegistration()

	assert.Equal(t, TestMessageRouter.Emit().Metrics[0].Name, "numberOfDumpSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[0].Value, oldDumpSinksCounter+1)

	assert.Equal(t, TestMessageRouter.Emit().Metrics[1].Name, "numberOfSyslogSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[1].Value, oldSyslogSinksCounter+1)

	assert.Equal(t, TestMessageRouter.Emit().Metrics[2].Name, "numberOfWebsocketSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[2].Value, oldWebsocketSinksCounter+1)

	dontKeepAliveChan <- true
	WaitForWebsocketRegistration()

	assert.Equal(t, TestMessageRouter.Emit().Metrics[0].Name, "numberOfDumpSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[0].Value, oldDumpSinksCounter+1)

	assert.Equal(t, TestMessageRouter.Emit().Metrics[1].Name, "numberOfSyslogSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[1].Value, oldSyslogSinksCounter+1)

	assert.Equal(t, TestMessageRouter.Emit().Metrics[2].Name, "numberOfWebsocketSinks")
	assert.Equal(t, TestMessageRouter.Emit().Metrics[2].Value, oldWebsocketSinksCounter)
}