Exemplo n.º 1
0
			})

			It("drives a container lifecycle", func() {
				err := gardenChecker.Healthcheck(logger)

				By("Fetching any pre-existing healthcheck containers")
				Expect(gardenClient.ContainersCallCount()).To(Equal(1))

				By("Deleting all pre-existing-containers")
				//call count is two because we also expect to destroy the container we create
				Expect(gardenClient.DestroyCallCount()).To(Equal(2))
				guid := gardenClient.DestroyArgsForCall(0)
				Expect(guid).To(Equal("old-guid"))

				By("Creates the container")
				Expect(gardenClient.CreateCallCount()).To(Equal(1))
				containerSpec := gardenClient.CreateArgsForCall(0)
				Expect(containerSpec).To(Equal(garden.ContainerSpec{
					Handle:     "executor-healthcheck-abc-123",
					RootFSPath: rootfsPath,
					Properties: garden.Properties{
						gardenstore.ContainerOwnerProperty:                          containerOwnerName,
						gardenstore.TagPropertyPrefix + gardenhealth.HealthcheckTag: gardenhealth.HealthcheckTagValue,
					},
				}))

				By("Runs the process")
				Expect(fakeContainer.RunCallCount()).To(Equal(1))

				procSpec, procIO := fakeContainer.RunArgsForCall(0)
				Expect(procSpec).To(Equal(healthcheckSpec))
Exemplo n.º 2
0
				Context("when creating the garden container works", func() {
					var fakeContainer *gfakes.FakeContainer

					BeforeEach(func() {
						fakeContainer = new(gfakes.FakeContainer)
						fakeContainer.HandleReturns("some-handle")

						fakeGardenClient.CreateReturns(fakeContainer, nil)
					})

					It("succeeds", func() {
						Expect(createErr).NotTo(HaveOccurred())
					})

					It("creates the container with the Garden client", func() {
						Expect(fakeGardenClient.CreateCallCount()).To(Equal(1))
						Expect(fakeGardenClient.CreateArgsForCall(0)).To(Equal(garden.ContainerSpec{
							RootFSPath: "some-resource-image",
							Privileged: true,
							Properties: garden.Properties{},
						}))
					})

					It("creates the container info in the database", func() {
						expectedIdentifier := db.ContainerIdentifier(id)
						expectedIdentifier.WorkerName = "my-garden-worker"

						container := db.Container{
							Handle:              "some-handle",
							ContainerIdentifier: expectedIdentifier,
						}
Exemplo n.º 3
0
				Context("when creating works", func() {
					var fakeContainer *gfakes.FakeContainer

					BeforeEach(func() {
						fakeContainer = new(gfakes.FakeContainer)
						fakeContainer.HandleReturns("some-handle")

						fakeGardenClient.CreateReturns(fakeContainer, nil)
					})

					It("succeeds", func() {
						Ω(createErr).ShouldNot(HaveOccurred())
					})

					It("creates the container with the Garden client", func() {
						Ω(fakeGardenClient.CreateCallCount()).Should(Equal(1))
						Ω(fakeGardenClient.CreateArgsForCall(0)).Should(Equal(garden.ContainerSpec{
							RootFSPath: "some-resource-image",
							Privileged: true,
							Properties: garden.Properties{
								"concourse:type":          "get",
								"concourse:pipeline-name": "some-pipeline",
								"concourse:location":      "3",
								"concourse:check-type":    "some-check-type",
								"concourse:check-source":  "{\"some\":\"source\"}",
								"concourse:name":          "some-name",
								"concourse:build-id":      "42",
							},
						}))
					})