diff --git a/integration/images.go b/integration/images.go index ea5d1f464..3c3f0ccd7 100644 --- a/integration/images.go +++ b/integration/images.go @@ -167,6 +167,7 @@ type DockerFileBuilder struct { func NewDockerFileBuilder() *DockerFileBuilder { d := DockerFileBuilder{filesBuilt: map[string]struct{}{}} d.DockerfilesToIgnore = map[string]struct{}{ + "Dockerfile_test_add_404": {}, // TODO: remove test_user_run from this when https://github.com/GoogleContainerTools/container-diff/issues/237 is fixed "Dockerfile_test_user_run": {}, } diff --git a/integration/integration_test.go b/integration/integration_test.go index 117ba76d7..8eb356923 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -386,6 +386,45 @@ func TestBuildWithLabels(t *testing.T) { checkContainerDiffOutput(t, diff, expected) } +func TestBuildWithHTTPError(t *testing.T) { + repo := getGitRepo() + dockerfile := fmt.Sprintf("%s/%s/Dockerfile_test_add_404", integrationPath, dockerfilesPath) + + // Build with docker + dockerImage := GetDockerImage(config.imageRepo, "Dockerfile_test_add_404") + dockerCmd := exec.Command("docker", + append([]string{"build", + "-t", dockerImage, + "-f", dockerfile, + repo})...) + out, err := RunCommandWithoutTest(dockerCmd) + if err != nil { + t.Errorf("Failed to build image %s with docker command %q: %s %s", dockerImage, dockerCmd.Args, err, string(out)) + } + + // Build with kaniko + kanikoImage := GetKanikoImage(config.imageRepo, "Dockerfile_test_add_404") + dockerRunFlags := []string{"run", "--net=host"} + dockerRunFlags = addServiceAccountFlags(dockerRunFlags, config.serviceAccount) + dockerRunFlags = append(dockerRunFlags, ExecutorImage, + "-f", dockerfile, + "-d", kanikoImage, + "-c", fmt.Sprintf("git://%s", repo), + ) + + kanikoCmd := exec.Command("docker", dockerRunFlags...) + + out, err = RunCommandWithoutTest(kanikoCmd) + if err != nil { + t.Errorf("Failed to build image %s with kaniko command %q: %v %s", dockerImage, kanikoCmd.Args, err, string(out)) + } + + diff := containerDiff(t, daemonPrefix+dockerImage, kanikoImage, "--no-cache") + + expected := fmt.Sprintf(emptyContainerDiff, dockerImage, kanikoImage, dockerImage, kanikoImage) + checkContainerDiffOutput(t, diff, expected) +} + func TestLayers(t *testing.T) { offset := map[string]int{ "Dockerfile_test_add": 12,