Skip to content

Commit

Permalink
feat: support test docker-env for containerd runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeProgrammer committed Nov 4, 2023
1 parent df07d69 commit 9dc8caf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ var BenchMethods = []method{
command.ClearDockerCache,
"image build containerd",
},
{
command.StartMinikubeDockerEnvContainerd,
command.RunDockerEnvWithBuildKitDiabled,
func(s string) error { return nil },
"docker-env containerd",
},
{
command.StartMinikubeRegistryContainerd,
command.RunRegistry,
Expand Down
13 changes: 12 additions & 1 deletion pkg/command/dockerenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package command
import (
"fmt"
"os/exec"
"strings"
"time"
)

Expand All @@ -11,10 +12,20 @@ func StartMinikubeDockerEnv(profile string, args ...string) error {
return startMinikube(profile, args...)
}

func StartMinikubeDockerEnvContainerd(profile string, args ...string) error {
return startMinikube(profile, "--container-runtime=containerd")
}

// RunDockerEnv builds the provided image using the docker-env method and returns the run time.
func RunDockerEnv(image string, profile string) (float64, error) {
return runDockerEnv(image, profile)
}
func RunDockerEnvWithBuildKitDiabled(image string, profile string) (float64, error) {
return runDockerEnv(image, profile, "DOCKER_BUILDKIT=0")
}
func runDockerEnv(image string, profile string, envs ...string) (float64, error) {
// build
buildArgs := fmt.Sprintf("eval $(./minikube -p %s docker-env) && docker build -t benchmark-env -f testdata/Dockerfile.%s .", profile, image)
buildArgs := fmt.Sprintf("eval $(./minikube -p %s docker-env) && %s docker build -t benchmark-env -f testdata/Dockerfile.%s .", profile, strings.Join(envs, " "), image)
build := exec.Command("/bin/bash", "-c", buildArgs)
start := time.Now()
if _, err := run(build); err != nil {
Expand Down

0 comments on commit 9dc8caf

Please sign in to comment.