From 5d013626fc2ef97363d2e2699913490a9fd9219d Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Mon, 25 May 2020 21:21:33 -0700 Subject: [PATCH 1/8] benchmark project added --- .gitignore | 1 + integration/benchmark/Dockerfile_FS_benchmark | 9 ++ integration/benchmark/context.txt | 1 + integration/benchmark/make.sh | 10 ++ integration/benchmark_test.go | 51 ++++++++ integration/images.go | 114 ++++++++++-------- scripts/integration-test.sh | 13 -- 7 files changed, 134 insertions(+), 65 deletions(-) create mode 100644 integration/benchmark/Dockerfile_FS_benchmark create mode 100644 integration/benchmark/context.txt create mode 100755 integration/benchmark/make.sh create mode 100644 integration/benchmark_test.go diff --git a/.gitignore b/.gitignore index c58a5b6d00..d80906dc93 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ out/ .idea +*.iml diff --git a/integration/benchmark/Dockerfile_FS_benchmark b/integration/benchmark/Dockerfile_FS_benchmark new file mode 100644 index 0000000000..b589757dde --- /dev/null +++ b/integration/benchmark/Dockerfile_FS_benchmark @@ -0,0 +1,9 @@ +FROM bash:4.4 + +ARG NUM +COPY context.txt . +COPY make.sh . +RUN ls -al make.sh +SHELL ["/usr/local/bin/bash", "-c"] +RUN ./make.sh $NUM +RUN ls -al /workdir | wc diff --git a/integration/benchmark/context.txt b/integration/benchmark/context.txt new file mode 100644 index 0000000000..3b18e512db --- /dev/null +++ b/integration/benchmark/context.txt @@ -0,0 +1 @@ +hello world diff --git a/integration/benchmark/make.sh b/integration/benchmark/make.sh new file mode 100755 index 0000000000..525f84e943 --- /dev/null +++ b/integration/benchmark/make.sh @@ -0,0 +1,10 @@ +#!/usr/local/bin/bash + +mkdir /workdir + +i=1 +while [ $i -le $1 ] +do + cat context.txt > /workdir/somefile$i + i=$(( $i + 1 )) +done diff --git a/integration/benchmark_test.go b/integration/benchmark_test.go new file mode 100644 index 0000000000..0092782a1d --- /dev/null +++ b/integration/benchmark_test.go @@ -0,0 +1,51 @@ +/* +Copyright 2018 Google LLC + +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. +*/ + +package integration + +import ( + "fmt" + "os" + "path/filepath" + "testing" +) + +func TestSnapshotBenchmark(t *testing.T) { + cwd, err := os.Getwd() + if err != nil { + t.Fatal(err) + } + contextDir := filepath.Join(cwd, "benchmark") + + nums := []int{10000, 50000, 100000, 200000, 300000, 500000, 700000, 800000} + + for _, num := range nums { + + t.Run("test_benchmark"+string(num), func(t *testing.T) { + t.Parallel() + dockerfile := "Dockerfile_FS_benchmark" + kanikoImage := GetKanikoImage(config.imageRepo, dockerfile) + buildArgs := []string{"--build-arg", fmt.Sprintf("NUM=%d", num)} + if _, err := buildKanikoImage("", dockerfile, + buildArgs, []string{}, kanikoImage, contextDir, config.gcsBucket, config.serviceAccount); err != nil { + t.Errorf("could not run benchmark results for num %d", num) + } + }) + } + if err := logBenchmarks("benchmark"); err != nil { + t.Logf("Failed to create benchmark file: %v", err) + } +} diff --git a/integration/images.go b/integration/images.go index bb254f1102..82e8244b6a 100644 --- a/integration/images.go +++ b/integration/images.go @@ -259,70 +259,25 @@ func (d *DockerFileBuilder) BuildImageWithContext(config *integrationTestConfig, } } - reproducibleFlag := "" + additionalKanikoFlags := additionalDockerFlagsMap[dockerfile] + additionalKanikoFlags = append(additionalKanikoFlags, contextFlag, contextPath) for _, d := range reproducibleTests { if d == dockerfile { - reproducibleFlag = "--reproducible" + additionalKanikoFlags = append(additionalKanikoFlags, "--reproducible") break } } - benchmarkEnv := "BENCHMARK_FILE=false" - benchmarkDir, err := ioutil.TempDir("", "") - if err != nil { - return err - } - if b, err := strconv.ParseBool(os.Getenv("BENCHMARK")); err == nil && b { - benchmarkEnv = "BENCHMARK_FILE=/kaniko/benchmarks/" + dockerfile - benchmarkFile := path.Join(benchmarkDir, dockerfile) - fileName := fmt.Sprintf("run_%s_%s", time.Now().Format("2006-01-02-15:04"), dockerfile) - dst := path.Join("benchmarks", fileName) - defer UploadFileToBucket(gcsBucket, benchmarkFile, dst) - } - - // build kaniko image - additionalFlags := append(buildArgs, additionalKanikoFlagsMap[dockerfile]...) kanikoImage := GetKanikoImage(imageRepo, dockerfile) - fmt.Printf("Going to build image with kaniko: %s, flags: %s \n", kanikoImage, additionalFlags) - - dockerRunFlags := []string{"run", "--net=host", - "-e", benchmarkEnv, - "-v", contextDir + ":/workspace", - "-v", benchmarkDir + ":/kaniko/benchmarks", - } - - if env, ok := envsMap[dockerfile]; ok { - for _, envVariable := range env { - dockerRunFlags = append(dockerRunFlags, "-e", envVariable) - } - } - - dockerRunFlags = addServiceAccountFlags(dockerRunFlags, serviceAccount) - - kanikoDockerfilePath := path.Join(buildContextPath, dockerfilesPath, dockerfile) - if dockerfilesPath == "" { - kanikoDockerfilePath = path.Join(buildContextPath, "Dockerfile") - } - - dockerRunFlags = append(dockerRunFlags, ExecutorImage, - "-f", kanikoDockerfilePath, - "-d", kanikoImage, reproducibleFlag, - contextFlag, contextPath) - dockerRunFlags = append(dockerRunFlags, additionalFlags...) - - kanikoCmd := exec.Command("docker", dockerRunFlags...) - - timer = timing.Start(dockerfile + "_kaniko") - out, err := RunCommandWithoutTest(kanikoCmd) - timing.DefaultRun.Stop(timer) - + out, err := buildKanikoImage(dockerfilesPath, dockerfile, buildArgs, additionalKanikoFlags, kanikoImage, + contextDir, gcsBucket, serviceAccount) if err != nil { - return fmt.Errorf("Failed to build image %s with kaniko command \"%s\": %s %s", kanikoImage, kanikoCmd.Args, err, string(out)) + return err } if outputCheck := outputChecks[dockerfile]; outputCheck != nil { if err := outputCheck(dockerfile, out); err != nil { - return fmt.Errorf("Output check failed for image %s with kaniko command \"%s\": %s %s", kanikoImage, kanikoCmd.Args, err, string(out)) + return fmt.Errorf("Output check failed for image %s with kaniko command : %s %s", kanikoImage, err, string(out)) } } @@ -435,3 +390,58 @@ func (d *DockerFileBuilder) buildRelativePathsImage(imageRepo, dockerfile, servi return nil } + +func buildKanikoImage(dockerfilesPath string, dockerfile string, buildArgs []string, kanikoArgs []string, kanikoImage string, + contextDir string, gcsBucket string, serviceAccount string) ([]byte, error) { + benchmarkEnv := "BENCHMARK_FILE=false" + benchmarkDir, err := ioutil.TempDir("", "") + if err != nil { + return nil, err + } + if b, err := strconv.ParseBool(os.Getenv("BENCHMARK")); err == nil && b { + benchmarkEnv = "BENCHMARK_FILE=/kaniko/benchmarks/" + dockerfile + benchmarkFile := path.Join(benchmarkDir, dockerfile) + fileName := fmt.Sprintf("run_%s_%s", time.Now().Format("2006-01-02-15:04"), dockerfile) + dst := path.Join("benchmarks", fileName) + defer UploadFileToBucket(gcsBucket, benchmarkFile, dst) + } + + // build kaniko image + additionalFlags := append(buildArgs, kanikoArgs...) + fmt.Printf("Going to build image with kaniko: %s, flags: %s \n", kanikoImage, additionalFlags) + + dockerRunFlags := []string{"run", "--net=host", + "-e", benchmarkEnv, + "-v", contextDir + ":/workspace", + "-v", benchmarkDir + ":/kaniko/benchmarks", + } + + if env, ok := envsMap[dockerfile]; ok { + for _, envVariable := range env { + dockerRunFlags = append(dockerRunFlags, "-e", envVariable) + } + } + + dockerRunFlags = addServiceAccountFlags(dockerRunFlags, serviceAccount) + + kanikoDockerfilePath := path.Join(buildContextPath, dockerfilesPath, dockerfile) + if dockerfilesPath == "" { + kanikoDockerfilePath = path.Join(buildContextPath, "Dockerfile") + } + + dockerRunFlags = append(dockerRunFlags, ExecutorImage, + "-f", kanikoDockerfilePath, + "-d", kanikoImage) + dockerRunFlags = append(dockerRunFlags, additionalFlags...) + + kanikoCmd := exec.Command("docker", dockerRunFlags...) + + timer := timing.Start(dockerfile + "_kaniko") + out, err := RunCommandWithoutTest(kanikoCmd) + timing.DefaultRun.Stop(timer) + + if err != nil { + return nil, fmt.Errorf("Failed to build image %s with kaniko command \"%s\": %s %s", kanikoImage, kanikoCmd.Args, err, string(out)) + } + return out, nil +} diff --git a/scripts/integration-test.sh b/scripts/integration-test.sh index 3af24c922f..07ac75bdb4 100755 --- a/scripts/integration-test.sh +++ b/scripts/integration-test.sh @@ -21,19 +21,6 @@ IMAGE_REPO="${IMAGE_REPO:-gcr.io/kaniko-test}" docker version # Sets up a kokoro (Google internal integration testing tool) environment -if [ -f "$KOKORO_GFILE_DIR"/common.sh ]; then - echo "Installing dependencies..." - source "$KOKORO_GFILE_DIR/common.sh" - mkdir -p /usr/local/go/src/github.com/GoogleContainerTools/ - cp -r github/kaniko /usr/local/go/src/github.com/GoogleContainerTools/ - pushd /usr/local/go/src/github.com/GoogleContainerTools/kaniko - echo "Installing container-diff..." - mv $KOKORO_GFILE_DIR/container-diff-linux-amd64 $KOKORO_GFILE_DIR/container-diff - chmod +x $KOKORO_GFILE_DIR/container-diff - export PATH=$PATH:$KOKORO_GFILE_DIR - cp $KOKORO_ROOT/src/keystore/72508_gcr_application_creds $HOME/.config/gcloud/application_default_credentials.json -fi - echo "Running integration tests..." make out/executor make out/warmer From 4129c17d12c0a39d6f9b721943d76a1aed42f403 Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Mon, 25 May 2020 23:36:59 -0700 Subject: [PATCH 2/8] more changes --- .../Dockerfile_fs_benchmark} | 0 .../{benchmark => benchmark_fs}/context.txt | 0 .../{benchmark => benchmark_fs}/make.sh | 0 integration/benchmark_test.go | 76 +++++++++++++++---- integration/images.go | 52 +++++++------ 5 files changed, 93 insertions(+), 35 deletions(-) rename integration/{benchmark/Dockerfile_FS_benchmark => benchmark_fs/Dockerfile_fs_benchmark} (100%) rename integration/{benchmark => benchmark_fs}/context.txt (100%) rename integration/{benchmark => benchmark_fs}/make.sh (100%) diff --git a/integration/benchmark/Dockerfile_FS_benchmark b/integration/benchmark_fs/Dockerfile_fs_benchmark similarity index 100% rename from integration/benchmark/Dockerfile_FS_benchmark rename to integration/benchmark_fs/Dockerfile_fs_benchmark diff --git a/integration/benchmark/context.txt b/integration/benchmark_fs/context.txt similarity index 100% rename from integration/benchmark/context.txt rename to integration/benchmark_fs/context.txt diff --git a/integration/benchmark/make.sh b/integration/benchmark_fs/make.sh similarity index 100% rename from integration/benchmark/make.sh rename to integration/benchmark_fs/make.sh diff --git a/integration/benchmark_test.go b/integration/benchmark_test.go index 0092782a1d..a5e1d08beb 100644 --- a/integration/benchmark_test.go +++ b/integration/benchmark_test.go @@ -17,35 +17,85 @@ limitations under the License. package integration import ( + "encoding/json" "fmt" + "io/ioutil" "os" "path/filepath" + "sync" "testing" + "time" ) +type result struct { + totalBuildTime float64 + resolvingFiles float64 + walkingFiles float64 +} + func TestSnapshotBenchmark(t *testing.T) { cwd, err := os.Getwd() if err != nil { t.Fatal(err) } - contextDir := filepath.Join(cwd, "benchmark") + contextDir := filepath.Join(cwd, "benchmark_fs") nums := []int{10000, 50000, 100000, 200000, 300000, 500000, 700000, 800000} + var timeMap sync.Map + var wg sync.WaitGroup for _, num := range nums { - - t.Run("test_benchmark"+string(num), func(t *testing.T) { - t.Parallel() - dockerfile := "Dockerfile_FS_benchmark" - kanikoImage := GetKanikoImage(config.imageRepo, dockerfile) - buildArgs := []string{"--build-arg", fmt.Sprintf("NUM=%d", num)} - if _, err := buildKanikoImage("", dockerfile, - buildArgs, []string{}, kanikoImage, contextDir, config.gcsBucket, config.serviceAccount); err != nil { - t.Errorf("could not run benchmark results for num %d", num) - } + t.Run(fmt.Sprintf("test_benchmark_%d", num), func(t *testing.T) { + wg.Add(1) + go func(num int) { + dockerfile := "Dockerfile_fs_benchmark" + kanikoImage := fmt.Sprintf("%s_%d", GetKanikoImage(config.imageRepo, dockerfile), num) + buildArgs := []string{"--build-arg", fmt.Sprintf("NUM=%d", num)} + benchmarkDir, err := buildKanikoImage("", dockerfile, + buildArgs, []string{}, kanikoImage, contextDir, config.gcsBucket, + config.serviceAccount, false) + if err != nil { + t.Errorf("could not run benchmark results for num %d", num) + } + r := newResult(t, filepath.Join(benchmarkDir, dockerfile)) + timeMap.Store(num, r) + wg.Done() + defer os.Remove(benchmarkDir) + }(num) }) } - if err := logBenchmarks("benchmark"); err != nil { - t.Logf("Failed to create benchmark file: %v", err) + wg.Wait() + + fmt.Println("Number of Files,Total Build Time,Walking Filesystem, Resolving Files") + timeMap.Range(func(key interface{}, value interface{}) bool { + d, _ := key.(int) + v, _ := value.(result) + fmt.Println(fmt.Sprintf("%d,%f,%f,%f", d, v.totalBuildTime, v.walkingFiles, v.resolvingFiles)) + return true + }) + +} + +func newResult(t *testing.T, f string) result { + var current map[string]time.Duration + jsonFile, err := os.Open(f) + defer jsonFile.Close() + if err != nil { + t.Errorf("could not read benchmark file %s", f) + } + byteValue, _ := ioutil.ReadAll(jsonFile) + if err := json.Unmarshal(byteValue, ¤t); err != nil { + t.Errorf("could not unmarshal benchmark file") + } + r := result{} + if c, ok := current["Resolving Paths"]; ok { + r.resolvingFiles = c.Seconds() + } + if c, ok := current["Walking filesystem"]; ok { + r.walkingFiles = c.Seconds() + } + if c, ok := current["Total Build Time"]; ok { + r.totalBuildTime = c.Seconds() } + return r } diff --git a/integration/images.go b/integration/images.go index 82e8244b6a..0d2d63e70c 100644 --- a/integration/images.go +++ b/integration/images.go @@ -269,17 +269,12 @@ func (d *DockerFileBuilder) BuildImageWithContext(config *integrationTestConfig, } kanikoImage := GetKanikoImage(imageRepo, dockerfile) - out, err := buildKanikoImage(dockerfilesPath, dockerfile, buildArgs, additionalKanikoFlags, kanikoImage, - contextDir, gcsBucket, serviceAccount) - if err != nil { + timer = timing.Start(dockerfile + "_kaniko") + if _, err := buildKanikoImage(dockerfilesPath, dockerfile, buildArgs, additionalKanikoFlags, kanikoImage, + contextDir, gcsBucket, serviceAccount, true); err != nil { return err } - - if outputCheck := outputChecks[dockerfile]; outputCheck != nil { - if err := outputCheck(dockerfile, out); err != nil { - return fmt.Errorf("Output check failed for image %s with kaniko command : %s %s", kanikoImage, err, string(out)) - } - } + timing.DefaultRun.Stop(timer) d.filesBuilt[dockerfile] = struct{}{} @@ -336,9 +331,7 @@ func (d *DockerFileBuilder) buildCachedImages(config *integrationTestConfig, cac "--cache-dir", cacheDir) kanikoCmd := exec.Command("docker", dockerRunFlags...) - timer := timing.Start(dockerfile + "_kaniko_cached_" + strconv.Itoa(version)) _, err := RunCommandWithoutTest(kanikoCmd) - timing.DefaultRun.Stop(timer) if err != nil { return fmt.Errorf("Failed to build cached image %s with kaniko command \"%s\": %s", kanikoImage, kanikoCmd.Args, err) } @@ -391,19 +384,30 @@ func (d *DockerFileBuilder) buildRelativePathsImage(imageRepo, dockerfile, servi return nil } -func buildKanikoImage(dockerfilesPath string, dockerfile string, buildArgs []string, kanikoArgs []string, kanikoImage string, - contextDir string, gcsBucket string, serviceAccount string) ([]byte, error) { +func buildKanikoImage( + dockerfilesPath string, + dockerfile string, + buildArgs []string, + kanikoArgs []string, + kanikoImage string, + contextDir string, + gcsBucket string, + serviceAccount string, + shdUpload bool, +) (string, error) { benchmarkEnv := "BENCHMARK_FILE=false" benchmarkDir, err := ioutil.TempDir("", "") if err != nil { - return nil, err + return "", err } if b, err := strconv.ParseBool(os.Getenv("BENCHMARK")); err == nil && b { benchmarkEnv = "BENCHMARK_FILE=/kaniko/benchmarks/" + dockerfile - benchmarkFile := path.Join(benchmarkDir, dockerfile) - fileName := fmt.Sprintf("run_%s_%s", time.Now().Format("2006-01-02-15:04"), dockerfile) - dst := path.Join("benchmarks", fileName) - defer UploadFileToBucket(gcsBucket, benchmarkFile, dst) + if shdUpload { + benchmarkFile := path.Join(benchmarkDir, dockerfile) + fileName := fmt.Sprintf("run_%s_%s", time.Now().Format("2006-01-02-15:04"), dockerfile) + dst := path.Join("benchmarks", fileName) + defer UploadFileToBucket(gcsBucket, benchmarkFile, dst) + } } // build kaniko image @@ -426,7 +430,7 @@ func buildKanikoImage(dockerfilesPath string, dockerfile string, buildArgs []str kanikoDockerfilePath := path.Join(buildContextPath, dockerfilesPath, dockerfile) if dockerfilesPath == "" { - kanikoDockerfilePath = path.Join(buildContextPath, "Dockerfile") + kanikoDockerfilePath = path.Join(buildContextPath, dockerfile) } dockerRunFlags = append(dockerRunFlags, ExecutorImage, @@ -439,9 +443,13 @@ func buildKanikoImage(dockerfilesPath string, dockerfile string, buildArgs []str timer := timing.Start(dockerfile + "_kaniko") out, err := RunCommandWithoutTest(kanikoCmd) timing.DefaultRun.Stop(timer) - if err != nil { - return nil, fmt.Errorf("Failed to build image %s with kaniko command \"%s\": %s %s", kanikoImage, kanikoCmd.Args, err, string(out)) + return "", fmt.Errorf("Failed to build image %s with kaniko command \"%s\": %s %s", kanikoImage, kanikoCmd.Args, err, string(out)) + } + if outputCheck := outputChecks[dockerfile]; outputCheck != nil { + if err := outputCheck(dockerfile, out); err != nil { + return "", fmt.Errorf("Output check failed for image %s with kaniko command : %s %s", kanikoImage, err, string(out)) + } } - return out, nil + return benchmarkDir, nil } From 48421f1126b5bc7067535d90559401c47f13670d Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Tue, 26 May 2020 00:16:03 -0700 Subject: [PATCH 3/8] more fixes --- integration/benchmark_test.go | 13 +++++++++---- integration/images.go | 2 -- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/integration/benchmark_test.go b/integration/benchmark_test.go index a5e1d08beb..2b236fa544 100644 --- a/integration/benchmark_test.go +++ b/integration/benchmark_test.go @@ -47,21 +47,26 @@ func TestSnapshotBenchmark(t *testing.T) { for _, num := range nums { t.Run(fmt.Sprintf("test_benchmark_%d", num), func(t *testing.T) { wg.Add(1) - go func(num int) { + var err error + go func(num int, err error) { dockerfile := "Dockerfile_fs_benchmark" kanikoImage := fmt.Sprintf("%s_%d", GetKanikoImage(config.imageRepo, dockerfile), num) buildArgs := []string{"--build-arg", fmt.Sprintf("NUM=%d", num)} - benchmarkDir, err := buildKanikoImage("", dockerfile, + var benchmarkDir string + benchmarkDir, err = buildKanikoImage("", dockerfile, buildArgs, []string{}, kanikoImage, contextDir, config.gcsBucket, config.serviceAccount, false) if err != nil { - t.Errorf("could not run benchmark results for num %d", num) + return } r := newResult(t, filepath.Join(benchmarkDir, dockerfile)) timeMap.Store(num, r) wg.Done() defer os.Remove(benchmarkDir) - }(num) + }(num, err) + if err != nil { + t.Errorf("could not run benchmark results for num %d due to %s", num, err) + } }) } wg.Wait() diff --git a/integration/images.go b/integration/images.go index 0d2d63e70c..476012f1e5 100644 --- a/integration/images.go +++ b/integration/images.go @@ -440,9 +440,7 @@ func buildKanikoImage( kanikoCmd := exec.Command("docker", dockerRunFlags...) - timer := timing.Start(dockerfile + "_kaniko") out, err := RunCommandWithoutTest(kanikoCmd) - timing.DefaultRun.Stop(timer) if err != nil { return "", fmt.Errorf("Failed to build image %s with kaniko command \"%s\": %s %s", kanikoImage, kanikoCmd.Args, err, string(out)) } From a60a097c9b562f7263b0556b7dc7277fdac8d106 Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Tue, 26 May 2020 00:22:50 -0700 Subject: [PATCH 4/8] one more fix --- integration/images.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/images.go b/integration/images.go index 476012f1e5..97f3b6fecf 100644 --- a/integration/images.go +++ b/integration/images.go @@ -259,7 +259,7 @@ func (d *DockerFileBuilder) BuildImageWithContext(config *integrationTestConfig, } } - additionalKanikoFlags := additionalDockerFlagsMap[dockerfile] + additionalKanikoFlags := additionalKanikoFlagsMap[dockerfile] additionalKanikoFlags = append(additionalKanikoFlags, contextFlag, contextPath) for _, d := range reproducibleTests { if d == dockerfile { From b98f55a41d2a4d1950ccdb5d695a0c8b36881533 Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Tue, 26 May 2020 08:40:25 -0700 Subject: [PATCH 5/8] some more fixes --- integration/benchmark_fs/Dockerfile_fs_benchmark | 1 - integration/benchmark_test.go | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/integration/benchmark_fs/Dockerfile_fs_benchmark b/integration/benchmark_fs/Dockerfile_fs_benchmark index b589757dde..4065467c4a 100644 --- a/integration/benchmark_fs/Dockerfile_fs_benchmark +++ b/integration/benchmark_fs/Dockerfile_fs_benchmark @@ -3,7 +3,6 @@ FROM bash:4.4 ARG NUM COPY context.txt . COPY make.sh . -RUN ls -al make.sh SHELL ["/usr/local/bin/bash", "-c"] RUN ./make.sh $NUM RUN ls -al /workdir | wc diff --git a/integration/benchmark_test.go b/integration/benchmark_test.go index 2b236fa544..036e96beb1 100644 --- a/integration/benchmark_test.go +++ b/integration/benchmark_test.go @@ -22,6 +22,7 @@ import ( "io/ioutil" "os" "path/filepath" + "strconv" "sync" "testing" "time" @@ -34,6 +35,9 @@ type result struct { } func TestSnapshotBenchmark(t *testing.T) { + if b, err := strconv.ParseBool(os.Getenv("BENCHMARK")); err != nil || !b { + t.SkipNow() + } cwd, err := os.Getwd() if err != nil { t.Fatal(err) @@ -48,22 +52,22 @@ func TestSnapshotBenchmark(t *testing.T) { t.Run(fmt.Sprintf("test_benchmark_%d", num), func(t *testing.T) { wg.Add(1) var err error - go func(num int, err error) { + go func(num int, err *error) { dockerfile := "Dockerfile_fs_benchmark" kanikoImage := fmt.Sprintf("%s_%d", GetKanikoImage(config.imageRepo, dockerfile), num) buildArgs := []string{"--build-arg", fmt.Sprintf("NUM=%d", num)} var benchmarkDir string - benchmarkDir, err = buildKanikoImage("", dockerfile, + benchmarkDir, *err = buildKanikoImage("", dockerfile, buildArgs, []string{}, kanikoImage, contextDir, config.gcsBucket, config.serviceAccount, false) - if err != nil { + if *err != nil { return } r := newResult(t, filepath.Join(benchmarkDir, dockerfile)) timeMap.Store(num, r) wg.Done() defer os.Remove(benchmarkDir) - }(num, err) + }(num, &err) if err != nil { t.Errorf("could not run benchmark results for num %d due to %s", num, err) } From 85c40c45b3b49b8d85da969a3854f8dca9b5784a Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Thu, 4 Jun 2020 15:10:01 -0700 Subject: [PATCH 6/8] fix dockerfile --- integration/images.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/images.go b/integration/images.go index 97f3b6fecf..8865e836aa 100644 --- a/integration/images.go +++ b/integration/images.go @@ -430,7 +430,7 @@ func buildKanikoImage( kanikoDockerfilePath := path.Join(buildContextPath, dockerfilesPath, dockerfile) if dockerfilesPath == "" { - kanikoDockerfilePath = path.Join(buildContextPath, dockerfile) + kanikoDockerfilePath = path.Join(buildContextPath, "Dockerfile") } dockerRunFlags = append(dockerRunFlags, ExecutorImage, From 18dbb0e12aae99ee73832691445a9676ba261d69 Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Thu, 4 Jun 2020 15:11:24 -0700 Subject: [PATCH 7/8] add biolerplate --- integration/benchmark_fs/make.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/integration/benchmark_fs/make.sh b/integration/benchmark_fs/make.sh index 525f84e943..96a5f36b4e 100755 --- a/integration/benchmark_fs/make.sh +++ b/integration/benchmark_fs/make.sh @@ -1,5 +1,19 @@ #!/usr/local/bin/bash +# Copyright 2018 Google LLC +# +# 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. + mkdir /workdir i=1 From 92a5c89b97d5fe15be3af0fc54cc9b7b4c141694 Mon Sep 17 00:00:00 2001 From: Tejal Desai Date: Thu, 4 Jun 2020 15:12:57 -0700 Subject: [PATCH 8/8] update year in license. --- integration/benchmark_fs/make.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/benchmark_fs/make.sh b/integration/benchmark_fs/make.sh index 96a5f36b4e..828f420ba8 100755 --- a/integration/benchmark_fs/make.sh +++ b/integration/benchmark_fs/make.sh @@ -1,6 +1,6 @@ #!/usr/local/bin/bash -# Copyright 2018 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.