Example #1
0
import (
	"errors"
	"io/ioutil"
	"net/http"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/concourse/atc"
	"github.com/concourse/atc/db"
	dbfakes "github.com/concourse/atc/db/fakes"
)

var _ = Describe("Resources API", func() {
	var pipelineDB *dbfakes.FakePipelineDB

	BeforeEach(func() {
		pipelineDB = new(dbfakes.FakePipelineDB)
		pipelineDBFactory.BuildWithNameReturns(pipelineDB, nil)
	})

	Describe("GET /api/v1/pipelines/:pipeline_name/resources", func() {
		var response *http.Response

		JustBeforeEach(func() {
			var err error

			response, err = client.Get(server.URL + "/api/v1/pipelines/a-pipeline/resources")
			Expect(err).NotTo(HaveOccurred())
Example #2
0
				Expect(response.StatusCode).To(Equal(http.StatusInternalServerError))
			})
		})

		It("looks up the pipeline in the db via the url param", func() {
			Expect(pipelinesDB.GetPipelineByTeamNameAndNameCallCount()).To(Equal(1))

			teamName, actualPipelineName := pipelinesDB.GetPipelineByTeamNameAndNameArgsForCall(0)
			Expect(actualPipelineName).To(Equal("some-specific-pipeline"))
			Expect(teamName).To(Equal(atc.DefaultTeamName))
		})
	})

	Describe("DELETE /api/v1/pipelines/:pipeline_name", func() {
		var response *http.Response
		var pipelineDB *dbfakes.FakePipelineDB

		BeforeEach(func() {
			pipelineDB = new(dbfakes.FakePipelineDB)

			pipelineDBFactory.BuildWithTeamNameAndNameReturns(pipelineDB, nil)
		})

		JustBeforeEach(func() {
			pipelineName := "a-pipeline-name"
			req, err := http.NewRequest("DELETE", server.URL+"/api/v1/pipelines/"+pipelineName, nil)
			Expect(err).NotTo(HaveOccurred())

			req.Header.Set("Content-Type", "application/json")

			response, err = client.Do(req)
Example #3
0
	"net/http"
	"time"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/concourse/atc"
	"github.com/concourse/atc/config"
	"github.com/concourse/atc/db"
	"github.com/concourse/atc/db/algorithm"
	dbfakes "github.com/concourse/atc/db/fakes"
	schedulerfakes "github.com/concourse/atc/scheduler/fakes"
)

var _ = Describe("Jobs API", func() {
	var pipelineDB *dbfakes.FakePipelineDB

	BeforeEach(func() {
		pipelineDB = new(dbfakes.FakePipelineDB)
		pipelineDBFactory.BuildWithTeamNameAndNameReturns(pipelineDB, nil)
	})

	Describe("GET /api/v1/pipelines/:pipeline_name/jobs/:job_name", func() {
		var response *http.Response

		JustBeforeEach(func() {
			var err error

			response, err = client.Get(server.URL + "/api/v1/pipelines/some-pipeline/jobs/some-job")
			Expect(err).NotTo(HaveOccurred())
Example #4
0
	"github.com/pivotal-golang/lager"
	"github.com/pivotal-golang/lager/lagertest"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/ginkgomon"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Runner", func() {
	var (
		locker     *fakes.FakeLocker
		pipelineDB *dbfakes.FakePipelineDB
		scheduler  *fakes.FakeBuildScheduler
		noop       bool

		lock *dbfakes.FakeLock

		initialConfig atc.Config

		process ifrit.Process
	)

	BeforeEach(func() {
		locker = new(fakes.FakeLocker)
		pipelineDB = new(dbfakes.FakePipelineDB)
		scheduler = new(fakes.FakeBuildScheduler)
		noop = false

		scheduler.TryNextPendingBuildStub = func(lager.Logger, atc.JobConfig, atc.ResourceConfigs) Waiter {
			return new(sync.WaitGroup)
		}
)

var _ = Describe("Baggage-collecting image resource volumes", func() {
	Context("when there is a single job", func() {
		var (
			fakeWorkerClient *wfakes.FakeClient
			workerA          *wfakes.FakeWorker

			workerB                   *wfakes.FakeWorker
			workerBBaggageClaimClient *bcfakes.FakeClient
			dockerVolume              *bcfakes.FakeVolume

			workerC                   *wfakes.FakeWorker
			workerCBaggageClaimClient *bcfakes.FakeClient
			crossedWiresVolume        *bcfakes.FakeVolume

			fakeBaggageCollectorDB *fakes.FakeBaggageCollectorDB
			fakePipelineDBFactory  *dbfakes.FakePipelineDBFactory

			expectedOldVersionTTL    = 4 * time.Minute
			expectedLatestVersionTTL = time.Duration(0)
			expectedOneOffTTL        = 5 * time.Hour

			baggageCollector lostandfound.BaggageCollector

			savedPipeline  db.SavedPipeline
			fakePipelineDB *dbfakes.FakePipelineDB
		)

		BeforeEach(func() {
			fakeWorkerClient = new(wfakes.FakeClient)
Example #6
0
import (
	"encoding/json"
	"errors"
	"io/ioutil"
	"net/http"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/concourse/atc"
	"github.com/concourse/atc/db"
	dbfakes "github.com/concourse/atc/db/fakes"
)

var _ = Describe("Jobs API", func() {
	var pipelineDB *dbfakes.FakePipelineDB

	BeforeEach(func() {
		pipelineDB = new(dbfakes.FakePipelineDB)
		pipelineDBFactory.BuildWithNameReturns(pipelineDB, nil)
	})

	Describe("GET /api/v1/pipelines/:pipeline_name/jobs/:job_name", func() {
		var response *http.Response

		JustBeforeEach(func() {
			var err error

			response, err = client.Get(server.URL + "/api/v1/pipelines/some-pipeline/jobs/some-job")
			Ω(err).ShouldNot(HaveOccurred())
	wfakes "github.com/concourse/atc/worker/fakes"
	bcfakes "github.com/concourse/baggageclaim/fakes"
)

var _ = Describe("Baggage-collecting image resource volumes created by one-off builds", func() {

	var (
		fakeWorkerClient *wfakes.FakeClient
		worker1          *wfakes.FakeWorker

		worker2             *wfakes.FakeWorker
		baggageClaimClient2 *bcfakes.FakeClient
		volume2             *bcfakes.FakeVolume

		fakeBaggageCollectorDB *fakes.FakeBaggageCollectorDB
		fakePipelineDBFactory  *dbfakes.FakePipelineDBFactory

		expectedOldVersionTTL    = 4 * time.Minute
		expectedLatestVersionTTL = time.Duration(0)
		expectedOneOffTTL        = 5 * time.Hour

		baggageCollector lostandfound.BaggageCollector

		savedPipeline  db.SavedPipeline
		fakePipelineDB *dbfakes.FakePipelineDB
	)

	BeforeEach(func() {
		fakeWorkerClient = new(wfakes.FakeClient)

		worker1 = new(wfakes.FakeWorker)
Example #8
0
	"github.com/pivotal-golang/lager"
	"github.com/pivotal-golang/lager/lagertest"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/ginkgomon"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Runner", func() {
	var (
		locker     *fakes.FakeLocker
		pipelineDB *dbfakes.FakePipelineDB
		scheduler  *fakes.FakeBuildScheduler
		noop       bool

		lock *dbfakes.FakeLock

		initialConfig atc.Config

		process ifrit.Process
	)

	BeforeEach(func() {
		locker = new(fakes.FakeLocker)
		pipelineDB = new(dbfakes.FakePipelineDB)
		scheduler = new(fakes.FakeBuildScheduler)
		noop = false

		scheduler.TryNextPendingBuildStub = func(lager.Logger, atc.JobConfig, atc.ResourceConfigs) Waiter {
			return new(sync.WaitGroup)
		}
Example #9
0
	"github.com/pivotal-golang/lager/lagertest"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/ginkgomon"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Runner", func() {
	var (
		pipelineDB *dbfakes.FakePipelineDB
		scheduler  *fakes.FakeBuildScheduler
		noop       bool

		lease *dbfakes.FakeLease

		initialConfig atc.Config

		someVersions *algorithm.VersionsDB

		process ifrit.Process
	)

	BeforeEach(func() {
		pipelineDB = new(dbfakes.FakePipelineDB)
		pipelineDB.GetPipelineNameReturns("some-pipeline")
		scheduler = new(fakes.FakeBuildScheduler)
		noop = false

		someVersions = &algorithm.VersionsDB{
			BuildOutputs: []algorithm.BuildOutput{
Example #10
0
	"net/http"
	"time"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/concourse/atc"
	"github.com/concourse/atc/config"
	"github.com/concourse/atc/db"
	"github.com/concourse/atc/db/algorithm"
	dbfakes "github.com/concourse/atc/db/fakes"
	schedulerfakes "github.com/concourse/atc/scheduler/fakes"
)

var _ = Describe("Jobs API", func() {
	var pipelineDB *dbfakes.FakePipelineDB

	BeforeEach(func() {
		pipelineDB = new(dbfakes.FakePipelineDB)
		pipelineDBFactory.BuildWithNameReturns(pipelineDB, nil)
	})

	Describe("GET /api/v1/pipelines/:pipeline_name/jobs/:job_name", func() {
		var response *http.Response

		JustBeforeEach(func() {
			var err error

			response, err = client.Get(server.URL + "/api/v1/pipelines/some-pipeline/jobs/some-job")
			Expect(err).NotTo(HaveOccurred())
Example #11
0
	"github.com/pivotal-golang/lager"
	"github.com/pivotal-golang/lager/lagertest"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/ginkgomon"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Runner", func() {
	var (
		locker         *fakes.FakeLocker
		pipelineDB     *dbfakes.FakePipelineDB
		scannerFactory *fakes.FakeScannerFactory
		noop           bool
		syncInterval   time.Duration

		initialConfig atc.Config

		process ifrit.Process
	)

	BeforeEach(func() {
		locker = new(fakes.FakeLocker)
		scannerFactory = new(fakes.FakeScannerFactory)
		pipelineDB = new(dbfakes.FakePipelineDB)
		noop = false
		syncInterval = 100 * time.Millisecond

		initialConfig = atc.Config{
			Resources: atc.ResourceConfigs{
				for name, data := range example.pipelineData {
					config := atc.Config{}

					for _, resourceData := range data {
						config.Resources = append(config.Resources, resourceData.config)
					}

					savedPipelines = append(savedPipelines, db.SavedPipeline{
						Pipeline: db.Pipeline{
							Name:   name,
							Config: config,
						},
					})

					fakePipelineDB := new(dbfakes.FakePipelineDB)

					savedVersionsForEachResource := make(map[string][]db.SavedVersionedResource)

					for _, resourceInfo := range data {
						var savedVersions []db.SavedVersionedResource

						for i, version := range resourceInfo.versions {
							disabled := false
							for _, j := range resourceInfo.versionsToDisable {
								if i == j {
									disabled = true
								}
							}

							if !disabled {
Example #13
0
			Ω(body).Should(MatchJSON(`[
      {
        "name": "a-pipeline",
        "url": "/pipelines/a-pipeline",
				"paused": false
      },{
        "name": "another-pipeline",
        "url": "/pipelines/another-pipeline",
				"paused": true
      }]`))
		})
	})

	Describe("DELETE /api/v1/pipelines/:pipeline_name", func() {
		var response *http.Response
		var pipelineDB *dbfakes.FakePipelineDB

		BeforeEach(func() {
			pipelineDB = new(dbfakes.FakePipelineDB)

			pipelineDBFactory.BuildWithNameReturns(pipelineDB, nil)
		})

		JustBeforeEach(func() {
			pipelineName := "a-pipeline-name"
			req, err := http.NewRequest("DELETE", server.URL+"/api/v1/pipelines/"+pipelineName, nil)
			Ω(err).ShouldNot(HaveOccurred())

			req.Header.Set("Content-Type", "application/json")

			response, err = client.Do(req)
			},
			ID:        123,
			ExpiresIn: expectedOldResourceGracePeriod,
		}

		returnedVolumes = []db.SavedVolume{returnedSavedVolume}
	})

	JustBeforeEach(func() {
		fakeBaggageCollectorDB.GetVolumesReturns(returnedVolumes, nil)
	})

	Context("when the worker for a newest resource no longer exists", func() {
		var (
			fakeSavedPipeline          db.SavedPipeline
			fakePipelineDB             dbfakes.FakePipelineDB
			fakeSavedVersionedResource db.SavedVersionedResource
		)

		BeforeEach(func() {
			fakeSavedPipeline = db.SavedPipeline{
				Pipeline: db.Pipeline{
					Name: "some-pipeline",
					Config: atc.Config{
						Resources: atc.ResourceConfigs{
							atc.ResourceConfig{
								Name:   "our-resource",
								Type:   "git",
								Source: atc.Source{"some": "source"},
							},
						},