Merge pull request #10225 from priyawadhwa/force-systemd-fix

Fix TestForceSystemdFlag tests on containerd
pull/10240/head
priyawadhwa 2021-01-22 16:49:07 -08:00 committed by GitHub
commit 452d8db91e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 10 deletions

View File

@ -82,16 +82,36 @@ func TestForceSystemdFlag(t *testing.T) {
t.Errorf("failed to start minikube with args: %q : %v", rr.Command(), err)
}
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker info --format {{.CgroupDriver}}"))
containerRuntime := ContainerRuntime()
switch containerRuntime {
case "docker":
validateDockerSystemd(ctx, t, profile)
case "containerd":
validateContainerdSystemd(ctx, t, profile)
}
}
func validateDockerSystemd(ctx context.Context, t *testing.T, profile string) {
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker info --format {{.CgroupDriver}}"))
if err != nil {
t.Errorf("failed to get docker cgroup driver. args %q: %v", rr.Command(), err)
}
if !strings.Contains(rr.Output(), "systemd") {
t.Fatalf("expected systemd cgroup driver, got: %v", rr.Output())
}
}
func validateContainerdSystemd(ctx context.Context, t *testing.T, profile string) {
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "cat /etc/containerd/config.toml"))
if err != nil {
t.Errorf("failed to get docker cgroup driver. args %q: %v", rr.Command(), err)
}
if !strings.Contains(rr.Output(), "systemd_cgroup = true") {
t.Fatalf("expected systemd cgroup driver, got: %v", rr.Output())
}
}
func TestForceSystemdEnv(t *testing.T) {
if NoneDriver() {
t.Skip("skipping: none driver does not support ssh or bundle docker")
@ -109,13 +129,11 @@ func TestForceSystemdEnv(t *testing.T) {
if err != nil {
t.Errorf("failed to start minikube with args: %q : %v", rr.Command(), err)
}
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker info --format {{.CgroupDriver}}"))
if err != nil {
t.Errorf("failed to get docker cgroup driver. args %q: %v", rr.Command(), err)
}
if !strings.Contains(rr.Output(), "systemd") {
t.Fatalf("expected systemd cgroup driver, got: %v", rr.Output())
containerRuntime := ContainerRuntime()
switch containerRuntime {
case "docker":
validateDockerSystemd(ctx, t, profile)
case "containerd":
validateContainerdSystemd(ctx, t, profile)
}
}