예제 #1
0
func (t *ETCDHelper) SetRawTask(task *models.Task) {
	value, err := t.serializer.Marshal(t.logger, t.format, task)
	Expect(err).NotTo(HaveOccurred())

	key := etcddb.TaskSchemaPath(task)
	_, err = t.client.Set(key, value, 0)

	Expect(err).NotTo(HaveOccurred())
}
			// Evacuating ActualLRP
			expectedEvacuatingActualLRP = model_helpers.NewValidActualLRP("process-guid", 4)
			jsonValue, err = json.Marshal(expectedEvacuatingActualLRP)
			Expect(err).NotTo(HaveOccurred())
			_, err = storeClient.Set(
				etcd.EvacuatingActualLRPSchemaPath(expectedEvacuatingActualLRP.ProcessGuid, 1),
				jsonValue,
				0,
			)
			Expect(err).NotTo(HaveOccurred())

			// Tasks
			expectedTask = model_helpers.NewValidTask("task-guid")
			jsonValue, err = json.Marshal(expectedTask)
			Expect(err).NotTo(HaveOccurred())
			_, err = storeClient.Set(etcd.TaskSchemaPath(expectedTask), jsonValue, 0)
			Expect(err).NotTo(HaveOccurred())
		})

		JustBeforeEach(func() {
			migration.SetStoreClient(storeClient)
			migration.SetCryptor(cryptor)
			migrationErr = migration.Up(logger)
		})

		var validateConversionToProto = func(node *goetcd.Node, actual, expected format.Versioner) {
			value := node.Value

			Expect(value[:2]).To(BeEquivalentTo(format.BASE64[:]))
			payload, err := base64.StdEncoding.DecodeString(string(value[2:]))
			Expect(err).NotTo(HaveOccurred())
			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)))
			})
예제 #4
0
func (t *ETCDHelper) CreateMalformedTask(guid string) {
	t.createMalformedValueForKey(etcddb.TaskSchemaPath(&models.Task{TaskGuid: guid}))
}