minikube/test/integration/docker_test.go

66 lines
2.4 KiB
Go
Raw Normal View History

// +build integration
/*
Copyright 2016 The Kubernetes Authors All rights reserved.
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 (
"context"
"os/exec"
"strings"
"testing"
)
func TestDockerFlags(t *testing.T) {
if NoneDriver() {
t.Skip("skipping: none driver does not support ssh or bundle docker")
2019-08-01 05:50:04 +00:00
}
MaybeParallel(t)
profile := UniqueProfileName("docker-flags")
2020-02-21 00:19:59 +00:00
ctx, cancel := context.WithTimeout(context.Background(), Minutes(30))
defer CleanupWithLogs(t, profile, cancel)
2019-09-13 14:42:30 +00:00
// Use the most verbose logging for the simplest test. If it fails, something is very wrong.
args := append([]string{"start", "-p", profile, "--cache-images=false", "--memory=1800", "--install-addons=false", "--wait=false", "--docker-env=FOO=BAR", "--docker-env=BAZ=BAT", "--docker-opt=debug", "--docker-opt=icc=true", "--alsologtostderr", "-v=5"}, StartArgs()...)
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
if err != nil {
2020-03-26 05:21:19 +00:00
t.Errorf("failed to start minikube with args: %q : %v", rr.Command(), err)
2019-05-14 04:43:52 +00:00
}
2020-02-22 19:12:18 +00:00
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo systemctl show docker --property=Environment --no-pager"))
if err != nil {
2020-03-26 05:21:19 +00:00
t.Errorf("failed to 'systemctl show docker' inside minikube. args %q: %v", rr.Command(), err)
}
for _, envVar := range []string{"FOO=BAR", "BAZ=BAT"} {
if !strings.Contains(rr.Stdout.String(), envVar) {
2020-03-26 03:18:05 +00:00
t.Errorf("expected env key/value %q to be passed to minikube's docker and be included in: *%q*.", envVar, rr.Stdout)
}
}
2020-02-22 19:12:18 +00:00
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo systemctl show docker --property=ExecStart --no-pager"))
if err != nil {
2020-03-26 05:21:19 +00:00
t.Errorf("failed on the second 'systemctl show docker' inside minikube. args %q: %v", rr.Command(), err)
}
for _, opt := range []string{"--debug", "--icc=true"} {
if !strings.Contains(rr.Stdout.String(), opt) {
2020-03-26 03:18:05 +00:00
t.Fatalf("expected %q output to have include *%s* . output: %q", rr.Command(), opt, rr.Stdout)
}
}
}