Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support test docker-env for containerd runtime #41

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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