Beispiel #1
0
		AfterEach(func() {
			Expect(os.RemoveAll(symlinkPath)).To(Succeed())
		})

		It("returns a ID of the symlinked directory", func() {
			pathID := idp.ProvideID(path1)
			symlinkID := idp.ProvideID(symlinkPath)
			Expect(symlinkID).To(Equal(pathID))
		})
	})
})

var _ = Describe("Local", func() {
	var (
		fetcher           *repository_fetcher.Local
		fakeCake          *fake_cake.FakeCake
		defaultRootFSPath string
		idProvider        UnderscoreIDer
	)

	BeforeEach(func() {
		fakeCake = new(fake_cake.FakeCake)
		defaultRootFSPath = ""
		idProvider = UnderscoreIDer{}

		// default to not containing an image
		fakeCake.GetReturns(nil, errors.New("no image"))
	})

	JustBeforeEach(func() {
		fetcher = &repository_fetcher.Local{
			Cake:              fakeCake,
	"code.cloudfoundry.org/garden-shed/repository_fetcher"
	"code.cloudfoundry.org/garden-shed/rootfs_provider"
	fakes "code.cloudfoundry.org/garden-shed/rootfs_provider/rootfs_providerfakes"
	"code.cloudfoundry.org/lager"
	"code.cloudfoundry.org/lager/lagertest"

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

var _ = Describe("The Cake Co-ordinator", func() {
	var (
		fakeFetcher      *fakes.FakeRepositoryFetcher
		fakeLayerCreator *fakes.FakeLayerCreator
		fakeCake         *fake_cake.FakeCake
		fakeGCer         *fakes.FakeGCer
		fakeMetrics      *fakes.FakeMetricser
		logger           *lagertest.TestLogger

		cakeOrdinator *rootfs_provider.CakeOrdinator
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")

		fakeFetcher = new(fakes.FakeRepositoryFetcher)

		fakeLayerCreator = new(fakes.FakeLayerCreator)
		fakeCake = new(fake_cake.FakeCake)
		fakeGCer = new(fakes.FakeGCer)
		fakeMetrics = new(fakes.FakeMetricser)
		cakeOrdinator = rootfs_provider.NewCakeOrdinator(fakeCake, fakeFetcher, fakeLayerCreator, fakeMetrics, fakeGCer)
	"code.cloudfoundry.org/garden-shed/layercake/cleaner"
	fakes "code.cloudfoundry.org/garden-shed/layercake/cleaner/cleanerfakes"
	"code.cloudfoundry.org/garden-shed/layercake/fake_cake"
	"code.cloudfoundry.org/lager"
	"code.cloudfoundry.org/lager/lagertest"
	"github.com/docker/docker/image"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Oven cleaner", func() {
	var (
		retainer      cleaner.RetainChecker
		gc            *cleaner.OvenCleaner
		fakeCake      *fake_cake.FakeCake
		child2parent  map[layercake.ID]layercake.ID // child -> parent
		size          map[layercake.ID]int64
		fakeThreshold *fakes.FakeThreshold
		logger        lager.Logger
	)

	BeforeEach(func() {
		fakeThreshold = new(fakes.FakeThreshold)
		logger = lagertest.NewTestLogger("test")

		retainer = cleaner.NewRetainer()

		fakeCake = new(fake_cake.FakeCake)
		fakeCake.GetStub = func(id layercake.ID) (*image.Image, error) {
			if parent, ok := child2parent[id]; ok {
				return &image.Image{
package cleaner_test

import (
	"code.cloudfoundry.org/garden-shed/layercake/cleaner"
	"code.cloudfoundry.org/garden-shed/layercake/fake_cake"
	"code.cloudfoundry.org/lager"
	"code.cloudfoundry.org/lager/lagertest"
	"github.com/docker/docker/image"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Threshold", func() {
	var (
		fakeCake  *fake_cake.FakeCake
		logger    lager.Logger
		threshold int64
	)

	BeforeEach(func() {
		threshold = 1234
		fakeCake = new(fake_cake.FakeCake)
		logger = lagertest.NewTestLogger("test")
	})

	Context("when there are no layers in the graph", func() {
		It("is not exceeded", func() {
			threshold := cleaner.NewThreshold(threshold)
			Expect(threshold.Exceeded(logger, fakeCake)).To(BeFalse())
		})
	})
	"code.cloudfoundry.org/garden-shed/layercake"
	"code.cloudfoundry.org/garden-shed/layercake/fake_cake"
	"code.cloudfoundry.org/garden-shed/quota_manager"
	"code.cloudfoundry.org/lager"
	"code.cloudfoundry.org/lager/lagertest"
	"github.com/docker/docker/image"

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

var _ = Describe("AUFSBaseSizer", func() {
	Describe("BaseSize", func() {
		var (
			baseSizer *quota_manager.AUFSBaseSizer
			fakeCake  *fake_cake.FakeCake

			logger lager.Logger
		)

		BeforeEach(func() {
			logger = lagertest.NewTestLogger("test")
			fakeCake = new(fake_cake.FakeCake)
			fakeCake.GetReturns(nil, errors.New("no such image"))

			baseSizer = quota_manager.NewAUFSBaseSizer(fakeCake)
		})

		It("asks for the size of the layer based on the base name of the rootfs path", func() {
			baseSizer.BaseSize(logger, "/some/path/to/54321")
			Expect(fakeCake.GetCallCount()).To(Equal(1))
			Expect(fakeCake.GetArgsForCall(0)).To(Equal(layercake.DockerImageID("54321")))
type RootAndVolume struct {
	RootPath string
	Volume   string
}

func (f *FakeVolumeCreator) Create(path, v string) error {
	f.Created = append(f.Created, RootAndVolume{path, v})
	return f.CreateError
}

var _ = Describe("Layer Creator", func() {
	var (
		fakeCake          *fake_cake.FakeCake
		fakeNamespacer    *fake_namespacer.FakeNamespacer
		fakeVolumeCreator *FakeVolumeCreator
		name              string

		provider *rootfs_provider.ContainerLayerCreator
	)

	BeforeEach(func() {
		fakeCake = new(fake_cake.FakeCake)
		fakeVolumeCreator = &FakeVolumeCreator{}
		fakeNamespacer = &fake_namespacer.FakeNamespacer{}
		name = "some-name"

		provider = rootfs_provider.NewLayerCreator(
			fakeCake,
			fakeVolumeCreator,
			fakeNamespacer,
		)
Beispiel #7
0
	"code.cloudfoundry.org/garden-shed/layercake/fake_id"
	"github.com/cloudfoundry/gunk/command_runner"
	"github.com/cloudfoundry/gunk/command_runner/fake_command_runner"
	"github.com/cloudfoundry/gunk/command_runner/linux_command_runner"
	"github.com/docker/docker/image"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Aufs", func() {
	var (
		aufsCake               *layercake.AufsCake
		cake                   *fake_cake.FakeCake
		parentID               *fake_id.FakeID
		childID                *fake_id.FakeID
		testError              error
		namespacedChildID      layercake.ID
		otherNamespacedChildID layercake.ID
		runner                 command_runner.CommandRunner
		baseDirectory          string
	)

	BeforeEach(func() {
		var err error
		baseDirectory, err = ioutil.TempDir("", "aufsTestGraphRoot")
		Expect(err).NotTo(HaveOccurred())

		cake = new(fake_cake.FakeCake)
		runner = linux_command_runner.New()

		parentID = new(fake_id.FakeID)
	fakes "code.cloudfoundry.org/garden-shed/repository_fetcher/repository_fetcherfakes"
	"code.cloudfoundry.org/lager"
	"code.cloudfoundry.org/lager/lagertest"
	"github.com/docker/distribution/digest"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Fetching from a Remote repo", func() {
	var (
		fakeDialer   *fakes.FakeDialer
		fakeConn     *fake_distclient.FakeConn
		fakeCake     *fake_cake.FakeCake
		fakeVerifier *fakes.FakeVerifier

		remote *repository_fetcher.Remote

		manifests                 map[string]*distclient.Manifest
		blobs                     map[digest.Digest]string
		existingLayers            map[string]bool
		defaultDockerRegistryHost string
	)

	BeforeEach(func() {
		defaultDockerRegistryHost = "registry-1.docker.io"
	})

	JustBeforeEach(func() {
		existingLayers = map[string]bool{}

		manifests = map[string]*distclient.Manifest{