• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang testhelpers.MarshalledLogEnvelopeForMessage函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cloudfoundry/loggregatorlib/logmessage/testhelpers.MarshalledLogEnvelopeForMessage函数的典型用法代码示例。如果您正苦于以下问题:Golang MarshalledLogEnvelopeForMessage函数的具体用法?Golang MarshalledLogEnvelopeForMessage怎么用?Golang MarshalledLogEnvelopeForMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MarshalledLogEnvelopeForMessage函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestThatItSends

func TestThatItSends(t *testing.T) {
	receivedChan := make(chan []byte, 2)

	expectedMessageString := "Some data"
	logEnvelope := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString, "myApp01", SECRET)
	otherMessageString := "Some more stuff"
	otherLogEnvelope := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, otherMessageString, "myApp01", SECRET)

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

	dataReadChannel <- logEnvelope
	dataReadChannel <- otherLogEnvelope

	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:uabassguy,项目名称:loggregator,代码行数:30,代码来源:sinkserver_websocket_test.go


示例2: TestThatItSendsAllMessageToKnownDrains

func TestThatItSendsAllMessageToKnownDrains(t *testing.T) {
	client1ReceivedChan := make(chan []byte)

	fakeSyslogDrain, err := NewFakeService(client1ReceivedChan, "127.0.0.1:34566")
	defer fakeSyslogDrain.Stop()
	assert.NoError(t, err)
	go fakeSyslogDrain.Serve()
	<-fakeSyslogDrain.ReadyChan

	expectedMessageString := "Some Data"
	logEnvelope1 := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString, "myApp", SECRET, "syslog://localhost:34566")

	expectedSecondMessageString := "Some Data Without a drainurl"
	logEnvelope2 := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedSecondMessageString, "myApp", SECRET, "syslog://localhost:34566")

	dataReadChannel <- logEnvelope1

	select {
	case <-time.After(200 * time.Millisecond):
		t.Errorf("Did not get the first message")
	case message := <-client1ReceivedChan:
		assert.Contains(t, string(message), expectedMessageString)
	}

	dataReadChannel <- logEnvelope2

	select {
	case <-time.After(200 * time.Millisecond):
		t.Errorf("Did not get the second message")
	case message := <-client1ReceivedChan:
		assert.Contains(t, string(message), expectedSecondMessageString)
	}
}
开发者ID:pxie,项目名称:loggregator,代码行数:33,代码来源:sinkserver_syslog_test.go


示例3: TestThatItDumpsLogsBeforeTailing

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()
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:33,代码来源:sinkserver_websocket_test.go


示例4: TestThatItReestablishesConnectionToSinks

func TestThatItReestablishesConnectionToSinks(t *testing.T) {
	client1ReceivedChan := make(chan []byte)

	fakeSyslogDrain, err := NewFakeService(client1ReceivedChan, "127.0.0.1:34569")
	assert.NoError(t, err)
	go fakeSyslogDrain.Serve()
	<-fakeSyslogDrain.ReadyChan

	expectedMessageString1 := "Some Data 1"
	logEnvelope := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString1, "myApp", SECRET, "syslog://localhost:34569")
	dataReadChannel <- logEnvelope

	errorString := "Did not get the first message. Server was up, it should have been there"
	AssertMessageOnChannel(t, 200, client1ReceivedChan, errorString, expectedMessageString1)
	fakeSyslogDrain.Stop()
	time.Sleep(50 * time.Millisecond)

	expectedMessageString2 := "Some Data 2"
	logEnvelope = messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString2, "myApp", SECRET, "syslog://localhost:34569")
	dataReadChannel <- logEnvelope
	errorString = "Did get a second message! Shouldn't be since the server is down"
	AssertMessageNotOnChannel(t, 200, client1ReceivedChan, errorString)

	expectedMessageString3 := "Some Data 3"
	logEnvelope = messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString3, "myApp", SECRET, "syslog://localhost:34569")
	dataReadChannel <- logEnvelope
	errorString = "Did get a third message! Shouldn't be since the server is down"
	AssertMessageNotOnChannel(t, 200, client1ReceivedChan, errorString)

	time.Sleep(2260 * time.Millisecond)

	client2ReceivedChan := make(chan []byte, 10)
	fakeSyslogDrain, err = NewFakeService(client2ReceivedChan, "127.0.0.1:34569")
	assert.NoError(t, err)

	go fakeSyslogDrain.Serve()
	<-fakeSyslogDrain.ReadyChan

	time.Sleep(2260 * time.Millisecond)

	expectedMessageString4 := "Some Data 4"
	logEnvelope = messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString4, "myApp", SECRET, "syslog://localhost:34569")
	dataReadChannel <- logEnvelope

	errorString = "Did not get the fourth message, but it should have been just fine since the server was up"
	AssertMessageOnChannel(t, 200, client2ReceivedChan, errorString, expectedMessageString4)

	fakeSyslogDrain.Stop()
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:49,代码来源:sinkserver_syslog_test.go


