Commit c1a3e434 authored by Sharif Elgamal's avatar Sharif Elgamal

fix unit tests and fix merge conflicts

parent 2785d292
......@@ -20,7 +20,6 @@ import (
"fmt"
"os"
"os/exec"
"runtime"
"syscall"
"github.com/golang/glog"
......@@ -29,6 +28,7 @@ import (
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/node"
"k8s.io/minikube/pkg/minikube/out"
)
......@@ -59,7 +59,7 @@ minikube kubectl -- get pods --namespace kube-system`,
version = cc.KubernetesConfig.KubernetesVersion
}
path, err := cacheKubectlBinary(version)
path, err := node.CacheKubectlBinary(version)
if err != nil {
out.ErrLn("Error caching kubectl: %v", err)
}
......@@ -82,12 +82,3 @@ minikube kubectl -- get pods --namespace kube-system`,
}
},
}
func cacheKubectlBinary(k8sVerison string) (string, error) {
binary := "kubectl"
if runtime.GOOS == "windows" {
binary = "kubectl.exe"
}
return machine.CacheBinary(binary, k8sVerison, runtime.GOOS, runtime.GOARCH)
}
......@@ -290,7 +290,7 @@ func TestStartHostConfig(t *testing.T) {
func TestStopHostError(t *testing.T) {
RegisterMockDriver(t)
api := tests.NewMockAPI(t)
if err := StopHost(api, "minikube"); err == nil {
if err := StopHost(api, viper.GetString("profile")); err == nil {
t.Fatal("An error should be thrown when stopping non-existing machine.")
}
}
......@@ -303,7 +303,7 @@ func TestStopHost(t *testing.T) {
t.Errorf("createHost failed: %v", err)
}
if err := StopHost(api, "minikube"); err != nil {
if err := StopHost(api, viper.GetString("profile")); err != nil {
t.Fatal("An error should be thrown when stopping non-existing machine.")
}
if s, _ := h.Driver.GetState(); s != state.Stopped {
......@@ -389,7 +389,7 @@ func TestGetHostStatus(t *testing.T) {
checkState(state.Running.String())
if err := StopHost(api, "minikube"); err != nil {
if err := StopHost(api, viper.GetString("profile")); err != nil {
t.Errorf("StopHost failed: %v", err)
}
checkState(state.Stopped.String())
......
......@@ -18,6 +18,7 @@ package node
import (
"os"
"runtime"
"github.com/golang/glog"
"github.com/spf13/viper"
......@@ -51,6 +52,9 @@ func handleDownloadOnly(cacheGroup *errgroup.Group, k8sVersion string) {
if err := doCacheBinaries(k8sVersion); err != nil {
exit.WithError("Failed to cache binaries", err)
}
if _, err := CacheKubectlBinary(k8sVersion); err != nil {
exit.WithError("Failed to cache kubectl", err)
}
waitCacheRequiredImages(cacheGroup)
if err := saveImagesToTarFromConfig(); err != nil {
exit.WithError("Failed to cache images to tar", err)
......@@ -60,6 +64,16 @@ func handleDownloadOnly(cacheGroup *errgroup.Group, k8sVersion string) {
}
// CacheKubectlBinary caches the kubectl binary
func CacheKubectlBinary(k8sVerison string) (string, error) {
binary := "kubectl"
if runtime.GOOS == "windows" {
binary = "kubectl.exe"
}
return machine.CacheBinary(binary, k8sVerison, runtime.GOOS, runtime.GOARCH)
}
// doCacheBinaries caches Kubernetes binaries in the foreground
func doCacheBinaries(k8sVersion string) error {
return machine.CacheBinariesForBootstrapper(k8sVersion, viper.GetString(cmdcfg.Bootstrapper))
......
......@@ -39,7 +39,7 @@ import (
"k8s.io/minikube/pkg/util/retry"
)
func startMachine(cfg *config.MachineConfig, n *config.Node) (runner command.Runner, preExists bool, machineAPI libmachine.API, host *host.Host) {
func startMachine(cfg *config.MachineConfig, node *config.Node) (runner command.Runner, preExists bool, machineAPI libmachine.API, host *host.Host) {
m, err := machine.NewAPIClient()
if err != nil {
exit.WithError("Failed to get machine client", err)
......@@ -58,9 +58,9 @@ func startMachine(cfg *config.MachineConfig, n *config.Node) (runner command.Run
out.ErrT(out.FailureType, "Failed to set NO_PROXY Env. Please use `export NO_PROXY=$NO_PROXY,{{.ip}}`.", out.V{"ip": ip})
}
// Save IP to configuration file for subsequent use
n.IP = ip
node.IP = ip
if err := Save(cfg, n); err != nil {
if err := Save(cfg, node); err != nil {
exit.WithError("Failed to save config", err)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment