Describe("Down", func() {
		It("returns a not implemented error", func() {
			Expect(migration.Down(logger)).To(HaveOccurred())
		})
	})

	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)
			})
示例#2
0
				Expect(err).To(HaveOccurred())
				Expect(err.Error()).To(ContainSubstring(expectedErr))
			}
		},
		Entry("valid scheduling info", models.NewDesiredLRPSchedulingInfo(newValidLRPKey(), annotation, instances, newValidResource(), routes, tag, nil, nil), ""),
		Entry("invalid annotation", models.NewDesiredLRPSchedulingInfo(newValidLRPKey(), largeString, instances, newValidResource(), routes, tag, nil, nil), "annotation"),
		Entry("invalid instances", models.NewDesiredLRPSchedulingInfo(newValidLRPKey(), annotation, -2, newValidResource(), routes, tag, nil, nil), "instances"),
		Entry("invalid key", models.NewDesiredLRPSchedulingInfo(models.DesiredLRPKey{}, annotation, instances, newValidResource(), routes, tag, nil, nil), "process_guid"),
		Entry("invalid resource", models.NewDesiredLRPSchedulingInfo(newValidLRPKey(), annotation, instances, models.DesiredLRPResource{}, routes, tag, nil, nil), "rootfs"),
		Entry("invalid routes", models.NewDesiredLRPSchedulingInfo(newValidLRPKey(), annotation, instances, newValidResource(), largeRoutes, tag, nil, nil), "routes"),
	)
})

var _ = Describe("DesiredLRPRunInfo", func() {
	var envVars = []models.EnvironmentVariable{{"FOO", "bar"}}
	var action = model_helpers.NewValidAction()
	const startTimeoutMs int64 = 12
	const privileged = true
	var ports = []uint32{80, 443}
	var egressRules = model_helpers.NewValidEgressRules()
	const logSource = "log-source"
	const metricsGuid = "metrics-guid"
	const cpuWeight = 50
	var createdAt = time.Unix(123, 456)
	var trustedSystemCertificatesPath = "/etc/cf-system-certificates"

	DescribeTable("Validation",
		func(key models.DesiredLRPRunInfo, expectedErr string) {
			err := key.Validate()
			if expectedErr == "" {
				Expect(err).NotTo(HaveOccurred())