示例5: TestThatItSendsAllDataToAllDrainUrls

func TestThatItSendsAllDataToAllDrainUrls(t *testing.T) {
	client1ReceivedChan := make(chan []byte)
	client2ReceivedChan := make(chan []byte)

	fakeSyslogDrain1, err := NewFakeService(client1ReceivedChan, "127.0.0.1:34567")
	assert.NoError(t, err)
	go fakeSyslogDrain1.Serve()
	<-fakeSyslogDrain1.ReadyChan

	fakeSyslogDrain2, err := NewFakeService(client2ReceivedChan, "127.0.0.1:34568")
	assert.NoError(t, err)
	go fakeSyslogDrain2.Serve()
	<-fakeSyslogDrain2.ReadyChan

	expectedMessageString := "Some Data"
	logEnvelope := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, expectedMessageString, "myApp", SECRET, "syslog://localhost:34567", "syslog://localhost:34568")
	dataReadChannel <- logEnvelope

	errString := "Did not get message from client 1."
	assertMessageOnChannel(t, 500, client1ReceivedChan, errString, expectedMessageString)

	errString = "Did not get message from client 2."
	assertMessageOnChannel(t, 500, client2ReceivedChan, errString, expectedMessageString)

	fakeSyslogDrain1.Stop()
	fakeSyslogDrain2.Stop()
}
开发者ID:pxie,项目名称:loggregator,代码行数:27,代码来源:sinkserver_syslog_test.go


示例6: TestThatItDoesNotRegisterADrainIfItsURLIsBlacklisted

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)
	}
}
开发者ID:pxie,项目名称:loggregator,代码行数:31,代码来源:sinkserver_syslog_test.go


示例7: TestThatItSendsLogsToProperAppSink

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()
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:25,代码来源:sinkserver_websocket_test.go


示例8: TestThatItSendsAllDataToAllSinks

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()
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:32,代码来源:sinkserver_websocket_test.go


示例9: TestDropUnmarshallableMessage

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()
}
开发者ID:pxie,项目名称:loggregator,代码行数:26,代码来源:sinkserver_websocket_test.go


示例10: TestThatItSendsAllDataToOnlyAuthoritiveMessagesWithDrainUrls

