2016-07-17 18:41:29 +00:00
|
|
|
// +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 (
|
2018-11-27 16:24:28 +00:00
|
|
|
"context"
|
2019-09-11 16:59:38 +00:00
|
|
|
"os/exec"
|
2016-07-17 18:41:29 +00:00
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2019-09-11 16:59:38 +00:00
|
|
|
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
|
|
|
}
|
2019-10-30 16:27:25 +00:00
|
|
|
MaybeParallel(t)
|
|
|
|
|
2019-09-11 16:59:38 +00:00
|
|
|
profile := UniqueProfileName("docker-flags")
|
2020-02-21 00:19:59 +00:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), Minutes(30))
|
2019-09-13 16:11:19 +00:00
|
|
|
defer CleanupWithLogs(t, profile, cancel)
|
2018-11-27 16:24:28 +00:00
|
|
|
|
2019-09-13 14:42:30 +00:00
|
|
|
// Use the most verbose logging for the simplest test. If it fails, something is very wrong.
|
2020-03-05 21:03:57 +00:00
|
|
|
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()...)
|
2019-09-11 16:59:38 +00:00
|
|
|
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
|
|
|
}
|
2018-11-27 16:24:28 +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"))
|
2018-11-27 16:24:28 +00:00
|
|
|
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)
|
2018-11-27 16:24:28 +00:00
|
|
|
}
|
2016-07-17 18:41:29 +00:00
|
|
|
|
|
|
|
for _, envVar := range []string{"FOO=BAR", "BAZ=BAT"} {
|
2019-09-11 16:59:38 +00:00
|
|
|
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)
|
2016-07-17 18:41:29 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-05 06:25:23 +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=ExecStart --no-pager"))
|
2018-11-27 16:24:28 +00:00
|
|
|
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)
|
2018-11-27 16:24:28 +00:00
|
|
|
}
|
2017-03-17 09:53:45 +00:00
|
|
|
for _, opt := range []string{"--debug", "--icc=true"} {
|
2019-09-11 16:59:38 +00:00
|
|
|
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)
|
2017-03-17 09:53:45 +00:00
|
|
|
}
|
|
|
|
}
|
2016-07-17 18:41:29 +00:00
|
|
|
}
|