Beispiel #1
0
	. "github.com/onsi/gomega"

	"github.com/tedsuo/ifrit"

	"github.com/concourse/atc/exec"
	"github.com/concourse/atc/exec/fakes"
)

var _ = Describe("Ensure Step", func() {
	var (
		stepFactory *fakes.FakeStepFactory
		hookFactory *fakes.FakeStepFactory

		step *fakes.FakeStep
		hook *fakes.FakeStep

		previousStep *fakes.FakeStep

		repo *exec.SourceRepository

		ensureFactory exec.StepFactory
		ensureStep    exec.Step
	)

	BeforeEach(func() {
		stepFactory = &fakes.FakeStepFactory{}
		hookFactory = &fakes.FakeStepFactory{}

		step = &fakes.FakeStep{}
		hook = &fakes.FakeStep{}

		previousStep = &fakes.FakeStep{}
Beispiel #2
0
	. "github.com/concourse/atc/exec"
	"github.com/tedsuo/ifrit"

	"github.com/concourse/atc/exec/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Retry Step", func() {
	var (
		attempt1Factory *fakes.FakeStepFactory
		attempt1Step    *fakes.FakeStep

		attempt2Factory *fakes.FakeStepFactory
		attempt2Step    *fakes.FakeStep

		attempt3Factory *fakes.FakeStepFactory
		attempt3Step    *fakes.FakeStep

		stepFactory StepFactory
		step        Step
	)

	BeforeEach(func() {
		attempt1Factory = new(fakes.FakeStepFactory)
		attempt1Step = new(fakes.FakeStep)
		attempt1Factory.UsingReturns(attempt1Step)

		attempt2Factory = new(fakes.FakeStepFactory)
		attempt2Step = new(fakes.FakeStep)
		attempt2Factory.UsingReturns(attempt2Step)
Beispiel #3
0
var errorMatching = MatchError

// check hook is executed - if step succeeds - DONE
// check hook is not executed if the step fails/errors - DONE

// when we send a signal it is forwarded to the currently running step - DONE
// what if steps cannot respond to success - don't need to cover this case because the contract guarentees this won't happen

var _ = Describe("On Success Step", func() {
	var (
		stepFactory    *fakes.FakeStepFactory
		successFactory *fakes.FakeStepFactory

		step *fakes.FakeStep
		hook *fakes.FakeStep

		previousStep *fakes.FakeStep

		repo *exec.SourceRepository

		onSuccessFactory exec.StepFactory
		onSuccessStep    exec.Step
	)

	BeforeEach(func() {
		stepFactory = &fakes.FakeStepFactory{}
		successFactory = &fakes.FakeStepFactory{}

		step = &fakes.FakeStep{}
		hook = &fakes.FakeStep{}

		previousStep = &fakes.FakeStep{}
Beispiel #4
0
		expectedMetadata = engine.StepMetadata{
			BuildID:      84,
			BuildName:    "42",
			JobName:      "some-job",
			PipelineName: "some-pipeline",
		}
	})

	Context("running hooked composes", func() {
		var (
			taskStepFactory *execfakes.FakeStepFactory
			taskStep        *execfakes.FakeStep

			inputStepFactory *execfakes.FakeStepFactory
			inputStep        *execfakes.FakeStep

			outputStepFactory *execfakes.FakeStepFactory
			outputStep        *execfakes.FakeStep

			dependentStepFactory *execfakes.FakeStepFactory
			dependentStep        *execfakes.FakeStep
		)

		BeforeEach(func() {
			taskStepFactory = new(execfakes.FakeStepFactory)
			taskStep = new(execfakes.FakeStep)
			taskStep.ResultStub = successResult(true)
			taskStepFactory.UsingReturns(taskStep)
			fakeFactory.TaskReturns(taskStepFactory)

			inputStepFactory = new(execfakes.FakeStepFactory)
Beispiel #5
0
			*x = result
			return true

		default:
			return false
		}
	}
}

var _ = Describe("Conditional", func() {
	var (
		inStep *fakes.FakeStep
		repo   *SourceRepository

		fakeStepFactory *fakes.FakeStepFactory
		conditional     Conditional

		outStep *fakes.FakeStep

		step    Step
		process ifrit.Process
	)

	BeforeEach(func() {
		inStep = new(fakes.FakeStep)
		repo = NewSourceRepository()

		fakeStepFactory = new(fakes.FakeStepFactory)

		outStep = new(fakes.FakeStep)
		outStep.ResultStub = successResult(true)
		execEngine = engine.NewExecEngine(fakeFactory, fakeDelegateFactory, fakeDB)

		fakeDelegate = new(fakes.FakeBuildDelegate)
		fakeDelegateFactory.DelegateReturns(fakeDelegate)

		buildModel = db.Build{ID: 84}
	})

	Describe("Resume", func() {
		Context("get with nil location", func() {
			var (
				getStepFactory *execfakes.FakeStepFactory
				getStep        *execfakes.FakeStep

				fakeDelegate    *fakes.FakeBuildDelegate
				fakeGetDelegate *execfakes.FakeGetDelegate

				plan atc.Plan
			)

			BeforeEach(func() {
				getStepFactory = new(execfakes.FakeStepFactory)
				getStep = new(execfakes.FakeStep)
				getStep.ResultStub = successResult(true)
				getStepFactory.UsingReturns(getStep)
				fakeFactory.GetReturns(getStepFactory)

				fakeDelegate = new(fakes.FakeBuildDelegate)
				fakeDelegateFactory.DelegateReturns(fakeDelegate)
Beispiel #7
0
	"github.com/concourse/atc/exec/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/tedsuo/ifrit"
)

var _ = Describe("Timeout Step", func() {
	var (
		fakeStepFactoryStep *fakes.FakeStepFactory

		runStep *fakes.FakeStep

		timeout StepFactory
		step    Step

		startStep chan error
		process   ifrit.Process

		timeoutDuration atc.Duration
	)

	BeforeEach(func() {
		startStep = make(chan error, 1)
		fakeStepFactoryStep = new(fakes.FakeStepFactory)
		runStep = new(fakes.FakeStep)
		fakeStepFactoryStep.UsingReturns(runStep)

	})
Beispiel #8
0
	. "github.com/onsi/gomega"

	"github.com/tedsuo/ifrit"

	"github.com/concourse/atc/exec"
	"github.com/concourse/atc/exec/fakes"
)

var _ = Describe("On Failure Step", func() {
	var (
		stepFactory    *fakes.FakeStepFactory
		failureFactory *fakes.FakeStepFactory

		step *fakes.FakeStep
		hook *fakes.FakeStep

		previousStep *fakes.FakeStep

		repo *exec.SourceRepository

		onFailureFactory exec.StepFactory
		onFailureStep    exec.Step
	)

	BeforeEach(func() {
		stepFactory = &fakes.FakeStepFactory{}
		failureFactory = &fakes.FakeStepFactory{}

		step = &fakes.FakeStep{}
		hook = &fakes.FakeStep{}

		previousStep = &fakes.FakeStep{}
Beispiel #9
0
	"github.com/concourse/atc/exec/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/tedsuo/ifrit"
)

var _ = Describe("Aggregate", func() {
	var (
		fakeStepA *fakes.FakeStepFactory
		fakeStepB *fakes.FakeStepFactory

		aggregate StepFactory

		inStep *fakes.FakeStep
		repo   *SourceRepository

		outStepA *fakes.FakeStep
		outStepB *fakes.FakeStep

		step    Step
		process ifrit.Process
	)

	BeforeEach(func() {
		fakeStepA = new(fakes.FakeStepFactory)
		fakeStepB = new(fakes.FakeStepFactory)

		aggregate = Aggregate{
			fakeStepA,
			fakeStepB,
Beispiel #10
0
		fakeDelegateFactory = new(fakes.FakeBuildDelegateFactory)
		fakeDB = new(fakes.FakeEngineDB)

		execEngine = engine.NewExecEngine(fakeFactory, fakeDelegateFactory, fakeDB)

		fakeDelegate = new(fakes.FakeBuildDelegate)
		fakeDelegateFactory.DelegateReturns(fakeDelegate)

		buildModel = db.Build{ID: 84}
	})

	Context("running timeout steps", func() {
		var (
			taskStepFactory *execfakes.FakeStepFactory
			taskStep        *execfakes.FakeStep

			inputStepFactory *execfakes.FakeStepFactory
			inputStep        *execfakes.FakeStep
		)

		BeforeEach(func() {
			taskStepFactory = new(execfakes.FakeStepFactory)
			taskStep = new(execfakes.FakeStep)
			taskStep.ResultStub = successResult(true)
			taskStepFactory.UsingReturns(taskStep)
			fakeFactory.TaskReturns(taskStepFactory)

			inputStepFactory = new(execfakes.FakeStepFactory)
			inputStep = new(execfakes.FakeStep)
			inputStep.ResultStub = successResult(true)
			inputStepFactory.UsingReturns(inputStep)
Beispiel #11
0
// which defaults to returning whatever the previous step was from using. For
// this reason, the input step gets returned as the next step of type identity
// step, which returns nil when ran.

var _ = Describe("Hooked Compose", func() {
	var (
		fakeStepFactoryStep     *fakes.FakeStepFactory
		fakeStepFactoryNextStep *fakes.FakeStepFactory

		hookedCompose StepFactory

		inStep *fakes.FakeStep
		repo   *SourceRepository

		outStep  *fakes.FakeStep
		nextStep *fakes.FakeStep

		startStep  chan error
		finishStep chan error

		startNextStep  chan error
		finishNextStep chan error

		step    Step
		process ifrit.Process
	)

	BeforeEach(func() {
		fakeStepFactoryStep = new(fakes.FakeStepFactory)
		fakeStepFactoryNextStep = new(fakes.FakeStepFactory)
Beispiel #12
0
	. "github.com/onsi/gomega"
	"github.com/tedsuo/ifrit"
)

var _ = Describe("Compose", func() {
	var (
		fakeStepFactoryA *fakes.FakeStepFactory
		fakeStepFactoryB *fakes.FakeStepFactory

		compose StepFactory

		inStep *fakes.FakeStep
		repo   *SourceRepository

		outStepA *fakes.FakeStep
		outStepB *fakes.FakeStep

		startA  chan error
		finishA chan error

		startB  chan error
		finishB chan error

		step    Step
		process ifrit.Process
	)

	BeforeEach(func() {
		fakeStepFactoryA = new(fakes.FakeStepFactory)
		fakeStepFactoryB = new(fakes.FakeStepFactory)
Beispiel #13
0
	"github.com/concourse/atc/exec/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/tedsuo/ifrit"
)

var _ = Describe("Aggregate", func() {
	var (
		fakeStepA *fakes.FakeStepFactory
		fakeStepB *fakes.FakeStepFactory

		aggregate StepFactory

		inStep *fakes.FakeStep
		repo   *SourceRepository

		outStepA *fakes.FakeStep
		outStepB *fakes.FakeStep

		step    Step
		process ifrit.Process
	)

	BeforeEach(func() {
		fakeStepA = new(fakes.FakeStepFactory)
		fakeStepB = new(fakes.FakeStepFactory)

		aggregate = Aggregate{
			fakeStepA,
			fakeStepB,