Example #1
0
	"github.com/pivotal-golang/lager"
	"github.com/pivotal-golang/lager/lagertest"
)

var _ = Describe("DockerBackend", func() {
	var (
		stagingRequest        cc_messages.StagingRequestFromCC
		downloadBuilderAction models.ActionInterface
		runAction             models.ActionInterface
		config                backend.Config
		logger                lager.Logger
		docker                backend.Backend

		stagingGuid       string
		appId             string
		dockerImageUrl    string
		dockerLoginServer string
		dockerUser        string
		dockerPassword    string
		dockerEmail       string
		fileDescriptors   int
		memoryMb          int32
		diskMb            int32
		timeout           int
		egressRules       []*models.SecurityGroupRule
	)

	BeforeEach(func() {
		appId = "bunny"
		dockerImageUrl = "busybox"
		dockerLoginServer = ""
		var mountCgroupsAction = models.EmitProgressFor(
			&models.RunAction{
				Path: "/tmp/docker_app_lifecycle/mount_cgroups",
				ResourceLimits: &models.ResourceLimits{
					Nofile: &fileDescriptorLimit,
				},
				User: "******",
			},
			"Preparing docker daemon...",
			"",
			"Failed to set up docker environment",
		)

		var (
			dockerBackend     backend.Backend
			dockerRegistryIPs []string
			consulCluster     *ghttp.Server
			stagingRequest    cc_messages.StagingRequestFromCC
		)

		BeforeEach(func() {
			dockerRegistryIPs = []string{"10.244.2.6", "10.244.2.7"}
			consulCluster = newConsulCluster(dockerRegistryIPs)
		})

		Context("user did not opt-in for docker image caching", func() {
			BeforeEach(func() {
				dockerBackend = setupDockerBackend(validDockerRegistryAddress, []string{}, consulCluster)
				stagingRequest = setupStagingRequest(false, "", "", "", "")
			})

			It("creates a cf-app-docker-staging Task with no additional egress rules", func() {
)

var _ = Describe("TraditionalBackend", func() {
	var (
		traditional                    backend.Backend
		stagingRequest                 cc_messages.StagingRequestFromCC
		config                         backend.Config
		buildpackOrder                 string
		timeout                        int
		stack                          string
		memoryMb                       int32
		diskMb                         int32
		fileDescriptors                int
		buildArtifactsCacheDownloadUri string
		appId                          string
		stagingGuid                    string
		buildpacks                     []cc_messages.Buildpack
		appBitsDownloadUri             string
		downloadBuilderAction          models.ActionInterface
		downloadAppAction              models.ActionInterface
		downloadFirstBuildpackAction   models.ActionInterface
		downloadSecondBuildpackAction  models.ActionInterface
		downloadBuildArtifactsAction   models.ActionInterface
		runAction                      models.ActionInterface
		uploadDropletAction            models.ActionInterface
		uploadBuildArtifactsAction     models.ActionInterface
		egressRules                    []*models.SecurityGroupRule
		environment                    []*models.EnvironmentVariable
	)

	BeforeEach(func() {
		stagerURL := "http://the-stager.example.com"
			LifecycleData:   &lifecycleData,
		}
	}

	BeforeEach(func() {
		loginServer = ""
		user = ""
		password = ""
		email = ""
	})

	Context("when docker registry is running", func() {
		var (
			downloadBuilderAction  models.ActionInterface
			docker                 backend.Backend
			expectedRunAction      models.ActionInterface
			expectedEgressRules    []*models.SecurityGroupRule
			insecureDockerRegistry bool
			stagingRequest         cc_messages.StagingRequestFromCC
		)

		setupEgressRules := func(ips []string) []*models.SecurityGroupRule {
			rules := []*models.SecurityGroupRule{}
			for _, ip := range ips {
				rules = append(rules, &models.SecurityGroupRule{
					Protocol:     models.TCPProtocol,
					Destinations: []string{ip},
					Ports:        []uint32{dockerRegistryPort},
				})
			}
			return rules
		}