本文整理匯總了Golang中code/cloudfoundry/org/bbs/models.DesiredLRP.Instances方法的典型用法代碼示例。如果您正苦於以下問題:Golang DesiredLRP.Instances方法的具體用法?Golang DesiredLRP.Instances怎麽用?Golang DesiredLRP.Instances使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/cloudfoundry/org/bbs/models.DesiredLRP
的用法示例。
在下文中一共展示了DesiredLRP.Instances方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
Expect(response.Error).To(Equal(models.ErrUnknownError))
})
})
})
Describe("DesireDesiredLRP", func() {
var (
desiredLRP *models.DesiredLRP
requestBody interface{}
)
BeforeEach(func() {
desiredLRP = model_helpers.NewValidDesiredLRP("some-guid")
desiredLRP.Instances = 5
requestBody = &models.DesireLRPRequest{
DesiredLrp: desiredLRP,
}
})
JustBeforeEach(func() {
request := newTestRequest(requestBody)
handler.DesireDesiredLRP(logger, responseRecorder, request)
})
Context("when creating desired lrp in DB succeeds", func() {
var createdActualLRPGroups []*models.ActualLRPGroup
BeforeEach(func() {
createdActualLRPGroups = []*models.ActualLRPGroup{}
示例2:
etcdRunner.Start()
})
It("errors", func() {
_, err := etcdDB.DesiredLRPSchedulingInfos(logger, filter)
Expect(err).To(HaveOccurred())
})
})
})
Describe("DesireLRP", func() {
var lrp *models.DesiredLRP
BeforeEach(func() {
lrp = model_helpers.NewValidDesiredLRP("some-process-guid")
lrp.Instances = 5
})
Context("when the desired LRP does not yet exist", func() {
It("persists the scheduling info and run info", func() {
err := etcdDB.DesireLRP(logger, lrp)
Expect(err).NotTo(HaveOccurred())
persisted, err := etcdDB.DesiredLRPByProcessGuid(logger, "some-process-guid")
Expect(err).NotTo(HaveOccurred())
Expect(persisted.DesiredLRPKey()).To(Equal(lrp.DesiredLRPKey()))
Expect(persisted.DesiredLRPResource()).To(Equal(lrp.DesiredLRPResource()))
Expect(persisted.Annotation).To(Equal(lrp.Annotation))
Expect(persisted.Instances).To(Equal(lrp.Instances))
Expect(persisted.DesiredLRPRunInfo(clock.Now())).To(Equal(lrp.DesiredLRPRunInfo(clock.Now())))
示例3:
routes := models.Routes{
"blah": (*json.RawMessage)(&routeContent),
}
annotation := "annotated"
update = &models.DesiredLRPUpdate{
Instances: &instances,
Routes: &routes,
Annotation: &annotation,
}
_, err := sqlDB.UpdateDesiredLRP(logger, expectedDesiredLRP.ProcessGuid, update)
Expect(err).NotTo(HaveOccurred())
desiredLRP, err := sqlDB.DesiredLRPByProcessGuid(logger, expectedDesiredLRP.ProcessGuid)
Expect(err).NotTo(HaveOccurred())
expectedDesiredLRP.Instances = instances
expectedDesiredLRP.Annotation = annotation
expectedDesiredLRP.Routes = &routes
expectedDesiredLRP.ModificationTag.Increment()
Expect(desiredLRP).To(BeEquivalentTo(expectedDesiredLRP))
})
It("returns the desired lrp from before the update", func() {
instances := int32(20)
update = &models.DesiredLRPUpdate{
Instances: &instances,
}
beforeDesiredLRP, err := sqlDB.UpdateDesiredLRP(logger, expectedDesiredLRP.ProcessGuid, update)
Expect(err).NotTo(HaveOccurred())
示例4:
Expect(response.Error).To(Equal(models.ErrUnknownError))
})
})
})
Describe("DesireDesiredLRP_r0", func() {
var (
desiredLRP *models.DesiredLRP
expectedDesiredLRP *models.DesiredLRP
requestBody interface{}
)
BeforeEach(func() {
desiredLRP = model_helpers.NewValidDesiredLRP("some-guid")
desiredLRP.Instances = 5
desiredLRP.StartTimeoutMs = 0
desiredLRP.DeprecatedStartTimeoutS = 15
desiredLRP.Setup = &models.Action{
TimeoutAction: &models.TimeoutAction{
Action: models.WrapAction(&models.UploadAction{
From: "web_location",
To: "potato",
User: "face",
}),
DeprecatedTimeoutNs: int64(time.Second),
},
}
desiredLRP.Action = &models.Action{
TimeoutAction: &models.TimeoutAction{
Action: models.WrapAction(&models.UploadAction{
示例5:
}(validGuid)
}
invalidGuids := []string{"", "bang!", "!!!", "\\slash", "star*", "params()", "invalid/key", "with.dots"}
for _, invalidGuid := range invalidGuids {
func(invalidGuid string) {
It(fmt.Sprintf("'%s' is an invalid process_guid", invalidGuid), func() {
desiredLRP.ProcessGuid = invalidGuid
assertDesiredLRPValidationFailsWithMessage(desiredLRP, "process_guid")
})
}(invalidGuid)
}
})
It("requires a positive nonzero number of instances", func() {
desiredLRP.Instances = -1
assertDesiredLRPValidationFailsWithMessage(desiredLRP, "instances")
desiredLRP.Instances = 0
validationErr := desiredLRP.Validate()
Expect(validationErr).NotTo(HaveOccurred())
desiredLRP.Instances = 1
validationErr = desiredLRP.Validate()
Expect(validationErr).NotTo(HaveOccurred())
})
It("requires a domain", func() {
desiredLRP.Domain = ""
assertDesiredLRPValidationFailsWithMessage(desiredLRP, "domain")
})