Beispiel #1
0
	"github.com/cloudfoundry-incubator/bbs/models"
	"github.com/cloudfoundry-incubator/garden"
	gfakes "github.com/cloudfoundry-incubator/garden/fakes"
	"github.com/pivotal-golang/clock/fakeclock"

	"github.com/cloudfoundry-incubator/executor"
	"github.com/cloudfoundry-incubator/executor/depot/log_streamer/fake_log_streamer"
	"github.com/cloudfoundry-incubator/executor/depot/steps"
	"github.com/cloudfoundry-incubator/executor/fakes"
)

var _ = Describe("RunAction", func() {
	var step steps.Step

	var runAction models.RunAction
	var fakeStreamer *fake_log_streamer.FakeLogStreamer
	var gardenClient *fakes.FakeGardenClient
	var logger *lagertest.TestLogger
	var fileDescriptorLimit uint64
	var externalIP string
	var portMappings []executor.PortMapping
	var exportNetworkEnvVars bool
	var fakeClock *fakeclock.FakeClock

	var spawnedProcess *gfakes.FakeProcess
	var runError error

	BeforeEach(func() {
		fileDescriptorLimit = 17
Beispiel #2
0
			}`,
			models.WrapAction(&models.RunAction{
				User: "******",
				Path: "rm",
				Dir:  "./some-dir",
				Args: []string{"-rf", "/"},
				Env: []*models.EnvironmentVariable{
					{"FOO", "1"},
					{"BAR", "2"},
				},
				ResourceLimits: &models.ResourceLimits{Nofile: &nofile},
			}),
		)

		Describe("Validate", func() {
			var runAction *models.RunAction

			Context("when the action has the required fields", func() {
				It("is valid", func() {
					runAction = &models.RunAction{
						Path: "ls",
						User: "******",
					}

					err := runAction.Validate()
					Expect(err).NotTo(HaveOccurred())
				})
			})

			for _, testCase := range []ValidatorErrorCase{
				{
			Expect(actions[0].GetEmitProgressAction()).To(Equal(downloadBuilderAction))
			Expect(actions[1].GetEmitProgressAction()).To(Equal(expectedRunAction))
		}

		Context("user did not opt-in for docker image caching", func() {
			It("creates a cf-app-docker-staging Task with no additional egress rules", func() {
				taskDef, _, _, err := docker.BuildRecipe(stagingGuid, stagingRequest)
				Expect(err).NotTo(HaveOccurred())
				Expect(taskDef.EgressRules).To(BeEmpty())
			})
		})

		Context("user opted-in for docker image caching", func() {
			modelsCachingVar := &models.EnvironmentVariable{Name: "DIEGO_DOCKER_CACHE", Value: "true"}
			var (
				internalRunAction models.RunAction
			)

			JustBeforeEach(func() {
				cachingVar := &models.EnvironmentVariable{Name: "DIEGO_DOCKER_CACHE", Value: "true"}
				stagingRequest.Environment = append(stagingRequest.Environment, cachingVar)
				fileDescriptorLimit := uint64(512)
				internalRunAction = models.RunAction{
					Path: "/tmp/docker_app_lifecycle/builder",
					Args: []string{
						"-outputMetadataJSONFilename",
						"/tmp/docker-result/result.json",
						"-dockerRef",
						"busybox",
						"-cacheDockerImage",
						"-dockerRegistryHost",