本文整理匯總了Golang中github.com/cloudfoundry-incubator/bbs/fake_bbs.FakeClient.DesiredLRPByProcessGuidReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeClient.DesiredLRPByProcessGuidReturns方法的具體用法?Golang FakeClient.DesiredLRPByProcessGuidReturns怎麽用?Golang FakeClient.DesiredLRPByProcessGuidReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/bbs/fake_bbs.FakeClient
的用法示例。
在下文中一共展示了FakeClient.DesiredLRPByProcessGuidReturns方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
Context("when the desired LRP does not exist", func() {
var newlyDesiredLRP *models.DesiredLRP
BeforeEach(func() {
newlyDesiredLRP = &models.DesiredLRP{
ProcessGuid: "new-process-guid",
Instances: 1,
RootFs: models.PreloadedRootFS("stack-2"),
Action: models.WrapAction(&models.RunAction{
User: "me",
Path: "ls",
}),
Annotation: "last-modified-etag",
}
fakeBBS.DesiredLRPByProcessGuidReturns(&models.DesiredLRP{}, models.ErrResourceNotFound)
buildpackBuilder.BuildReturns(newlyDesiredLRP, nil)
})
It("logs the incoming and outgoing request", func() {
Eventually(logger.TestSink.Buffer).Should(gbytes.Say("request-from-cc"))
Eventually(logger.TestSink.Buffer).Should(gbytes.Say("creating-desired-lrp"))
})
It("creates the desired LRP", func() {
Expect(fakeBBS.DesireLRPCallCount()).To(Equal(1))
Expect(fakeBBS.DesiredLRPByProcessGuidCallCount()).To(Equal(1))
Expect(fakeBBS.DesireLRPArgsForCall(0)).To(Equal(newlyDesiredLRP))
Expect(buildpackBuilder.BuildArgsForCall(0)).To(Equal(&desireAppRequest))
示例2:
BeforeEach(func() {
req = newTestRequest("")
req.Form = url.Values{":process_guid": []string{"process-guid-0"}}
})
JustBeforeEach(func() {
handler.Get(responseRecorder, req)
})
Context("when reading tasks from BBS succeeds", func() {
BeforeEach(func() {
fakeBBS.DesiredLRPByProcessGuidReturns(&models.DesiredLRP{
ProcessGuid: "process-guid-0",
Domain: "domain-1",
Action: models.WrapAction(&models.RunAction{
User: "me",
Path: "the-path",
}),
}, nil)
})
It("calls DesiredLRPByProcessGuid on the BBS", func() {
Expect(fakeBBS.DesiredLRPByProcessGuidCallCount()).To(Equal(1))
actualProcessGuid := fakeBBS.DesiredLRPByProcessGuidArgsForCall(0)
Expect(actualProcessGuid).To(Equal("process-guid-0"))
})
It("responds with 200 Status OK", func() {
Expect(responseRecorder.Code).To(Equal(http.StatusOK))
})
示例3:
routes.DIEGO_SSH: &diegoSSHRouteMessage,
},
LogGuid: "log-guid",
}
actualLRPGroup = &models.ActualLRPGroup{
Instance: &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey("some-guid", 1, "some-domain"),
ActualLRPInstanceKey: models.NewActualLRPInstanceKey("some-instance-guid", "some-cell-id"),
ActualLRPNetInfo: models.NewActualLRPNetInfo("1.2.3.4", models.NewPortMapping(3333, 1111)),
},
}
bbsClient = new(fake_bbs.FakeClient)
bbsClient.ActualLRPGroupByProcessGuidAndIndexReturns(actualLRPGroup, nil)
bbsClient.DesiredLRPByProcessGuidReturns(desiredLRP, nil)
credentials = []byte("some-user:some-password")
permissionsBuilder = authenticators.NewPermissionsBuiler(bbsClient)
remoteAddr, err := net.ResolveIPAddr("ip", "1.1.1.1")
Expect(err).NotTo(HaveOccurred())
metadata = &fake_ssh.FakeConnMetadata{}
metadata.RemoteAddrReturns(remoteAddr)
processGuid = "some-guid"
index = 1
})
JustBeforeEach(func() {
permissions, buildErr = permissionsBuilder.Build(processGuid, index, metadata)
示例4:
})
Context("and the container is INVALID", func() {
BeforeEach(func() {
expectedSessionName = sessionPrefix + "process-invalid-container"
container.State = executor.StateInvalid
})
It("logs an error", func() {
Expect(logger).To(Say(expectedSessionName))
})
})
Context("and the container is RESERVED", func() {
BeforeEach(func() {
bbsClient.DesiredLRPByProcessGuidReturns(desiredLRP, nil)
expectedSessionName = sessionPrefix + "process-reserved-container"
container.State = executor.StateReserved
})
It("claims the actualLRP in the bbs", func() {
Expect(bbsClient.ClaimActualLRPCallCount()).To(Equal(1))
processGuid, index, instanceKey := bbsClient.ClaimActualLRPArgsForCall(0)
Expect(processGuid).To(Equal(expectedLrpKey.ProcessGuid))
Expect(int32(index)).To(Equal(expectedLrpKey.Index))
Expect(*instanceKey).To(Equal(expectedInstanceKey))
})
Context("when claiming fails because ErrActualLRPCannotBeClaimed", func() {
BeforeEach(func() {
bbsClient.ClaimActualLRPReturns(models.ErrActualLRPCannotBeClaimed)
示例5:
request.Header.Set("Authorization", authorization)
request.Form = url.Values{}
request.Form.Add(":guid", guid)
noaaClient.ContainerMetricsReturns([]*events.ContainerMetric{
{
ApplicationId: proto.String("appId"),
InstanceIndex: proto.Int32(5),
CpuPercentage: proto.Float64(4),
MemoryBytes: proto.Uint64(1024),
DiskBytes: proto.Uint64(2048),
},
}, nil)
bbsClient.DesiredLRPByProcessGuidReturns(&models.DesiredLRP{
LogGuid: logGuid,
ProcessGuid: guid,
}, nil)
actualLRP := &models.ActualLRP{
ActualLRPKey: models.NewActualLRPKey(guid, 5, "some-domain"),
ActualLRPInstanceKey: models.NewActualLRPInstanceKey("instanceId", "some-cell"),
ActualLRPNetInfo: models.NewActualLRPNetInfo(
"host",
models.NewPortMapping(5432, 7890),
models.NewPortMapping(1234, uint32(recipebuilder.DefaultPort)),
),
State: models.ActualLRPStateRunning,
Since: fakeClock.Now().UnixNano(),
}
bbsClient.ActualLRPGroupsByProcessGuidReturns([]*models.ActualLRPGroup{{