本文整理汇总了Golang中github.com/cloudfoundry/bosh-agent/agentclient.AgentClient.Stop方法的典型用法代码示例。如果您正苦于以下问题:Golang AgentClient.Stop方法的具体用法?Golang AgentClient.Stop怎么用?Golang AgentClient.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-agent/agentclient.AgentClient
的用法示例。
在下文中一共展示了AgentClient.Stop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
BeforeEach(func() {
logger := boshlog.NewLogger(boshlog.LevelNone)
fakeHTTPClient = fakehttpclient.NewFakeHTTPClient()
toleratedErrorCount := 2
agentClient = NewAgentClient("http://localhost:6305", "fake-uuid", 0, toleratedErrorCount, fakeHTTPClient, logger)
})
Describe("get_task", func() {
Context("when the http client errors", func() {
It("should retry", func() {
fakeHTTPClient.SetPostBehavior(`{"value":{"agent_task_id":"fake-agent-task-id","state":"running"}}`, 200, nil)
fakeHTTPClient.SetPostBehavior("", 0, errors.New("connection reset by peer"))
fakeHTTPClient.SetPostBehavior("", 0, errors.New("connection reset by peer"))
fakeHTTPClient.SetPostBehavior(`{"value":{"agent_task_id":"fake-agent-task-id","state":"running"}}`, 200, nil)
fakeHTTPClient.SetPostBehavior(`{"value":"stopped"}`, 200, nil)
err := agentClient.Stop()
Expect(err).ToNot(HaveOccurred())
})
Context("when the http client errors more times than the error retry count", func() {
It("should return the error", func() {
fakeHTTPClient.SetPostBehavior(`{"value":{"agent_task_id":"fake-agent-task-id","state":"running"}}`, 200, nil)
fakeHTTPClient.SetPostBehavior("", 0, errors.New("connection reset by peer 1"))
fakeHTTPClient.SetPostBehavior("", 0, errors.New("connection reset by peer 2"))
fakeHTTPClient.SetPostBehavior("", 0, errors.New("connection reset by peer 3"))
err := agentClient.Stop()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("connection reset by peer 3"))
})
})