Move the benchmark files from /workspace to their own mounted volume in tests. (#527)

If we don't do this, they can end up in the built images causing test failures.
This commit is contained in:
dlorenc 2019-01-11 16:04:16 -07:00 committed by GitHub
parent d9055df304
commit 48f9968e5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -17,5 +17,5 @@ set -ex
script_name=$0
script_full_path=$(dirname "$0")
export BENCHMARK=true
export IMAGE_REPO="gcr.io/kaniko-test-project/benchmarks"
export IMAGE_REPO="gcr.io/kaniko-test/benchmarks"
./${script_full_path}/integration-test.sh

View File

@ -18,6 +18,7 @@ package integration
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"
@ -188,9 +189,12 @@ func (d *DockerFileBuilder) BuildImage(imageRepo, gcsBucket, dockerfilesPath, do
}
benchmarkEnv := "BENCHMARK_FILE=false"
benchmarkDir, err := ioutil.TempDir("", "")
if err != nil {
return err
}
if b, err := strconv.ParseBool(os.Getenv("BENCHMARK")); err == nil && b {
os.Mkdir("benchmarks", 0755)
benchmarkEnv = "BENCHMARK_FILE=/workspace/benchmarks/" + dockerfile
benchmarkEnv = "BENCHMARK_FILE=/kaniko/benchmarks/" + dockerfile
}
// build kaniko image
@ -199,6 +203,7 @@ func (d *DockerFileBuilder) BuildImage(imageRepo, gcsBucket, dockerfilesPath, do
kanikoCmd := exec.Command("docker",
append([]string{"run",
"-v", os.Getenv("HOME") + "/.config/gcloud:/root/.config/gcloud",
"-v", benchmarkDir + ":/kaniko/benchmarks",
"-v", cwd + ":/workspace",
"-e", benchmarkEnv,
ExecutorImage,