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

Golang testhelpers.AssertProtoBufferMessageEquals函数代码示例

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

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



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

示例1: 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


示例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: 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: 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


示例5: TestItDumpsAllMessagesForAnAppUser

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


示例6: TestProxyWhenAuthorizationFailsThroughQueryParams

func TestProxyWhenAuthorizationFailsThroughQueryParams(t *testing.T) {
	proxy := NewProxy(
		"localhost:62062",
		[]*hasher.Hasher{
			hasher.NewHasher([]string{"localhost:62032"}),
		},
		testhelpers.SuccessfulAuthorizer,
		loggertesthelper.Logger(),
	)
	go proxy.Start()
	time.Sleep(time.Millisecond * 50)

	config, err := websocket.NewConfig("ws://localhost:62061/?app=myApp&authorization="+url.QueryEscape(testhelpers.INVALID_AUTHENTICATION_TOKEN), "http://localhost")
	assert.NoError(t, err)
	receivedChan := ClientWithAuth(t, "62062", "/?app=myApp", config)

	select {
	case data := <-receivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, "Error: Invalid authorization", data)
	case <-time.After(1 * time.Second):
		t.Error("Did not receive response within one second")
	}

	_, stillOpen := <-receivedChan
	assert.False(t, stillOpen)
}
开发者ID:james-masson,项目名称:loggregator,代码行数:26,代码来源:output_proxy_test.go


示例7: TestProxyWithoutAuthorization

func TestProxyWithoutAuthorization(t *testing.T) {
	proxy := NewProxy(
		"localhost:62061",
		[]*hasher.Hasher{
			hasher.NewHasher([]string{"localhost:62032"}),
		},
		testhelpers.SuccessfulAuthorizer,
		loggertesthelper.Logger(),
	)
	go proxy.Start()
	time.Sleep(time.Millisecond * 50)

	config, err := websocket.NewConfig("ws://localhost:62061/?app=myApp", "http://localhost")
	assert.NoError(t, err)
	receivedChan := ClientWithAuth(t, "62061", "/?app=myApp", config)

	select {
	case data := <-receivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, "Error: Authorization not provided", data)
	case <-time.After(1 * time.Second):
		t.Error("Did not receive response within one second")
	}

	_, stillOpen := <-receivedChan
	assert.False(t, stillOpen)
}
开发者ID:james-masson,项目名称:loggregator,代码行数:26,代码来源:output_proxy_test.go


示例8: 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


示例9: TestEndtoEndEnvelopeToMessage

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


示例10: TestDontDropSinkThatWorks

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


示例11: TestProxyWhenLogTargetisinvalid

func TestProxyWhenLogTargetisinvalid(t *testing.T) {
	proxy := NewProxy(
		"localhost:62060",
		[]*hasher.Hasher{
			hasher.NewHasher([]string{"localhost:62032"}),
		},
		testhelpers.SuccessfulAuthorizer,
		loggertesthelper.Logger(),
	)
	go proxy.Start()
	time.Sleep(time.Millisecond * 50)

	receivedChan := Client(t, "62060", "/invalid_target")

	select {
	case data := <-receivedChan:
		messagetesthelpers.AssertProtoBufferMessageEquals(t, "Error: Invalid target", data)
	case <-time.After(1 * time.Second):
		t.Error("Did not receive response within one second")
	}

	_, stillOpen := <-receivedChan
	assert.False(t, stillOpen)
}
开发者ID:james-masson,项目名称:loggregator,代码行数:24,代码来源:output_proxy_test.go


示例12: TestItDumpsAllMessagesForAnAppUser

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang testhelpers.MarshalledLogEnvelopeForMessage函数代码示例发布时间:2022-05-23
下一篇:
Golang logmessage.Message类代码示例发布时间: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