From c7d173cd998a648c443b5269ca7bf81206759ee6 Mon Sep 17 00:00:00 2001 From: Yoan Blanc Date: Sun, 22 Dec 2019 11:28:13 +0100 Subject: [PATCH] integration-test: using registry-mirror Signed-off-by: Yoan Blanc --- integration/dockerfiles/Dockerfile_test_run_3 | 20 +++++++++ integration/integration_test.go | 45 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 integration/dockerfiles/Dockerfile_test_run_3 diff --git a/integration/dockerfiles/Dockerfile_test_run_3 b/integration/dockerfiles/Dockerfile_test_run_3 new file mode 100644 index 000000000..1d48c3e34 --- /dev/null +++ b/integration/dockerfiles/Dockerfile_test_run_3 @@ -0,0 +1,20 @@ +# Copyright 2018 Google, Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test to make sure the executor builds an image correctly +# when no files are changed + +FROM google-appengine/debian9@sha256:1d6a9a6d106bd795098f60f4abb7083626354fa6735e81743c7f8cfca11259f0 +RUN echo "hey" +MAINTAINER kaniko diff --git a/integration/integration_test.go b/integration/integration_test.go index 246e9e6cb..76b496fc4 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -267,6 +267,51 @@ func TestGitBuildContextWithBranch(t *testing.T) { checkContainerDiffOutput(t, diff, expected) } +func TestBuildViaRegistryMirror(t *testing.T) { + repo := "github.com/GoogleContainerTools/kaniko" + + // Build with docker + dockerImage := GetDockerImage(config.imageRepo, "Dockerfile_test_git") + dockerfile := "integration/dockerfiles/Dockerfile_test_run_2" + 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 \"%s\": %s %s", dockerImage, dockerCmd.Args, err, string(out)) + } + + // Build with kaniko + kanikoImage := GetKanikoImage(config.imageRepo, "Dockerfile_test_git") + dockerfile = "integration/dockerfiles/Dockerfile_test_run_3" + kanikoCmd := exec.Command("docker", + append([]string{"run", + "-v", os.Getenv("HOME") + "/.config/gcloud:/root/.config/gcloud", + ExecutorImage, + "-f", dockerfile, + "-d", kanikoImage, + "--registry-mirror", "gcr.io", + "-c", fmt.Sprintf("git://%s", repo)})...) + + out, err = RunCommandWithoutTest(kanikoCmd) + if err != nil { + t.Errorf("Failed to build image %s with kaniko command \"%s\": %v %s", dockerImage, kanikoCmd.Args, err, string(out)) + } + + // container-diff + daemonDockerImage := daemonPrefix + dockerImage + containerdiffCmd := exec.Command("container-diff", "diff", "--no-cache", + daemonDockerImage, kanikoImage, + "-q", "--type=file", "--type=metadata", "--json") + diff := RunCommand(containerdiffCmd, t) + t.Logf("diff = %s", string(diff)) + + 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,