本文整理匯總了Golang中github.com/cloudfoundry/bosh-agent/platform/fakes.FakePlatform.DeleteARPEntryWithIPErr方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakePlatform.DeleteARPEntryWithIPErr方法的具體用法?Golang FakePlatform.DeleteARPEntryWithIPErr怎麽用?Golang FakePlatform.DeleteARPEntryWithIPErr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-agent/platform/fakes.FakePlatform
的用法示例。
在下文中一共展示了FakePlatform.DeleteARPEntryWithIPErr方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
func init() {
Describe("natsHandler", func() {
var (
settingsService *fakesettings.FakeSettingsService
client *fakeyagnats.FakeYagnats
logger boshlog.Logger
handler boshhandler.Handler
platform *fakeplatform.FakePlatform
loggerOutBuf *bytes.Buffer
loggerErrBuf *bytes.Buffer
)
BeforeEach(func() {
settingsService = &fakesettings.FakeSettingsService{
Settings: boshsettings.Settings{
AgentID: "my-agent-id",
Mbus: "nats://fake-username:[email protected]:1234",
},
}
loggerOutBuf = bytes.NewBufferString("")
loggerErrBuf = bytes.NewBufferString("")
logger = boshlog.NewWriterLogger(boshlog.LevelError, loggerOutBuf, loggerErrBuf)
client = fakeyagnats.New()
platform = fakeplatform.NewFakePlatform()
handler = NewNatsHandler(settingsService, client, logger, platform)
})
Describe("Start", func() {
It("starts", func() {
var receivedRequest boshhandler.Request
handler.Start(func(req boshhandler.Request) (resp boshhandler.Response) {
receivedRequest = req
return boshhandler.NewValueResponse("expected value")
})
defer handler.Stop()
Expect(client.ConnectedConnectionProvider()).ToNot(BeNil())
Expect(client.SubscriptionCount()).To(Equal(1))
subscriptions := client.Subscriptions("agent.my-agent-id")
Expect(len(subscriptions)).To(Equal(1))
expectedPayload := []byte(`{"method":"ping","arguments":["foo","bar"], "reply_to": "reply to me!"}`)
subscription := subscriptions[0]
subscription.Callback(&yagnats.Message{
Subject: "agent.my-agent-id",
Payload: expectedPayload,
})
Expect(receivedRequest).To(Equal(boshhandler.Request{
ReplyTo: "reply to me!",
Method: "ping",
Payload: expectedPayload,
}))
Expect(client.PublishedMessageCount()).To(Equal(1))
messages := client.PublishedMessages("reply to me!")
Expect(len(messages)).To(Equal(1))
Expect(messages[0].Payload).To(Equal([]byte(`{"value":"expected value"}`)))
})
It("cleans up ip-mac address cache for nats configured with ip address", func() {
handler.Start(func(req boshhandler.Request) (resp boshhandler.Response) {
return nil
})
defer handler.Stop()
Expect(platform.LastIPDeletedFromARP).To(Equal("127.0.0.1"))
Expect(client.ConnectedConnectionProvider()).ToNot(BeNil())
})
It("does not try to clean up ip-mac address cache for nats configured with hostname", func() {
settingsService.Settings.Mbus = "nats://fake-username:[email protected]:1234"
handler.Start(func(req boshhandler.Request) (resp boshhandler.Response) {
return nil
})
defer handler.Stop()
Expect(platform.LastIPDeletedFromARP).To(BeEmpty())
Expect(client.ConnectedConnectionProvider()).ToNot(BeNil())
})
It("logs error and proceeds if it fails to clean up ip-mac address cache for nats", func() {
platform.DeleteARPEntryWithIPErr = errors.New("failed to run")
handler.Start(func(req boshhandler.Request) (resp boshhandler.Response) {
return nil
})
defer handler.Stop()
Expect(platform.LastIPDeletedFromARP).To(Equal("127.0.0.1"))
Expect(loggerErrBuf).To(ContainSubstring("ERROR - Cleaning ip-mac address cache for: 127.0.0.1"))
Expect(client.ConnectedConnectionProvider()).ToNot(BeNil())
})
It("does not respond if the response is nil", func() {
err := handler.Start(func(req boshhandler.Request) (resp boshhandler.Response) {
return nil
//.........這裏部分代碼省略.........