-
Notifications
You must be signed in to change notification settings - Fork 5
/
rootfs_test.go
106 lines (89 loc) · 2.79 KB
/
rootfs_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package garden_integration_tests_test
import (
"os"
"runtime"
"code.cloudfoundry.org/garden"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
)
var _ = Describe("Rootfses", func() {
BeforeEach(func() {
if runtime.GOOS == "windows" {
Skip("pending for windows")
}
})
Context("when the rootfs path is a private azure image URL", func() {
BeforeEach(func() {
imageRef.URI = "docker://gnome.azurecr.io/alpine#3.7"
imageRef.Username = os.Getenv("AZURE_REGISTRY_USERNAME")
imageRef.Password = os.Getenv("AZURE_REGISTRY_PASSWORD")
if imageRef.Username == "" || imageRef.Password == "" {
Skip("Registry username or password not provided")
}
})
It("should succeed", func() {
Expect(containerCreateErr).NotTo(HaveOccurred())
})
})
Context("when the rootfs path is a docker image URL", func() {
Context("and the image specifies $PATH", func() {
BeforeEach(func() {
imageRef.URI = "docker:///cloudfoundry/garden-rootfs"
skipIfWoot("Groot does not place environemnt variables in the bundle spec yet")
})
It("$PATH is taken from the docker image", func() {
stdout := runForStdout(container, garden.ProcessSpec{
User: "root",
Path: "/bin/sh",
Args: []string{"-c", "echo $PATH"},
})
Expect(stdout).To(gbytes.Say("/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/from-dockerfile"))
})
It("$TEST is taken from the docker image", func() {
stdout := runForStdout(container, garden.ProcessSpec{
User: "root",
Path: "/bin/sh",
Args: []string{"-c", "echo $TEST"},
})
Expect(stdout).To(gbytes.Say("second-test-from-dockerfile:test-from-dockerfile"))
})
})
Context("and the image is private", func() {
BeforeEach(func() {
imageRef.URI = "docker:///cloudfoundry/garden-private-image-test"
imageRef.Username = os.Getenv("DOCKER_REGISTRY_USERNAME")
imageRef.Password = os.Getenv("DOCKER_REGISTRY_PASSWORD")
if imageRef.Username == "" || imageRef.Password == "" {
Skip("Registry username or password not provided")
}
assertContainerCreate = false
})
It("successfully pulls the image", func() {
Expect(containerCreateErr).ToNot(HaveOccurred())
})
Context("but the credentials are incorrect", func() {
BeforeEach(func() {
imageRef.Username = ""
imageRef.Password = ""
})
It("fails", func() {
Expect(containerCreateErr).NotTo(Succeed())
})
})
})
})
Context("and the Docker image contains opaque whiteouts", func() {
BeforeEach(func() {
imageRef.URI = "docker:///cloudfoundry/garden-rootfs"
})
It("handles them correctly", func() {
exitCode, _, _ := runProcess(container,
garden.ProcessSpec{
Path: "ls",
Args: []string{"/test/foo"},
})
Expect(exitCode).To(Equal(0))
})
})
})