Пример #1
0
		buildFactory *BuildFactory
	)

	BeforeEach(func() {
		buildFactory = &BuildFactory{
			PipelineName: "some-pipeline",
		}
	})

	Context("When there is a task with a timeout", func() {
		It("builds correctly", func() {
			actual, err := buildFactory.Create(atc.JobConfig{
				Plan: atc.PlanSequence{
					{
						Task:    "first task",
						Timeout: atc.Duration(10 * time.Second),
					},
				},
			}, nil, nil)

			Ω(err).ShouldNot(HaveOccurred())

			expected := atc.Plan{
				Timeout: &atc.TimeoutPlan{
					Duration: atc.Duration(10 * time.Second),
					Step: atc.Plan{
						Task: &atc.TaskPlan{
							Name: "first task",
						},
					},
				},
Пример #2
0
		fakeStepFactoryStep = new(fakes.FakeStepFactory)
		runStep = new(fakes.FakeStep)
		fakeStepFactoryStep.UsingReturns(runStep)

	})

	JustBeforeEach(func() {
		timeout = Timeout(fakeStepFactoryStep, timeoutDuration)
		step = timeout.Using(nil, nil)
		process = ifrit.Background(step)
	})

	Context("when the process goes beyond the duration", func() {
		BeforeEach(func() {
			runStep.ResultStub = successResult(true)
			timeoutDuration = atc.Duration(1 * time.Second)

			runStep.RunStub = func(signals <-chan os.Signal, ready chan<- struct{}) error {
				close(ready)
				select {
				case <-startStep:
					return nil
				case <-signals:
					return ErrInterrupted
				}
			}
		})

		It("should interrupt after timeout duration", func() {
			Eventually(runStep.RunCallCount).Should(Equal(1))
Пример #3
0
			BeforeEach(func() {
				inputStep.RunStub = func(signals <-chan os.Signal, ready chan<- struct{}) error {
					close(ready)

					time.Sleep(4 * time.Second)

					return nil
				}
			})

			It("does not run the next step", func() {
				plan := atc.Plan{
					HookedCompose: &atc.HookedComposePlan{
						Step: atc.Plan{
							Timeout: &atc.TimeoutPlan{
								Duration: atc.Duration(2 * time.Second),
								Step: atc.Plan{
									Get: &atc.GetPlan{
										Name: "some-input",
									},
								},
							},
						},
						Next: atc.Plan{
							Task: &atc.TaskPlan{
								Name:   "some-resource",
								Config: &atc.TaskConfig{},
							},
						},
					},
				}