} err := desiredLRP.Validate() Expect(err).NotTo(HaveOccurred()) return desiredLRP } Describe("Up", func() { var ( existingDesiredLRP *models.DesiredLRP migrationErr error ) BeforeEach(func() { existingDesiredLRP = newValidDesiredLRP("process-guid") payload, err := serializer.Marshal(logger, format.ENCRYPTED_PROTO, existingDesiredLRP) Expect(err).NotTo(HaveOccurred()) _, err = storeClient.Set(deprecations.DesiredLRPSchemaPath(existingDesiredLRP), payload, 0) Expect(err).NotTo(HaveOccurred()) }) JustBeforeEach(func() { migration.SetStoreClient(storeClient) migration.SetCryptor(cryptor) migrationErr = migration.Up(logger) }) It("creates a DesiredLRPSchedulingInfo for all desired LRPs", func() { Expect(migrationErr).NotTo(HaveOccurred()) response, err := storeClient.Get(etcd.DesiredLRPSchedulingInfoSchemaRoot, false, true)
Describe("Up", func() { var ( task *models.Task migrationErr error ) Describe("Task Migration", func() { BeforeEach(func() { task = model_helpers.NewValidTask("task-guid-1") task.Action = models.WrapAction(&models.TimeoutAction{Action: model_helpers.NewValidAction(), DeprecatedTimeoutNs: 5 * int64(time.Second), }) }) JustBeforeEach(func() { taskData, err := serializer.Marshal(logger, format.ENCRYPTED_PROTO, task) Expect(err).NotTo(HaveOccurred()) _, err = storeClient.Set(etcddb.TaskSchemaPath(task), taskData, 0) Expect(err).NotTo(HaveOccurred()) migration.SetStoreClient(storeClient) migration.SetCryptor(cryptor) migration.SetClock(fakeClock) migrationErr = migration.Up(logger) }) It("changes task timeoutAction timeout to milliseconds", func() { Expect(migrationErr).NotTo(HaveOccurred()) newTask, err := db.TaskByGuid(logger, task.TaskGuid) Expect(err).NotTo(HaveOccurred()) Expect(newTask.Action.GetTimeoutAction().GetTimeoutMs()).To(Equal(int64(5000)))
desiredLRPsToCreate = 3 for i := 0; i < desiredLRPsToCreate; i++ { processGuid := fmt.Sprintf("process-guid-%d", i) var desiredLRP *models.DesiredLRP desiredLRP = model_helpers.NewValidDesiredLRP(processGuid) schedulingInfo, runInfo := desiredLRP.CreateComponents(fakeClock.Now()) var ( encryptedVolumePlacement []byte err error ) if i == 0 { // test for nil and full VolumePlacements schedulingInfo.VolumePlacement = nil encryptedVolumePlacement, err = serializer.Marshal(logger, format.ENCRYPTED_PROTO, &models.VolumePlacement{}) } else { encryptedVolumePlacement, err = serializer.Marshal(logger, format.ENCRYPTED_PROTO, schedulingInfo.VolumePlacement) } Expect(err).NotTo(HaveOccurred()) volumePlacementData, err := encoder.Decode(encryptedVolumePlacement) Expect(err).NotTo(HaveOccurred()) routesData, err := json.Marshal(desiredLRP.Routes) Expect(err).NotTo(HaveOccurred()) schedInfoData, err := serializer.Marshal(logger, format.ENCRYPTED_PROTO, &schedulingInfo) Expect(err).NotTo(HaveOccurred()) _, err = storeClient.Set(etcddb.DesiredLRPSchedulingInfoSchemaPath(processGuid), schedInfoData, 0) Expect(err).NotTo(HaveOccurred())