Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions integration_tests/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2464,6 +2464,11 @@ RUN cp /random-data.bin /data/realBaseImage.bin
contextDir := setupTestContext(t)
writeContainerfile(contextDir, fmt.Sprintf("FROM %s\n", baseImage))

// Use a clean container storage dir for this test to ensure the image gets pulled
containerStorage, err := createContainerStorageDir()
t.Cleanup(func() { removeContainerStorageDir(containerStorage) })
Expect(err).ToNot(HaveOccurred())

outputRef := "localhost/test-image-pull-proxy:" + GenerateUniqueTag(t)

buildParams := BuildParams{
Expand All @@ -2473,9 +2478,10 @@ RUN cp /random-data.bin /data/realBaseImage.bin
ImagePullProxy: "http://" + proxyAddr,
}

container := setupBuildContainerWithCleanup(t, buildParams, nil)
container := setupBuildContainerWithCleanup(t, buildParams, nil,
maybeMountContainerStorage(containerStorage, "taskuser"))

err := runBuild(container, buildParams)
err = runBuild(container, buildParams)
Expect(err).ToNot(HaveOccurred())

_, proxiedRegistry := connectedHosts.Load("registry.access.redhat.com:443")
Expand Down
21 changes: 15 additions & 6 deletions integration_tests/framework/runner_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type TestRunnerContainer struct {
user string
privileged bool
env map[string]string
volumes map[string]string
volumes map[string]hostMount // container dir => (host dir, options)
ports map[string]string
networks []string
results map[string]string
Expand All @@ -43,6 +43,11 @@ type TestRunnerContainer struct {
containerStatus ContainerStatus
}

type hostMount struct {
path string
options string
}

// ContainerOption is a functional-style option for configuring TestRunnerContainer.
type ContainerOption func(*TestRunnerContainer)

Expand All @@ -54,7 +59,7 @@ func NewTestRunnerContainer(name, image string, opts ...ContainerOption) *TestRu
name: name,
image: image,
env: make(map[string]string),
volumes: make(map[string]string),
volumes: make(map[string]hostMount),
ports: make(map[string]string),
results: make(map[string]string),
}
Expand Down Expand Up @@ -133,7 +138,7 @@ func WithEnv(key, value string) ContainerOption {

func (c *TestRunnerContainer) AddVolume(hostPath, containerPath string) {
c.ensureContainerNotStarted()
c.volumes[hostPath] = containerPath
c.volumes[containerPath] = hostMount{path: hostPath}
}

func WithVolume(hostPath, containerPath string) ContainerOption {
Expand All @@ -144,7 +149,7 @@ func WithVolume(hostPath, containerPath string) ContainerOption {

func (c *TestRunnerContainer) AddVolumeWithOptions(hostPath, containerPath, mountOptions string) {
c.ensureContainerNotStarted()
c.volumes[hostPath] = containerPath + ":" + mountOptions
c.volumes[containerPath] = hostMount{path: hostPath, options: mountOptions}
}

func WithVolumeWithOptions(hostPath, containerPath, mountOptions string) ContainerOption {
Expand Down Expand Up @@ -220,8 +225,12 @@ func (c *TestRunnerContainer) Start() error {
for name, value := range c.env {
args = append(args, "-e", name+"="+value)
}
for hostPath, containerPath := range c.volumes {
args = append(args, "-v", hostPath+":"+containerPath)
for containerPath, mount := range c.volumes {
volumeArg := mount.path + ":" + containerPath
if mount.options != "" {
volumeArg += ":" + mount.options
}
args = append(args, "-v", volumeArg)
}
for hostPort, containerPort := range c.ports {
args = append(args, "-p", hostPort+":"+containerPort)
Expand Down