@@ -82,16 +82,36 @@ func TestForceSystemdFlag(t *testing.T) {
8282 t .Errorf ("failed to start minikube with args: %q : %v" , rr .Command (), err )
8383 }
8484
85- rr , err = Run (t , exec .CommandContext (ctx , Target (), "-p" , profile , "ssh" , "docker info --format {{.CgroupDriver}}" ))
85+ containerRuntime := ContainerRuntime ()
86+ switch containerRuntime {
87+ case "docker" :
88+ validateDockerSystemd (ctx , t , profile )
89+ case "containerd" :
90+ validateContainerdSystemd (ctx , t , profile )
91+ }
92+
93+ }
94+
95+ func validateDockerSystemd (ctx context.Context , t * testing.T , profile string ) {
96+ rr , err := Run (t , exec .CommandContext (ctx , Target (), "-p" , profile , "ssh" , "docker info --format {{.CgroupDriver}}" ))
8697 if err != nil {
8798 t .Errorf ("failed to get docker cgroup driver. args %q: %v" , rr .Command (), err )
8899 }
89-
90100 if ! strings .Contains (rr .Output (), "systemd" ) {
91101 t .Fatalf ("expected systemd cgroup driver, got: %v" , rr .Output ())
92102 }
93103}
94104
105+ func validateContainerdSystemd (ctx context.Context , t * testing.T , profile string ) {
106+ rr , err := Run (t , exec .CommandContext (ctx , Target (), "-p" , profile , "ssh" , "cat /etc/containerd/config.toml" ))
107+ if err != nil {
108+ t .Errorf ("failed to get docker cgroup driver. args %q: %v" , rr .Command (), err )
109+ }
110+ if ! strings .Contains (rr .Output (), "systemd_cgroup = true" ) {
111+ t .Fatalf ("expected systemd cgroup driver, got: %v" , rr .Output ())
112+ }
113+ }
114+
95115func TestForceSystemdEnv (t * testing.T ) {
96116 if NoneDriver () {
97117 t .Skip ("skipping: none driver does not support ssh or bundle docker" )
@@ -109,13 +129,11 @@ func TestForceSystemdEnv(t *testing.T) {
109129 if err != nil {
110130 t .Errorf ("failed to start minikube with args: %q : %v" , rr .Command (), err )
111131 }
112-
113- rr , err = Run (t , exec .CommandContext (ctx , Target (), "-p" , profile , "ssh" , "docker info --format {{.CgroupDriver}}" ))
114- if err != nil {
115- t .Errorf ("failed to get docker cgroup driver. args %q: %v" , rr .Command (), err )
116- }
117-
118- if ! strings .Contains (rr .Output (), "systemd" ) {
119- t .Fatalf ("expected systemd cgroup driver, got: %v" , rr .Output ())
132+ containerRuntime := ContainerRuntime ()
133+ switch containerRuntime {
134+ case "docker" :
135+ validateDockerSystemd (ctx , t , profile )
136+ case "containerd" :
137+ validateContainerdSystemd (ctx , t , profile )
120138 }
121139}
0 commit comments