func TestThatItSendsAllDataToOnlyAuthoritiveMessagesWithDrainUrls(t *testing.T) {
	client1ReceivedChan := make(chan []byte)
	client2ReceivedChan := make(chan []byte)

	fakeSyslogDrain1, err := NewFakeService(client1ReceivedChan, "127.0.0.1:34569")
	defer fakeSyslogDrain1.Stop()
	assert.NoError(t, err)
	go fakeSyslogDrain1.Serve()
	<-fakeSyslogDrain1.ReadyChan

	fakeSyslogDrain2, err := NewFakeService(client2ReceivedChan, "127.0.0.1:34540")
	defer fakeSyslogDrain2.Stop()
	assert.NoError(t, err)
	go fakeSyslogDrain2.Serve()
	<-fakeSyslogDrain2.ReadyChan

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

	select {
	case <-time.After(200 * time.Millisecond):
		t.Errorf("Did not get message 1")
	case message := <-client1ReceivedChan:
		assert.Contains(t, string(message), expectedMessageString)
	}

	expectedSecondMessageString := "loggregator myApp: loggregator myApp: Some More Data"
	logMessage2 := messagetesthelpers.NewLogMessage(expectedSecondMessageString, "myApp")
	sourceName := "DEA"
	logMessage2.SourceName = &sourceName
	logMessage2.DrainUrls = []string{"syslog://localhost:34540"}
	logEnvelope2 := messagetesthelpers.MarshalledLogEnvelope(t, logMessage2, SECRET)

	dataReadChannel <- logEnvelope2

	select {
	case <-time.After(200 * time.Millisecond):
		t.Errorf("Did not get message 2")
	case message := <-client1ReceivedChan:
		matched, _ := regexp.MatchString(`<14>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}([-+]\d{2}:\d{2}) loggregator myApp DEA - - loggregator myApp: loggregator myApp: Some More Data`, string(message))
		assert.True(t, matched, string(message))
	case <-client2ReceivedChan:
		t.Error("Should not have gotten the new message in this drain")
	}
}
开发者ID:pxie,项目名称:loggregator,代码行数:46,代码来源:sinkserver_syslog_test.go


示例11: TestParseEnvelopesDoesntBlockWhenMessageRouterChannelIsFull

func TestParseEnvelopesDoesntBlockWhenMessageRouterChannelIsFull(t *testing.T) {
	logger := gosteno.NewLogger("TestLogger")

	messageChannelLength := 1
	sinkManager := NewSinkManager(1, true, []iprange.IPRange{}, logger)
	go sinkManager.Start()
	incomingLogChan := make(chan []byte, 1)
	messageRouter := NewMessageRouter(incomingLogChan, testhelpers.UnmarshallerMaker("secret"), sinkManager, messageChannelLength, logger)
	go messageRouter.listenForLogs()

	testMessage := messagetesthelpers.MarshalledLogEnvelopeForMessage(t, "msg", "appName", "secret")

	for i := 0; i < 10; i++ {
		select {
		case incomingLogChan <- testMessage:
			break
		case <-time.After(1 * time.Second):
			t.Fatal("Shouldn't have blocked")
		}
	}
}
开发者ID:james-masson,项目名称:loggregator,代码行数:21,代码来源:message_router_test.go


示例12: TestKeepAlive

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!
	}
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:23,代码来源:sinkserver_websocket_test.go


示例13: TestThatItDoesNotDumpLogsBeforeTailing

func TestThatItDoesNotDumpLogsBeforeTailing(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):
		break
	case _, ok := <-receivedChan:
		if ok {
			t.Errorf("Recieved unexpected message from app sink")
		}
	}

	stopKeepAlive <- true
	WaitForWebsocketRegistration()
}
开发者ID:pxie,项目名称:loggregator,代码行数:23,代码来源:sinkserver_websocket_test.go


示例14: TestKeepAlive

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")
}
开发者ID:pxie,项目名称:loggregator,代码行数:37,代码来源:sinkserver_websocket_test.go


示例15: TestDontDropSinkThatWorks

func TestDontDropSinkThatWorks(t *testing.T) {
	receivedChan := make(chan []byte, 2)
	_, stopKeepAlive, droppedChannel := testhelpers.AddWSSink(t, receivedChan, SERVER_PORT, TAIL_PATH+"?app=myApp04")

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

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

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

	stopKeepAlive <- true
	WaitForWebsocketRegistration()
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:24,代码来源:sinkserver_websocket_test.go


示例16: TestMetrics

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)
}
开发者ID:pxie,项目名称:loggregator,代码行数:81,代码来源:sinkserver_test.go



注:本文中的github.com/cloudfoundry/loggregatorlib/logmessage/testhelpers.MarshalledLogEnvelopeForMessage函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang testhelpers.NewMessage函数代码示例发布时间:2022-05-23
下一篇:
Golang testhelpers.AssertProtoBufferMessageEquals函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap