本文整理汇总了Golang中github.com/cloudfoundry/loggregatorlib/logmessage/testhelpers.NewMessage函数的典型用法代码示例。如果您正苦于以下问题:Golang NewMessage函数的具体用法?Golang NewMessage怎么用?Golang NewMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewMessage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestDumpReturnsAllRecentMessagesToMultipleDumpRequests
func TestDumpReturnsAllRecentMessagesToMultipleDumpRequests(t *testing.T) {
var bufferSize uint
bufferSize = 2
dump := NewDumpSink("myApp", bufferSize, loggertesthelper.Logger())
dump.Run()
logMessage := messagetesthelpers.NewMessage(t, "1", "appId")
dump.Channel() <- logMessage
logMessage = messagetesthelpers.NewMessage(t, "2", "appId")
dump.Channel() <- logMessage
logMessage = messagetesthelpers.NewMessage(t, "3", "appId")
dump.Channel() <- logMessage
runtime.Gosched()
logMessages := dumpAllMessages(dump, bufferSize)
assert.Equal(t, len(logMessages), 2)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "2")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "3")
logMessages = dumpAllMessages(dump, bufferSize)
assert.Equal(t, len(logMessages), 2)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "2")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "3")
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:25,代码来源:dump_sink_test.go
示例2: TestThatItSends
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
}
开发者ID:nkuacac,项目名称:loggregator,代码行数:30,代码来源:sinkserver_websocket_test.go
示例3: TestDumpWithLotsOfMessagesAndLargeBuffer
func TestDumpWithLotsOfMessagesAndLargeBuffer(t *testing.T) {
var bufferSize uint
bufferSize = 200
dump := NewDumpSink("myApp", bufferSize, loggertesthelper.Logger())
dump.Run()
for i := 0; i < 1000; i++ {
logMessage := messagetesthelpers.NewMessage(t, strconv.Itoa(i), "appId")
dump.Channel() <- logMessage
}
runtime.Gosched()
logMessages := dumpAllMessages(dump, bufferSize)
assert.Equal(t, len(logMessages), 200)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "800")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "801")
for i := 1000; i < 2000; i++ {
logMessage := messagetesthelpers.NewMessage(t, strconv.Itoa(i), "appId")
dump.Channel() <- logMessage
}
runtime.Gosched()
logMessages = dumpAllMessages(dump, bufferSize)
assert.Equal(t, len(logMessages), 200)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "1800")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "1801")
logMessages = dumpAllMessages(dump, bufferSize)
assert.Equal(t, len(logMessages), 200)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "1800")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "1801")
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:35,代码来源:dump_sink_test.go
示例4: TestSendingToErrorChannelDoesNotBlock
func TestSendingToErrorChannelDoesNotBlock(t *testing.T) {
testMessageRouter := NewMessageRouter(1024, false, nil, loggertesthelper.Logger())
testMessageRouter.errorChannel = make(chan *logmessage.Message, 1)
go testMessageRouter.Start()
sinkChannel := make(chan *logmessage.Message, 10)
ourSink := testSink{sinkChannel, false}
testMessageRouter.sinkOpenChan <- ourSink
<-time.After(1 * time.Millisecond)
for i := 0; i < 10; i++ {
badMessage := messagetesthelpers.NewMessage(t, "error msg", "appIdWeDontCareAbout")
badMessage.GetLogMessage().DrainUrls = []string{fmt.Sprintf("<nil%d>", i)}
testMessageRouter.parsedMessageChan <- badMessage
}
goodMessage := messagetesthelpers.NewMessage(t, "error msg", "appId")
testMessageRouter.parsedMessageChan <- goodMessage
select {
case _ = <-ourSink.Channel():
case <-time.After(1000 * time.Millisecond):
t.Error("Should have received a message")
}
}
开发者ID:pxie,项目名称:loggregator,代码行数:26,代码来源:message_router_test.go
示例5: TestDumpReturnsAllRecentMessagesToMultipleDumpRequestsWithMessagesCloningInInTheMeantime
func TestDumpReturnsAllRecentMessagesToMultipleDumpRequestsWithMessagesCloningInInTheMeantime(t *testing.T) {
dump := NewDumpSink("myApp", 2, loggertesthelper.Logger(), make(chan Sink, 1), time.Second)
go dump.Run()
logMessage := messagetesthelpers.NewMessage(t, "1", "appId")
dump.Channel() <- logMessage
logMessage = messagetesthelpers.NewMessage(t, "2", "appId")
dump.Channel() <- logMessage
logMessage = messagetesthelpers.NewMessage(t, "3", "appId")
dump.Channel() <- logMessage
runtime.Gosched()
logMessages := dump.Dump()
assert.Equal(t, len(logMessages), 2)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "2")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "3")
logMessage = messagetesthelpers.NewMessage(t, "4", "appId")
dump.Channel() <- logMessage
runtime.Gosched()
logMessages = dump.Dump()
assert.Equal(t, len(logMessages), 2)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "3")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "4")
}
开发者ID:james-masson,项目名称:loggregator,代码行数:29,代码来源:dump_sink_test.go
示例6: TestDumpsMostRecentMessagesWithSmallerOutputChan
func TestDumpsMostRecentMessagesWithSmallerOutputChan(t *testing.T) {
var bufferSize uint
bufferSize = 4
dump := NewDumpSink("myApp", bufferSize, loggertesthelper.Logger())
dump.Run()
logMessage := messagetesthelpers.NewMessage(t, "1", "appId")
dump.Channel() <- logMessage
logMessage = messagetesthelpers.NewMessage(t, "2", "appId")
dump.Channel() <- logMessage
logMessage = messagetesthelpers.NewMessage(t, "3", "appId")
dump.Channel() <- logMessage
logMessage = messagetesthelpers.NewMessage(t, "4", "appId")
dump.Channel() <- logMessage
runtime.Gosched()
receivedChan := make(chan *logmessage.Message, 2)
dump.Dump(receivedChan)
firstMessage := <-receivedChan
assert.Equal(t, string(firstMessage.GetLogMessage().GetMessage()), "3")
secondMessage := <-receivedChan
assert.Equal(t, string(secondMessage.GetLogMessage().GetMessage()), "4")
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:28,代码来源:dump_sink_test.go
示例7: TestDumpWithLotsOfMessages
func TestDumpWithLotsOfMessages(t *testing.T) {
dump := NewDumpSink("myApp", 2, loggertesthelper.Logger())
for i := 0; i < 100; i++ {
logMessage := messagetesthelpers.NewMessage(t, strconv.Itoa(i), "appId")
dump.Channel() <- logMessage
}
runtime.Gosched()
logMessages := dumpAllMessages(dump)
assert.Equal(t, len(logMessages), 2)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "98")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "99")
for i := 100; i < 200; i++ {
logMessage := messagetesthelpers.NewMessage(t, strconv.Itoa(i), "appId")
dump.Channel() <- logMessage
}
runtime.Gosched()
logMessages = dumpAllMessages(dump)
assert.Equal(t, len(logMessages), 2)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "198")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "199")
logMessages = dumpAllMessages(dump)
assert.Equal(t, len(logMessages), 2)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "198")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "199")
}
开发者ID:pxie,项目名称:loggregator,代码行数:32,代码来源:dump_sink_test.go
示例8: TestStopsRetryingWhenSinkIsUnregistered
func TestStopsRetryingWhenSinkIsUnregistered(t *testing.T) {
testMessageRouter := NewMessageRouter(1024, false, []iprange.IPRange{iprange.IPRange{Start: "10.10.123.1", End: "10.10.123.1"}}, loggertesthelper.Logger())
go testMessageRouter.Start()
ourSink := testSink{make(chan *logmessage.Message, 100), true}
testMessageRouter.sinkOpenChan <- ourSink
runtime.Gosched()
go func() {
message := messagetesthelpers.NewMessage(t, "error msg", "appId")
message.GetLogMessage().DrainUrls = []string{"syslog://localhost:41223"}
testMessageRouter.parsedMessageChan <- message
newMessage := messagetesthelpers.NewMessage(t, "RemoveSyslogSink", "appId")
testMessageRouter.parsedMessageChan <- newMessage
}()
for {
readMessage := <-ourSink.Channel()
if string(readMessage.GetLogMessage().GetMessage()) == "RemoveSyslogSink" {
break
}
}
select {
case message := <-ourSink.Channel():
t.Errorf("Should not receive another message after removal; message was %v", string(message.GetLogMessage().GetMessage()))
case <-time.After(2 * time.Second):
}
}
开发者ID:pxie,项目名称:loggregator,代码行数:31,代码来源:message_router_test.go
示例9: TestDumpWithLotsOfMessagesAndLargeBuffer
func TestDumpWithLotsOfMessagesAndLargeBuffer(t *testing.T) {
dump := NewDumpSink("myApp", 200, loggertesthelper.Logger(), make(chan Sink, 1), time.Second)
go dump.Run()
for i := 0; i < 1000; i++ {
logMessage := messagetesthelpers.NewMessage(t, strconv.Itoa(i), "appId")
dump.Channel() <- logMessage
}
runtime.Gosched()
logMessages := dump.Dump()
assert.Equal(t, len(logMessages), 200)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "800")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "801")
for i := 1000; i < 2000; i++ {
logMessage := messagetesthelpers.NewMessage(t, strconv.Itoa(i), "appId")
dump.Channel() <- logMessage
}
runtime.Gosched()
logMessages = dump.Dump()
assert.Equal(t, len(logMessages), 200)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "1800")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "1801")
logMessages = dump.Dump()
assert.Equal(t, len(logMessages), 200)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "1800")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "1801")
}
开发者ID:james-masson,项目名称:loggregator,代码行数:34,代码来源:dump_sink_test.go
示例10: TestDumpAlwaysReturnsTheNewestMessages
func TestDumpAlwaysReturnsTheNewestMessages(t *testing.T) {
dump := NewDumpSink("myApp", 2, loggertesthelper.Logger(), time.Second, fakeTimeProvider)
dumpRunnerDone := make(chan struct{})
inputChan := make(chan *logmessage.Message)
go func() {
dump.Run(inputChan)
close(dumpRunnerDone)
}()
logMessage := messagetesthelpers.NewMessage(t, "1", "appId")
inputChan <- logMessage
logMessage = messagetesthelpers.NewMessage(t, "2", "appId")
inputChan <- logMessage
logMessage = messagetesthelpers.NewMessage(t, "3", "appId")
inputChan <- logMessage
close(inputChan)
<-dumpRunnerDone
logMessages := dump.Dump()
assert.Equal(t, len(logMessages), 2)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "2")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "3")
}
开发者ID:nkuacac,项目名称:loggregator,代码行数:28,代码来源:dump_sink_test.go
示例11: TestSimpleBlacklistRule
func TestSimpleBlacklistRule(t *testing.T) {
logger := loggertesthelper.Logger()
sinkManager := NewSinkManager(1024, false, []iprange.IPRange{iprange.IPRange{Start: "10.10.123.1", End: "10.10.123.1"}}, logger)
oldActiveSyslogSinksCounter := sinkManager.Metrics.SyslogSinks
go sinkManager.Start()
incomingLogChan := make(chan []byte, 10)
testMessageRouter := NewMessageRouter(incomingLogChan, testhelpers.UnmarshallerMaker("secret"), sinkManager, 2048, logger)
go testMessageRouter.Start()
ourSink := testSink{make(chan *logmessage.Message, 100), true}
sinkManager.sinkOpenChan <- ourSink
<-time.After(1 * time.Millisecond)
message := messagetesthelpers.NewMessage(t, "error msg", "appId")
message.GetLogMessage().DrainUrls = []string{"http://10.10.123.1"}
testMessageRouter.outgoingLogChan <- message
select {
case _ = <-ourSink.Channel():
case <-time.After(100 * time.Millisecond):
t.Error("Did not receive real message")
}
select {
case _ = <-ourSink.Channel():
case <-time.After(100 * time.Millisecond):
t.Error("Did not message about blacklisted syslog drain")
}
testMessageRouter.outgoingLogChan <- message
select {
case _ = <-ourSink.Channel():
case <-time.After(100 * time.Millisecond):
t.Error("Did not receive real message")
}
select {
case _ = <-ourSink.Channel():
t.Error("Should not receive another message about the blacklisted url since we cache blacklisted urls")
case <-time.After(100 * time.Millisecond):
}
assert.Equal(t, sinkManager.Metrics.SyslogSinks, oldActiveSyslogSinksCounter)
message = messagetesthelpers.NewMessage(t, "error msg", "appId")
message.GetLogMessage().DrainUrls = []string{"http://10.10.123.2"}
testMessageRouter.outgoingLogChan <- message
waitForMessageGettingProcessed(t, ourSink, 10*time.Millisecond)
assert.Equal(t, sinkManager.Metrics.SyslogSinks, oldActiveSyslogSinksCounter+1)
}
开发者ID:james-masson,项目名称:loggregator,代码行数:53,代码来源:message_router_test.go
示例12: TestSysLoggerDiesAndComesBack
func TestSysLoggerDiesAndComesBack(t *testing.T) {
sysLogger := NewSyslogWriterRecorder()
sink := NewSyslogSink("appId", "url_not_used", loggertesthelper.Logger(), sysLogger, make(chan *logmessage.Message))
sysLogger.SetUp(true)
done := make(chan bool)
go func() {
sink.Run()
done <- true
}()
msg := fmt.Sprintf("first message")
logMessage := messagetesthelpers.NewMessage(t, msg, "appId")
sink.Channel() <- logMessage
select {
case <-sysLogger.receivedChannel:
break
case <-time.After(10 * time.Millisecond):
t.Error("Should have received a message by now")
}
sysLogger.SetUp(false)
assert.Equal(t, len(sysLogger.ReceivedMessages()), 1)
for i := 0; i < 11; i++ {
msg := fmt.Sprintf("message no %v", i)
logMessage := messagetesthelpers.NewMessage(t, msg, "appId")
sink.Channel() <- logMessage
}
sysLogger.SetUp(true)
close(sink.Channel())
<-done
assert.Equal(t, len(sysLogger.ReceivedMessages()), 11)
stringOfMessages := fmt.Sprintf("%v", sysLogger.ReceivedMessages())
assert.Contains(t, stringOfMessages, "first message", "This message should have been there, since the server was up")
assert.NotContains(t, stringOfMessages, "out: message no 0", "This message should have been lost because the connection problem was detected while trying to send it.")
assert.Contains(t, stringOfMessages, "out: message no 1", "This message should have been there, since it was in the ringbuffer while the server was down")
assert.Contains(t, stringOfMessages, "out: message no 2", "This message should have been there, since it was in the ringbuffer while the server was down")
assert.Contains(t, stringOfMessages, "out: message no 3", "This message should have been there, since it was in the ringbuffer while the server was down")
assert.Contains(t, stringOfMessages, "out: message no 4", "This message should have been there, since it was in the ringbuffer while the server was down")
assert.Contains(t, stringOfMessages, "out: message no 5", "This message should have been there, since it was in the ringbuffer while the server was down")
assert.Contains(t, stringOfMessages, "out: message no 6", "This message should have been there, since it was in the ringbuffer while the server was down")
assert.Contains(t, stringOfMessages, "out: message no 7", "This message should have been there, since it was in the ringbuffer while the server was down")
assert.Contains(t, stringOfMessages, "out: message no 8", "This message should have been there, since it was in the ringbuffer while the server was down")
assert.Contains(t, stringOfMessages, "out: message no 9", "This message should have been there, since it was in the ringbuffer while the server was down")
assert.Contains(t, stringOfMessages, "out: message no 10", "This message should have been there, since it was in the ringbuffer while the server was down")
}
开发者ID:pxie,项目名称:loggregator,代码行数:52,代码来源:syslog_sink_test.go
示例13: TestBufferDropsOldMessages
func TestBufferDropsOldMessages(t *testing.T) {
channel, buffer := setup(1)
message1 := messagetesthelpers.NewMessage(t, "message 1", "appId")
channel <- message1
message2 := messagetesthelpers.NewMessage(t, "message 2", "appId")
channel <- message2
close(channel)
buffer.waitForClose()
dump := buffer.Dump()
assert.Equal(t, 1, len(dump))
assert.Equal(t, message2, dump[0])
}
开发者ID:james-masson,项目名称:loggregator,代码行数:14,代码来源:dumpable_ring_buffer_test.go
示例14: TestDumpWithLotsOfMessagesAndLargeBuffer
func TestDumpWithLotsOfMessagesAndLargeBuffer(t *testing.T) {
dump := NewDumpSink("myApp", 200, loggertesthelper.Logger(), time.Second, fakeTimeProvider)
dumpRunnerDone := make(chan struct{})
inputChan := make(chan *logmessage.Message)
go func() {
dump.Run(inputChan)
close(dumpRunnerDone)
}()
for i := 0; i < 1000; i++ {
logMessage := messagetesthelpers.NewMessage(t, strconv.Itoa(i), "appId")
inputChan <- logMessage
}
close(inputChan)
<-dumpRunnerDone
logMessages := dump.Dump()
assert.Equal(t, len(logMessages), 200)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "800")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "801")
dumpRunnerDone = make(chan struct{})
inputChan = make(chan *logmessage.Message)
go func() {
dump.Run(inputChan)
close(dumpRunnerDone)
}()
for i := 1000; i < 2000; i++ {
logMessage := messagetesthelpers.NewMessage(t, strconv.Itoa(i), "appId")
inputChan <- logMessage
}
close(inputChan)
<-dumpRunnerDone
logMessages = dump.Dump()
assert.Equal(t, len(logMessages), 200)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "1800")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "1801")
logMessages = dump.Dump()
assert.Equal(t, len(logMessages), 200)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "1800")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "1801")
}
开发者ID:nkuacac,项目名称:loggregator,代码行数:50,代码来源:dump_sink_test.go
示例15: TestThatItWorksLikeAChannel
func TestThatItWorksLikeAChannel(t *testing.T) {
inMessageChan := make(chan *logmessage.Message)
buffer := NewTruncatingBuffer(inMessageChan, 2, nil)
go buffer.Run()
logMessage1 := messagetesthelpers.NewMessage(t, "message 1", "appId")
inMessageChan <- logMessage1
readMessage := <-buffer.GetOutputChannel()
assert.Contains(t, string(readMessage.GetRawMessage()), "message 1")
logMessage2 := messagetesthelpers.NewMessage(t, "message 2", "appId")
inMessageChan <- logMessage2
readMessage2 := <-buffer.GetOutputChannel()
assert.Contains(t, string(readMessage2.GetRawMessage()), "message 2")
}
开发者ID:james-masson,项目名称:loggregator,代码行数:15,代码来源:truncating_buffer_test.go
示例16: TestBufferDropsOldMessages
func TestBufferDropsOldMessages(t *testing.T) {
channel, buffer := setup(1)
message1 := messagetesthelpers.NewMessage(t, "message 1", "appId")
channel <- message1
message2 := messagetesthelpers.NewMessage(t, "message 2", "appId")
channel <- message2
close(channel)
buffer.WaitForClose()
dumpChan := make(chan *logmessage.Message, 10)
buffer.Dump(dumpChan)
assert.Equal(t, 1, len(dumpChan))
assert.Equal(t, message2, <-dumpChan)
}
开发者ID:pxie,项目名称:loggregator,代码行数:15,代码来源:dumpable_ring_buffer_test.go
示例17: TestDumpForTwoMessages
func TestDumpForTwoMessages(t *testing.T) {
dump := NewDumpSink("myApp", 2, loggertesthelper.Logger())
logMessage := messagetesthelpers.NewMessage(t, "1", "appId")
dump.Channel() <- logMessage
logMessage = messagetesthelpers.NewMessage(t, "2", "appId")
dump.Channel() <- logMessage
runtime.Gosched()
logMessages := dumpAllMessages(dump)
assert.Equal(t, len(logMessages), 2)
assert.Equal(t, string(logMessages[0].GetLogMessage().GetMessage()), "1")
assert.Equal(t, string(logMessages[1].GetLogMessage().GetMessage()), "2")
}
开发者ID:pxie,项目名称:loggregator,代码行数:15,代码来源:dump_sink_test.go
示例18: TestInputChannelAddToBuffer
func TestInputChannelAddToBuffer(t *testing.T) {
channel, buffer := setup(10)
message1 := messagetesthelpers.NewMessage(t, "message 1", "appId")
channel <- message1
message2 := messagetesthelpers.NewMessage(t, "message 2", "appId")
channel <- message2
close(channel)
buffer.waitForClose()
dump := buffer.Dump()
assert.Equal(t, 2, len(dump))
assert.Equal(t, message1, dump[0])
assert.Equal(t, message2, dump[1])
}
开发者ID:james-masson,项目名称:loggregator,代码行数:15,代码来源:dumpable_ring_buffer_test.go
示例19: TestSysLoggerComesUpLate
func TestSysLoggerComesUpLate(t *testing.T) {
sysLogger := NewSyslogWriterRecorder()
sysLogger.SetUp(false)
sink := NewSyslogSink("appId", "url_not_used", loggertesthelper.Logger(), sysLogger)
done := make(chan bool)
go func() {
sink.Run()
done <- true
}()
for i := 0; i < 15; i++ {
msg := fmt.Sprintf("message no %v", i)
logMessage := messagetesthelpers.NewMessage(t, msg, "appId")
sink.Channel() <- logMessage
}
close(sink.Channel())
sysLogger.SetUp(true)
<-done
data := sysLogger.ReceivedMessages()
assert.Equal(t, len(data), 10)
for i := 0; i < 10; i++ {
msg := fmt.Sprintf("out: message no %v", i+5)
assert.Equal(t, data[i], msg)
}
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:30,代码来源:syslog_sink_test.go
示例20: xTestDumpSinkClosingTimeIsResetWhenAMessageArrives
func xTestDumpSinkClosingTimeIsResetWhenAMessageArrives(t *testing.T) {
dump := NewDumpSink("myApp", 5, loggertesthelper.Logger(), 10*time.Millisecond, fakeTimeProvider)
dumpRunnerDone := make(chan struct{})
inputChan := make(chan *logmessage.Message)
go func() {
dump.Run(inputChan)
close(dumpRunnerDone)
}()
fakeTimeProvider.IncrementBySeconds(uint64(5))
logMessage := messagetesthelpers.NewMessage(t, "0", "appId")
inputChan <- logMessage
fakeTimeProvider.IncrementBySeconds(uint64(8))
fakeTimeProvider.IncrementBySeconds(uint64(3))
select {
case sink := <-dumpRunnerDone:
assert.Equal(t, sink, dump)
case <-time.After(5 * time.Millisecond):
assert.Fail(t, "Should have closed")
}
}
开发者ID:nkuacac,项目名称:loggregator,代码行数:25,代码来源:dump_sink_test.go
注:本文中的github.com/cloudfoundry/loggregatorlib/logmessage/testhelpers.NewMessage函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论