Skip to content

Commit

Permalink
Rootless creation on overlay
Browse files Browse the repository at this point in the history
[finishes #140663715]

Signed-off-by: Gareth Clay <[email protected]>
  • Loading branch information
MissingRoberto authored and spikymonkey committed Apr 5, 2017
1 parent b327bd2 commit e1de76d
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 68 deletions.
5 changes: 5 additions & 0 deletions hack/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ run_all_tests() {
export GROOTFS_TEST_GID=0
fly_integration_tests "integration"

export VOLUME_DRIVER="overlay-xfs"
export GROOTFS_TEST_UID=1000
export GROOTFS_TEST_GID=1000
fly_integration_tests "integration"

export VOLUME_DRIVER="btrfs"
export GROOTFS_TEST_UID=0
export GROOTFS_TEST_GID=0
Expand Down
4 changes: 4 additions & 0 deletions integration/clean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import (
)

var _ = Describe("Clean", func() {
BeforeEach(func() {
integration.SkipIfNonRootAndNotBTRFS(GrootfsTestUid, Driver)
})

Context("Local Images", func() {
var (
baseImagePath string
Expand Down
2 changes: 2 additions & 0 deletions integration/create_concurrency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import (
"sync"

"code.cloudfoundry.org/grootfs/groot"
"code.cloudfoundry.org/grootfs/integration"

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

var _ = Describe("Concurrent creations", func() {
BeforeEach(func() {
integration.SkipIfNonRootAndNotBTRFS(GrootfsTestUid, Driver)
// run this to setup the store before concurrency!
_, err := Runner.Create(groot.CreateSpec{
ID: "test-pre-warm",
Expand Down
28 changes: 23 additions & 5 deletions integration/create_local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ var _ = Describe("Create with local images", func() {
spec = groot.CreateSpec{
BaseImage: baseImagePath,
ID: "random-id",
Mount: true,
Mount: mountByDefault(),
Json: true,
}
})

It("creates a root filesystem", func() {
image, err := Runner.Create(spec)
Expect(err).NotTo(HaveOccurred())

Expect(Runner.EnsureMounted(image)).To(Succeed())

imageContentPath := path.Join(image.Rootfs, "foo")
Expect(imageContentPath).To(BeARegularFile())

fooContents, err := ioutil.ReadFile(imageContentPath)
Expect(err).NotTo(HaveOccurred())
Expect(string(fooContents)).To(Equal("hello-world"))
Expand All @@ -66,6 +70,7 @@ var _ = Describe("Create with local images", func() {
It("keeps folders original permissions", func() {
image, err := Runner.Create(spec)
Expect(err).NotTo(HaveOccurred())
Expect(Runner.EnsureMounted(image)).To(Succeed())

permissiveFolderPath := path.Join(image.Rootfs, "permissive-folder")
stat, err := os.Stat(permissiveFolderPath)
Expand All @@ -81,9 +86,11 @@ var _ = Describe("Create with local images", func() {
image2, err := Runner.Create(groot.CreateSpec{
ID: "another-random-id",
BaseImage: baseImagePath,
Mount: true,
Mount: false,
Json: true,
})
Expect(err).NotTo(HaveOccurred())

Expect(ioutil.WriteFile(filepath.Join(image1.Rootfs, "new-file"), []byte("hello-world"), 0644)).To(Succeed())
Expect(filepath.Join(image2.Rootfs, "new-file")).NotTo(BeARegularFile())
})
Expand All @@ -104,6 +111,7 @@ var _ = Describe("Create with local images", func() {
It("preserves the timestamps", func() {
image, err := Runner.Create(spec)
Expect(err).NotTo(HaveOccurred())
Expect(Runner.EnsureMounted(image)).To(Succeed())

imageOldFilePath := path.Join(image.Rootfs, "old-file")
fi, err := os.Stat(imageOldFilePath)
Expand All @@ -114,10 +122,12 @@ var _ = Describe("Create with local images", func() {

Describe("clean up on create", func() {
JustBeforeEach(func() {
integration.SkipIfNonRootAndNotBTRFS(GrootfsTestUid, Driver)
_, err := Runner.Create(groot.CreateSpec{
ID: "my-image-1",
BaseImage: baseImagePath,
Mount: true,
Json: true,
})
Expect(err).NotTo(HaveOccurred())

Expand All @@ -136,6 +146,7 @@ var _ = Describe("Create with local images", func() {
ID: "my-image-2",
BaseImage: baseImage2Path,
Mount: true,
Json: true,
}
_, err := Runner.Create(createSpec)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -222,9 +233,11 @@ var _ = Describe("Create with local images", func() {
image, err := Runner.Create(groot.CreateSpec{
ID: "random-id-2",
BaseImage: baseImagePath,
Mount: true,
Mount: mountByDefault(),
Json: true,
})
Expect(err).NotTo(HaveOccurred())
Expect(Runner.EnsureMounted(image)).To(Succeed())

imageContentPath := path.Join(image.Rootfs, "foo")
Expect(imageContentPath).To(BeARegularFile())
Expand All @@ -245,8 +258,10 @@ var _ = Describe("Create with local images", func() {
image, err := Runner.Create(groot.CreateSpec{
ID: "random-id-2",
BaseImage: baseImagePath,
Mount: true,
Mount: mountByDefault(),
Json: true,
})
Expect(Runner.EnsureMounted(image)).To(Succeed())
Expect(err).NotTo(HaveOccurred())
Expect(path.Join(image.Rootfs, "foo")).To(BeARegularFile())
Expect(path.Join(image.Rootfs, "injected-file")).To(BeARegularFile())
Expand All @@ -258,7 +273,8 @@ var _ = Describe("Create with local images", func() {
_, err := Runner.Create(groot.CreateSpec{
BaseImage: "/invalid/image",
ID: "random-id",
Mount: true,
Mount: false,
Json: true,
})
Expect(err).To(MatchError(ContainSubstring("stat /invalid/image: no such file or directory")))
})
Expand All @@ -278,6 +294,7 @@ var _ = Describe("Create with local images", func() {
It("unpacks the symlinks", func() {
image, err := Runner.Create(spec)
Expect(err).NotTo(HaveOccurred())
Expect(Runner.EnsureMounted(image)).To(Succeed())

content, err := ioutil.ReadFile(filepath.Join(image.Rootfs, "symlink"))
Expect(err).NotTo(HaveOccurred())
Expand All @@ -295,6 +312,7 @@ var _ = Describe("Create with local images", func() {
It("preserves the timestamps", func() {
image, err := Runner.Create(spec)
Expect(err).NotTo(HaveOccurred())
Expect(Runner.EnsureMounted(image)).To(Succeed())

symlinkTargetFilePath := path.Join(image.Rootfs, "symlink-target")
symlinkTargetFi, err := os.Stat(symlinkTargetFilePath)
Expand Down
5 changes: 5 additions & 0 deletions integration/create_remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"code.cloudfoundry.org/grootfs/commands/config"
"code.cloudfoundry.org/grootfs/groot"
"code.cloudfoundry.org/grootfs/integration"
"code.cloudfoundry.org/grootfs/store"
"code.cloudfoundry.org/grootfs/testhelpers"
"code.cloudfoundry.org/lager"
Expand All @@ -32,6 +33,10 @@ import (
)

var _ = Describe("Create with remote images", func() {
BeforeEach(func() {
integration.SkipIfNonRootAndNotBTRFS(GrootfsTestUid, Driver)
})

var baseImageURL string

Context("when using the default registry", func() {
Expand Down
Loading

0 comments on commit e1de76d

Please sign in to comment.