Replace %s format directives with %v for errors.

Previously we were mixed between the two forms. This commit picks %v,
which is consistent with the Kubernetes code base. They both effectively
do the same thing in this case, though %v works with any object, and %s
only with string objects.
pull/3187/head
Thomas Stromberg 2018-09-28 16:05:27 -07:00
parent af61bf790c
commit 055c8002b1
59 changed files with 194 additions and 179 deletions

View File

@ -18,12 +18,13 @@ package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
cmdConfig "k8s.io/minikube/cmd/minikube/cmd/config"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/machine"
"os"
)
// cacheCmd represents the cache command
@ -41,12 +42,12 @@ var addCacheCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
// Cache and load images into docker daemon
if err := machine.CacheAndLoadImages(args); err != nil {
fmt.Fprintf(os.Stderr, "Error caching and loading images: %s\n", err)
fmt.Fprintf(os.Stderr, "Error caching and loading images: %v\n", err)
os.Exit(1)
}
// Add images to config file
if err := cmdConfig.AddToConfigMap(constants.Cache, args); err != nil {
fmt.Fprintf(os.Stderr, "Error adding cached images to config file: %s\n", err)
fmt.Fprintf(os.Stderr, "Error adding cached images to config file: %v\n", err)
os.Exit(1)
}
},
@ -60,12 +61,12 @@ var deleteCacheCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
// Delete images from config file
if err := cmdConfig.DeleteFromConfigMap(constants.Cache, args); err != nil {
fmt.Fprintf(os.Stderr, "Error deleting images from config file: %s\n", err)
fmt.Fprintf(os.Stderr, "Error deleting images from config file: %v\n", err)
os.Exit(1)
}
// Delete images from cache/images directory
if err := machine.DeleteFromImageCacheDir(args); err != nil {
fmt.Fprintf(os.Stderr, "Error deleting images: %s\n", err)
fmt.Fprintf(os.Stderr, "Error deleting images: %v\n", err)
os.Exit(1)
}
},

View File

@ -41,11 +41,11 @@ var listCacheCmd = &cobra.Command{
// list images from config file
images, err := cmdConfig.ListConfigMap(constants.Cache)
if err != nil {
fmt.Fprintf(os.Stderr, "Error listing image entries from config: %s\n", err)
fmt.Fprintf(os.Stderr, "Error listing image entries from config: %v\n", err)
os.Exit(1)
}
if err := cacheList(images); err != nil {
fmt.Fprintf(os.Stderr, "Error listing images: %s\n", err)
fmt.Fprintf(os.Stderr, "Error listing images: %v\n", err)
os.Exit(1)
}
},
@ -62,13 +62,13 @@ func cacheList(images []string) error {
for _, image := range images {
tmpl, err := template.New("list").Parse(cacheListFormat)
if err != nil {
fmt.Fprintf(os.Stderr, "Error creating list template: %s\n", err)
fmt.Fprintf(os.Stderr, "Error creating list template: %v\n", err)
os.Exit(1)
}
listTmplt := CacheListTemplate{image}
err = tmpl.Execute(os.Stdout, listTmplt)
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing list template: %s\n", err)
fmt.Fprintf(os.Stderr, "Error executing list template: %v\n", err)
os.Exit(1)
}
}

View File

@ -80,7 +80,7 @@ func TestHiddenPrint(t *testing.T) {
}
result, err := concealableAskForStaticValue(b, "hello", false)
if err != nil && !test.ShouldError {
t.Errorf("Error asking for concealable static value: %s", err)
t.Errorf("Error asking for concealable static value: %v", err)
continue
}
if result != test.TestString {
@ -94,7 +94,7 @@ func TestWriteConfig(t *testing.T) {
for _, tt := range configTestCases {
err := encode(&b, tt.config)
if err != nil {
t.Errorf("Error encoding: %s", err)
t.Errorf("Error encoding: %v", err)
}
if b.String() != tt.data {
t.Errorf("Did not write config correctly, \n\n expected:\n %+v \n\n actual:\n %+v", tt.data, b.String())

View File

@ -61,7 +61,7 @@ var addonsOpenCmd = &cobra.Command{
//TODO(r2d4): config should not reference API, pull this out
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()
@ -91,7 +91,7 @@ minikube addons enable %s`, addonName, addonName))
serviceList, err := service.GetServiceListByLabel(namespace, key, addonName)
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting service with namespace: %s and labels %s:%s: %s\n", namespace, key, addonName, err)
fmt.Fprintf(os.Stderr, "Error getting service with namespace: %s and labels %s:%s: %v\n", namespace, key, addonName, err)
os.Exit(1)
}
if len(serviceList.Items) == 0 {

View File

@ -104,7 +104,7 @@ func EnableOrDisableAddon(name string, val string) error {
//TODO(r2d4): config package should not reference API, pull this out
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()

View File

@ -38,7 +38,7 @@ func TestFindSettingNotFound(t *testing.T) {
func TestFindSetting(t *testing.T) {
s, err := findSetting("vm-driver")
if err != nil {
t.Fatalf("Couldn't find setting, vm-driver: %s", err)
t.Fatalf("Couldn't find setting, vm-driver: %v", err)
}
if s.name != "vm-driver" {
t.Fatalf("Found wrong setting, expected vm-driver, got %s", s.name)
@ -48,14 +48,14 @@ func TestFindSetting(t *testing.T) {
func TestSetString(t *testing.T) {
err := SetString(minikubeConfig, "vm-driver", "virtualbox")
if err != nil {
t.Fatalf("Couldnt set string: %s", err)
t.Fatalf("Couldnt set string: %v", err)
}
}
func TestSetInt(t *testing.T) {
err := SetInt(minikubeConfig, "cpus", "22")
if err != nil {
t.Fatalf("Couldn't set int in config: %s", err)
t.Fatalf("Couldn't set int in config: %v", err)
}
val, ok := minikubeConfig["cpus"].(int)
if !ok {
@ -69,7 +69,7 @@ func TestSetInt(t *testing.T) {
func TestSetBool(t *testing.T) {
err := SetBool(minikubeConfig, "show-libmachine-logs", "true")
if err != nil {
t.Fatalf("Couldn't set bool in config: %s", err)
t.Fatalf("Couldn't set bool in config: %v", err)
}
val, ok := minikubeConfig["show-libmachine-logs"].(bool)
if !ok {

View File

@ -44,7 +44,7 @@ var dashboardCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()
@ -54,7 +54,7 @@ var dashboardCmd = &cobra.Command{
svc := "kubernetes-dashboard"
if err = commonutil.RetryAfter(20, func() error { return service.CheckService(namespace, svc) }, 6*time.Second); err != nil {
fmt.Fprintf(os.Stderr, "Could not find finalized endpoint being pointed to by %s: %s\n", svc, err)
fmt.Fprintf(os.Stderr, "Could not find finalized endpoint being pointed to by %s: %v\n", svc, err)
os.Exit(1)
}

View File

@ -44,7 +44,7 @@ associated files.`,
fmt.Println("Deleting local Kubernetes cluster...")
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()

View File

@ -302,13 +302,13 @@ var dockerEnvCmd = &cobra.Command{
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()
host, err := cluster.CheckIfApiExistsAndLoad(api)
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting host: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting host: %v\n", err)
os.Exit(1)
}
if host.Driver.DriverName() == "none" {

View File

@ -244,7 +244,7 @@ func TestShellCfgSet(t *testing.T) {
t.Errorf("Shell cfgs differ: expected %+v, \n\n got %+v", test.expectedShellCfg, shellCfg)
}
if err != nil && !test.shouldErr {
t.Errorf("Test should have failed but didn't return error: %s, error: %s", test.description, err)
t.Errorf("Test should have failed but didn't return error: %s, error: %v", test.description, err)
}
if err == nil && test.shouldErr {
t.Errorf("Test didn't return error but should have: %s", test.description)

View File

@ -34,7 +34,7 @@ var ipCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()

View File

@ -41,13 +41,13 @@ var logsCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()
clusterBootstrapper, err := GetClusterBootstrapper(api, viper.GetString(cmdcfg.Bootstrapper))
if err != nil {
glog.Exitf("Error getting cluster bootstrapper: %s", err)
glog.Exitf("Error getting cluster bootstrapper: %v", err)
}
err = clusterBootstrapper.GetClusterLogsTo(follow, os.Stdout)

View File

@ -93,7 +93,7 @@ var mountCmd = &cobra.Command{
}
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()

View File

@ -70,7 +70,7 @@ var RootCmd = &cobra.Command{
PersistentPreRun: func(cmd *cobra.Command, args []string) {
for _, path := range dirs {
if err := os.MkdirAll(path, 0777); err != nil {
glog.Exitf("Error creating minikube directory: %s", err)
glog.Exitf("Error creating minikube directory: %v", err)
}
}
@ -143,7 +143,7 @@ func initConfig() {
viper.SetConfigType("json")
err := viper.ReadInConfig()
if err != nil {
glog.Warningf("Error reading config file at %s: %s", configPath, err)
glog.Warningf("Error reading config file at %s: %v", configPath, err)
}
setupViper()
}

View File

@ -65,7 +65,7 @@ var serviceCmd = &cobra.Command{
svc := args[0]
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()
@ -74,7 +74,7 @@ var serviceCmd = &cobra.Command{
err = service.WaitAndMaybeOpenService(api, namespace, svc,
serviceURLTemplate, serviceURLMode, https, wait, interval)
if err != nil {
fmt.Fprintf(os.Stderr, "Error opening service: %s\n", err)
fmt.Fprintf(os.Stderr, "Error opening service: %v\n", err)
os.Exit(1)
}
},

View File

@ -39,7 +39,7 @@ var serviceListCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()

View File

@ -35,13 +35,13 @@ var sshCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()
host, err := cluster.CheckIfApiExistsAndLoad(api)
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting host: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting host: %v\n", err)
os.Exit(1)
}
if host.Driver.DriverName() == "none" {

View File

@ -112,14 +112,14 @@ func runStart(cmd *cobra.Command, args []string) {
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()
exists, err := api.Exists(cfg.GetMachineName())
if err != nil {
glog.Exitf("checking if machine exists: %s", err)
glog.Exitf("checking if machine exists: %v", err)
}
diskSize := viper.GetString(humanReadableDiskSize)
@ -165,7 +165,7 @@ func runStart(cmd *cobra.Command, args []string) {
start := func() (err error) {
host, err = cluster.StartHost(api, config)
if err != nil {
glog.Errorf("Error starting host: %s.\n\n Retrying.\n", err)
glog.Errorf("Error starting host: %v.\n\n Retrying.\n", err)
}
return err
}
@ -228,7 +228,7 @@ func runStart(cmd *cobra.Command, args []string) {
k8sBootstrapper, err := GetClusterBootstrapper(api, clusterBootstrapper)
if err != nil {
glog.Exitf("Error getting cluster bootstrapper: %s", err)
glog.Exitf("Error getting cluster bootstrapper: %v", err)
}
// Write profile cluster configuration to file
@ -321,12 +321,12 @@ func runStart(cmd *cobra.Command, args []string) {
}
err = mountCmd.Start()
if err != nil {
glog.Errorf("Error running command minikube mount %s", err)
glog.Errorf("Error running command minikube mount %v", err)
cmdutil.MaybeReportErrorAndExit(err)
}
err = ioutil.WriteFile(filepath.Join(constants.GetMinipath(), constants.MountProcessFileName), []byte(strconv.Itoa(mountCmd.Process.Pid)), 0644)
if err != nil {
glog.Errorf("Error writing mount process pid to file: %s", err)
glog.Errorf("Error writing mount process pid to file: %v", err)
cmdutil.MaybeReportErrorAndExit(err)
}
}

View File

@ -61,7 +61,7 @@ var statusCmd = &cobra.Command{
var returnCode = 0
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(internalErrorCode)
}
defer api.Close()
@ -77,7 +77,7 @@ var statusCmd = &cobra.Command{
if ms == state.Running.String() {
clusterBootstrapper, err := GetClusterBootstrapper(api, viper.GetString(cmdcfg.Bootstrapper))
if err != nil {
glog.Errorf("Error getting cluster bootstrapper: %s", err)
glog.Errorf("Error getting cluster bootstrapper: %v", err)
cmdUtil.MaybeReportErrorAndExitWithCode(err, internalErrorCode)
}
cs, err = clusterBootstrapper.GetClusterStatus()

View File

@ -36,7 +36,7 @@ itself, leaving all files intact. The cluster can be started again with the "sta
fmt.Println("Stopping local Kubernetes cluster...")
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()

View File

@ -39,7 +39,7 @@ var updateContextCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
api, err := machine.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting client: %s\n", err)
fmt.Fprintf(os.Stderr, "Error getting client: %v\n", err)
os.Exit(1)
}
defer api.Close()

View File

@ -28,7 +28,7 @@ import (
func main() {
// Glog requires that /tmp exists.
if err := os.MkdirAll("/tmp", 0755); err != nil {
fmt.Printf("Error creating tmpdir: %s\n", err)
fmt.Printf("Error creating tmpdir: %v\n", err)
os.Exit(1)
}
flag.Parse()

View File

@ -48,7 +48,7 @@ func TestFormatError(t *testing.T) {
_, err := FormatError(testErr)
if err != nil {
t.Fatalf("Unexpected error: %s", err)
t.Fatalf("Unexpected error: %v", err)
}
}
@ -59,7 +59,7 @@ func TestMarshallError(t *testing.T) {
errMsg, _ := FormatError(testErr)
if _, err := MarshallError(errMsg, "default", version.GetVersion()); err != nil {
t.Fatalf("Unexpected error: %s", err)
t.Fatalf("Unexpected error: %v", err)
}
}
@ -75,7 +75,7 @@ func TestUploadError(t *testing.T) {
}))
if err := UploadError(jsonErrMsg, server.URL); err != nil {
t.Fatalf("Unexpected error: %s", err)
t.Fatalf("Unexpected error: %v", err)
}
server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

View File

@ -50,7 +50,7 @@ func getShaFromURL(url string) (string, error) {
func TestReleasesJson(t *testing.T) {
releases, err := notify.GetAllVersionsFromURL(constants.GithubMinikubeReleasesURL)
if err != nil {
t.Fatalf("Error getting releases.json: %s", err)
t.Fatalf("Error getting releases.json: %v", err)
}
for _, r := range releases {
@ -59,7 +59,7 @@ func TestReleasesJson(t *testing.T) {
fmt.Printf("Checking SHA for %s.\n", platform)
actualSha, err := getShaFromURL(util.GetBinaryDownloadURL(r.Name, platform))
if err != nil {
t.Errorf("Error calculating SHA for %s-%s. Error: %s", r.Name, platform, err)
t.Errorf("Error calculating SHA for %s-%s. Error: %v", r.Name, platform, err)
continue
}
if actualSha != sha {

View File

@ -151,7 +151,7 @@ func (d *Driver) Kill() error {
func (d *Driver) Remove() error {
s, err := d.GetState()
if err != nil || s == state.Error {
log.Infof("Error checking machine status: %s, assuming it has been removed already", err)
log.Infof("Error checking machine status: %v, assuming it has been removed already", err)
}
if s == state.Running {
if err := d.Stop(); err != nil {
@ -229,7 +229,8 @@ func (d *Driver) Start() error {
time.Sleep(time.Second * 30)
err = d.setupNFSShare()
if err != nil {
log.Errorf("NFS setup failed: %s", err.Error())
// TODO(tstromberg): Check that logging an and error and return it is appropriate. Seems weird.
log.Errorf("NFS setup failed: %v", err)
return err
}
}
@ -350,13 +351,13 @@ func (d *Driver) getPid() int {
f, err := os.Open(pidPath)
if err != nil {
log.Warnf("Error reading pid file: %s", err)
log.Warnf("Error reading pid file: %v", err)
return 0
}
dec := json.NewDecoder(f)
config := hyperkit.HyperKit{}
if err := dec.Decode(&config); err != nil {
log.Warnf("Error decoding pid file: %s", err)
log.Warnf("Error decoding pid file: %v", err)
return 0
}
@ -368,12 +369,12 @@ func (d *Driver) cleanupNfsExports() {
log.Infof("You must be root to remove NFS shared folders. Please type root password.")
for _, share := range d.NFSShares {
if _, err := nfsexports.Remove("", d.nfsExportIdentifier(share)); err != nil {
log.Errorf("failed removing nfs share (%s): %s", share, err.Error())
log.Errorf("failed removing nfs share (%s): %v", share, err)
}
}
if err := nfsexports.ReloadDaemon(); err != nil {
log.Errorf("failed to reload the nfs daemon: %s", err.Error())
log.Errorf("failed to reload the nfs daemon: %v", err
}
}
}

View File

@ -356,7 +356,7 @@ func (d *Driver) Stop() error {
}
return fmt.Errorf("Could not stop VM, current state %s", s.String())
return fmt.Errorf("Could not stop VM, current state %s", s.String()
}
func (d *Driver) Remove() error {
@ -370,7 +370,7 @@ func (d *Driver) Remove() error {
// Tear down network if it exists and is not in use by another minikube instance
log.Debug("Trying to delete the networks (if possible)")
if err := d.deleteNetwork(); err != nil {
log.Warnf("Deleting of networks failed: %s", err.Error())
log.Warnf("Deleting of networks failed: %v", err)
} else {
log.Info("Successfully deleted networks")
}

View File

@ -277,7 +277,7 @@ func (d *Driver) lookupIPFromStatusFile(conn *libvirt.Connect) (string, error) {
bridge, err := network.GetBridgeName()
if err != nil {
log.Warnf("Failed to get network bridge: %s", err)
log.Warnf("Failed to get network bridge: %v", err)
return "", err
}
statusFile := fmt.Sprintf("/var/lib/libvirt/dnsmasq/%s.status", bridge)

View File

@ -124,7 +124,7 @@ func (d *Driver) Kill() error {
} {
cmd := exec.Command("sudo", cmdStr...)
if out, err := cmd.CombinedOutput(); err != nil {
glog.Warningf("Error %s running command: %s. Output: %s", err, cmdStr, string(out))
glog.Warningf("Error %v running command: %s. Output: %s", err, cmdStr, out)
}
}
return nil
@ -138,7 +138,7 @@ func (d *Driver) Remove() error {
for _, cmdStr := range []string{rmCmd, dockerkillcmd} {
if out, err := runCommand(cmdStr, true); err != nil {
glog.Warningf("Error %s running command: %s, Output: %s", err, cmdStr, out)
glog.Warningf("Error %v running command: %s, Output: %s", err, cmdStr, out)
}
}
@ -192,7 +192,7 @@ fi
}
}
if out, err := runCommand(dockerstopcmd, false); err != nil {
glog.Warningf("Error %s running command %s. Output: %s", err, dockerstopcmd, out)
glog.Warningf("Error %v running command %s. Output: %s", err, dockerstopcmd, out)
}
return nil
}

View File

@ -44,7 +44,7 @@ func TestSetupCerts(t *testing.T) {
}
if err := SetupCerts(f, k8s); err != nil {
t.Fatalf("Error starting cluster: %s", err)
t.Fatalf("Error starting cluster: %v", err)
}
for _, cert := range filesToBeTransferred {
_, err := f.GetFileToContents(cert)

View File

@ -234,7 +234,7 @@ schedulerExtraArgs:
t.Run(test.description, func(t *testing.T) {
actualCfg, err := generateConfig(test.cfg)
if err != nil && !test.shouldErr {
t.Errorf("got unexpected error generating config: %s", err)
t.Errorf("got unexpected error generating config: %v", err)
return
}
if err == nil && test.shouldErr {

View File

@ -96,7 +96,7 @@ func TestVersionIsBetween(t *testing.T) {
func TestParseKubernetesVersion(t *testing.T) {
version, err := ParseKubernetesVersion("v1.8.0-alpha.5")
if err != nil {
t.Fatalf("Error parsing version: %s", err)
t.Fatalf("Error parsing version: %v", err)
}
if version.NE(semver.MustParse("1.8.0-alpha.5")) {
t.Errorf("Expected: %s, Actual:%s", "1.8.0-alpha.5", version)
@ -141,7 +141,7 @@ func TestParseFeatureArgs(t *testing.T) {
kubeadm, component, err := ParseFeatureArgs(test.featureGates)
if err != nil {
t.Fatalf("Error parsing feature args: %s", err)
t.Fatalf("Error parsing feature args: %v", err)
}
if !reflect.DeepEqual(kubeadm, test.expectedKubeadmFeatureArgs) {

View File

@ -229,7 +229,7 @@ func TestDeleteHost(t *testing.T) {
createHost(api, defaultMachineConfig)
if err := DeleteHost(api); err != nil {
t.Fatalf("Unexpected error deleting host: %s", err)
t.Fatalf("Unexpected error deleting host: %v", err)
}
}
@ -274,7 +274,7 @@ func TestDeleteHostMultipleErrors(t *testing.T) {
expectedErrors := []string{"Error removing " + config.GetMachineName(), "Error deleting machine"}
for _, expectedError := range expectedErrors {
if !strings.Contains(err.Error(), expectedError) {
t.Fatalf("Error %s expected to contain: %s.", err, expectedError)
t.Fatalf("Error %v expected to contain: %s.", err, expectedError)
}
}
}
@ -285,7 +285,7 @@ func TestGetHostStatus(t *testing.T) {
checkState := func(expected string) {
s, err := GetHostStatus(api)
if err != nil {
t.Fatalf("Unexpected error getting status: %s", err)
t.Fatalf("Unexpected error getting status: %v", err)
}
if s != expected {
t.Fatalf("Expected status: %s, got %s", s, expected)
@ -319,7 +319,7 @@ func TestGetHostDockerEnv(t *testing.T) {
envMap, err := GetHostDockerEnv(api)
if err != nil {
t.Fatalf("Unexpected error getting env: %s", err)
t.Fatalf("Unexpected error getting env: %v", err)
}
dockerEnvKeys := [...]string{
@ -352,7 +352,7 @@ func TestGetHostDockerEnvIPv6(t *testing.T) {
envMap, err := GetHostDockerEnv(api)
if err != nil {
t.Fatalf("Unexpected error getting env: %s", err)
t.Fatalf("Unexpected error getting env: %v", err)
}
expected := "tcp://[fe80::215:5dff:fe00:a903]:2376"
@ -368,7 +368,7 @@ func TestCreateSSHShell(t *testing.T) {
s, _ := tests.NewSSHServer()
port, err := s.Start()
if err != nil {
t.Fatalf("Error starting ssh server: %s", err)
t.Fatalf("Error starting ssh server: %v", err)
}
d := &tests.MockDriver{
@ -383,7 +383,7 @@ func TestCreateSSHShell(t *testing.T) {
cliArgs := []string{"exit"}
if err := CreateSSHShell(api, cliArgs); err != nil {
t.Fatalf("Error running ssh command: %s", err)
t.Fatalf("Error running ssh command: %v", err)
}
if !s.IsSessionRequested() {

View File

@ -62,7 +62,7 @@ func detectVBoxManageCmd() string {
func findVBoxInstallDirInRegistry() (string, error) {
registryKey, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Oracle\VirtualBox`, registry.QUERY_VALUE)
if err != nil {
errorMessage := fmt.Sprintf("Can't find VirtualBox registry entries, is VirtualBox really installed properly? %s", err)
errorMessage := fmt.Sprintf("Can't find VirtualBox registry entries, is VirtualBox really installed properly? %v", err)
glog.Errorf(errorMessage)
return "", errors.New(errorMessage)
}
@ -71,7 +71,7 @@ func findVBoxInstallDirInRegistry() (string, error) {
installDir, _, err := registryKey.GetStringValue("InstallDir")
if err != nil {
errorMessage := fmt.Sprintf("Can't find InstallDir registry key within VirtualBox registries entries, is VirtualBox really installed properly? %s", err)
errorMessage := fmt.Sprintf("Can't find InstallDir registry key within VirtualBox registries entries, is VirtualBox really installed properly? %v", err)
glog.Errorf(errorMessage)
return "", errors.New(errorMessage)
}

View File

@ -63,13 +63,13 @@ func ReadConfig() (MinikubeConfig, error) {
if os.IsNotExist(err) {
return make(map[string]interface{}), nil
}
return nil, fmt.Errorf("Could not open file %s: %s", constants.ConfigFile, err)
return nil, fmt.Errorf("Could not open file %s: %v", constants.ConfigFile, err)
}
defer f.Close()
m, err := decode(f)
if err != nil {
return nil, fmt.Errorf("Could not decode config %s: %s", constants.ConfigFile, err)
return nil, fmt.Errorf("Could not decode config %s: %v", constants.ConfigFile, err)
}
return m, nil

View File

@ -26,7 +26,7 @@ import (
func TestReplaceWinDriveLetterToVolumeName(t *testing.T) {
path, err := ioutil.TempDir("", "repwindl2vn")
if err != nil {
t.Fatalf("Error make tmp directory: %s", err)
t.Fatalf("Error make tmp directory: %v", err)
}
defer os.RemoveAll(path)
@ -40,7 +40,7 @@ func TestReplaceWinDriveLetterToVolumeName(t *testing.T) {
}
if _, err := replaceWinDriveLetterToVolumeName(path); err != nil {
t.Errorf("Error replace a Windows drive letter to a volume name: %s", err)
t.Errorf("Error replace a Windows drive letter to a volume name: %v", err)
}
}

View File

@ -102,7 +102,7 @@ func TestLocalClientNewHost(t *testing.T) {
}
}
if err != nil && !test.err {
t.Errorf("Unexpected error: %s", err)
t.Errorf("Unexpected error: %v", err)
}
if err == nil && test.err {
t.Errorf("No error returned, but expected err")

View File

@ -76,7 +76,7 @@ func (*K8sClientGetter) GetClientset() (*kubernetes.Clientset, error) {
kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides)
clientConfig, err := kubeConfig.ClientConfig()
if err != nil {
return nil, fmt.Errorf("Error creating kubeConfig: %s", err)
return nil, fmt.Errorf("Error creating kubeConfig: %v", err)
}
client, err := kubernetes.NewForConfig(clientConfig)
if err != nil {

View File

@ -274,7 +274,7 @@ func TestPrintURLsForService(t *testing.T) {
t.Parallel()
urls, err := printURLsForService(client, "127.0.0.1", test.serviceName, test.namespace, test.tmpl)
if err != nil && !test.err {
t.Errorf("Error: %s", err)
t.Errorf("Error: %v", err)
}
if err == nil && test.err {
t.Errorf("Expected error but got none")
@ -398,7 +398,7 @@ func TestGetServiceURLs(t *testing.T) {
}
urls, err := GetServiceURLs(test.api, test.namespace, defaultTemplate)
if err != nil && !test.err {
t.Errorf("Error GetServiceURLs %s", err)
t.Errorf("Error GetServiceURLs %v", err)
}
if err == nil && test.err {
t.Errorf("Test should have failed, but didn't")
@ -461,7 +461,7 @@ func TestGetServiceURLsForService(t *testing.T) {
}
urls, err := GetServiceURLsForService(test.api, test.namespace, test.service, defaultTemplate)
if err != nil && !test.err {
t.Errorf("Error GetServiceURLsForService %s", err)
t.Errorf("Error GetServiceURLsForService %v", err)
}
if err == nil && test.err {
t.Errorf("Test should have failed, but didn't")

View File

@ -28,7 +28,7 @@ func TestNewSSHClient(t *testing.T) {
s, _ := tests.NewSSHServer()
port, err := s.Start()
if err != nil {
t.Fatalf("Error starting ssh server: %s", err)
t.Fatalf("Error starting ssh server: %v", err)
}
d := &tests.MockDriver{
Port: port,
@ -39,7 +39,7 @@ func TestNewSSHClient(t *testing.T) {
}
c, err := NewSSHClient(d)
if err != nil {
t.Fatalf("Unexpected error: %s", err)
t.Fatalf("Unexpected error: %v", err)
}
cmd := "foo"
@ -75,7 +75,7 @@ func TestNewSSHHost(t *testing.T) {
h, err := newSSHHost(&d)
if err != nil {
t.Fatalf("Unexpected error creating host: %s", err)
t.Fatalf("Unexpected error creating host: %v", err)
}
if h.SSHKeyPath != sshKeyPath {

View File

@ -120,7 +120,7 @@ func (s *SSHServer) Start() (int, error) {
// Note: string(req.Payload) adds additional characters to start of input.
var cmd execRequest
if err := ssh.Unmarshal(req.Payload, &cmd); err != nil {
glog.Errorf("Unmarshall encountered error: %s with req: %v", err, req.Type)
glog.Errorf("Unmarshall encountered error: %v with req: %v", err, req.Type)
return
}
s.Commands[cmd.Command] = 1

View File

@ -208,7 +208,7 @@ CRIO_MINIKUBE_OPTIONS='{{ range .EngineOptions.InsecureRegistry }}--insecure-reg
// This is unlikely to cause issues unless the user has explicitly requested CRIO, so just log a warning.
if err := p.Service("crio", serviceaction.Restart); err != nil {
log.Warn("Unable to restart crio service. Error: %s", err)
log.Warn("Unable to restart crio service. Error: %v", err)
}
return nil
@ -264,7 +264,7 @@ func configureAuth(p *BuildrootProvisioner) error {
})
if err != nil {
return fmt.Errorf("error generating server cert: %s", err)
return fmt.Errorf("error generating server cert: %v", err)
}
remoteCerts := map[string]string{

View File

@ -66,19 +66,19 @@ func setElement(e reflect.Value, v string) error {
case net.IPNet:
_, cidr, err := net.ParseCIDR(v)
if err != nil {
return fmt.Errorf("Error converting input %s to a CIDR: %s", v, err)
return fmt.Errorf("Error converting input %s to a CIDR: %v", v, err)
}
e.Set(reflect.ValueOf(*cidr))
case utilnet.PortRange:
pr, err := utilnet.ParsePortRange(v)
if err != nil {
return fmt.Errorf("Error converting input %s to PortRange: %s", v, err)
return fmt.Errorf("Error converting input %s to PortRange: %v", v, err)
}
e.Set(reflect.ValueOf(*pr))
case time.Duration:
dur, err := time.ParseDuration(v)
if err != nil {
return fmt.Errorf("Error converting input %s to Duration: %s", v, err)
return fmt.Errorf("Error converting input %s to Duration: %v", v, err)
}
e.Set(reflect.ValueOf(dur))
case []string:
@ -126,7 +126,7 @@ func convertMap(e reflect.Value, v string) error {
func convertInt(e reflect.Value, v string) error {
i, err := strconv.Atoi(v)
if err != nil {
return fmt.Errorf("Error converting input %s to an integer: %s", v, err)
return fmt.Errorf("Error converting input %s to an integer: %v", v, err)
}
e.SetInt(int64(i))
return nil
@ -140,7 +140,7 @@ func convertString(e reflect.Value, v string) error {
func convertFloat(e reflect.Value, v string) error {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
return fmt.Errorf("Error converting input %s to a float: %s", v, err)
return fmt.Errorf("Error converting input %s to a float: %v", v, err)
}
e.SetFloat(f)
return nil
@ -149,7 +149,7 @@ func convertFloat(e reflect.Value, v string) error {
func convertBool(e reflect.Value, v string) error {
b, err := strconv.ParseBool(v)
if err != nil {
return fmt.Errorf("Error converting input %s to a bool: %s", v, err)
return fmt.Errorf("Error converting input %s to a bool: %v", v, err)
}
e.SetBool(b)
return nil

View File

@ -104,7 +104,7 @@ func TestFindNestedStrings(t *testing.T) {
} {
v, err := findNestedElement(tc.input, &a)
if err != nil {
t.Fatalf("Did not expect error. Got: %s", err)
t.Fatalf("Did not expect error. Got: %v", err)
}
if v.String() != tc.output {
t.Fatalf("Expected: %s, got %s", tc.output, v.String())
@ -126,7 +126,7 @@ func TestFindNestedInts(t *testing.T) {
} {
v, err := findNestedElement(tc.input, &a)
if err != nil {
t.Fatalf("Did not expect error. Got: %s", err)
t.Fatalf("Did not expect error. Got: %v", err)
}
if v.Int() != tc.output {
t.Fatalf("Expected: %d, got %d", tc.output, v.Int())
@ -151,7 +151,7 @@ func TestFindNestedFloats(t *testing.T) {
} {
v, err := findNestedElement(tc.input, &a)
if err != nil {
t.Fatalf("Did not expect error. Got: %s", err)
t.Fatalf("Did not expect error. Got: %v", err)
}
// Floating point comparison is tricky.
@ -187,7 +187,7 @@ func TestSetElement(t *testing.T) {
} {
a := buildConfig()
if err := FindAndSet(tc.path, &a, tc.newval); err != nil {
t.Fatalf("Error setting value: %s", err)
t.Fatalf("Error setting value: %v", err)
}
if !tc.checker(a) {
t.Fatalf("Error, values not correct: %v, %s, %s", a, tc.newval, tc.path)

View File

@ -59,7 +59,7 @@ func TestCacheMinikubeISOFromURL(t *testing.T) {
}))
isoURL := server.URL + "/minikube-test.iso"
if err := dler.CacheMinikubeISOFromURL(isoURL); err != nil {
t.Fatalf("Unexpected error from CacheMinikubeISOFromURL: %s", err)
t.Fatalf("Unexpected error from CacheMinikubeISOFromURL: %v", err)
}
transferred, err := ioutil.ReadFile(filepath.Join(isoPath))

View File

@ -70,7 +70,7 @@ func TestValidFlags(t *testing.T) {
var e ExtraOptionSlice
flags.Var(&e, "e", "usage")
if err := flags.Parse(tc.args); err != nil {
t.Errorf("Unexpected error: %s for %s.", err, tc)
t.Errorf("Unexpected error: %v for %s.", err, tc)
}
if !reflect.DeepEqual(e, tc.values) {

View File

@ -143,7 +143,7 @@ func TestSetupKubeConfig(t *testing.T) {
t.Parallel()
tmpDir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatalf("Error making temp directory %s", err)
t.Fatalf("Error making temp directory %v", err)
}
test.cfg.SetKubeConfigFile(filepath.Join(tmpDir, "kubeconfig"))
if len(test.existingCfg) != 0 {
@ -151,14 +151,14 @@ func TestSetupKubeConfig(t *testing.T) {
}
err = SetupKubeConfig(test.cfg)
if err != nil && !test.err {
t.Errorf("Got unexpected error: %s", err)
t.Errorf("Got unexpected error: %v", err)
}
if err == nil && test.err {
t.Errorf("Expected error but got none")
}
config, err := ReadConfigOrNew(test.cfg.GetKubeConfigFile())
if err != nil {
t.Errorf("Error reading kubeconfig file: %s", err)
t.Errorf("Error reading kubeconfig file: %v", err)
}
if test.cfg.KeepContext && config.CurrentContext == test.cfg.ClusterName {
t.Errorf("Context was changed even though KeepContext was true")
@ -213,10 +213,10 @@ func TestGetKubeConfigStatus(t *testing.T) {
configFilename := tempFile(t, test.existing)
statusActual, err := GetKubeConfigStatus(test.ip, configFilename, "minikube")
if err != nil && !test.err {
t.Errorf("Got unexpected error: %s", err)
t.Errorf("Got unexpected error: %v", err)
}
if err == nil && test.err {
t.Errorf("Expected error but got none: %s", err)
t.Errorf("Expected error but got none: %v", err)
}
if test.status != statusActual {
t.Errorf("Expected status %t, but got %t", test.status, statusActual)
@ -270,10 +270,10 @@ func TestUpdateKubeconfigIP(t *testing.T) {
configFilename := tempFile(t, test.existing)
statusActual, err := UpdateKubeconfigIP(test.ip, configFilename, "minikube")
if err != nil && !test.err {
t.Errorf("Got unexpected error: %s", err)
t.Errorf("Got unexpected error: %v", err)
}
if err == nil && test.err {
t.Errorf("Expected error but got none: %s", err)
t.Errorf("Expected error but got none: %v", err)
}
if test.status != statusActual {
t.Errorf("Expected status %t, but got %t", test.status, statusActual)
@ -357,10 +357,10 @@ func TestGetIPFromKubeConfig(t *testing.T) {
configFilename := tempFile(t, test.cfg)
ip, err := getIPFromKubeConfig(configFilename, "minikube")
if err != nil && !test.err {
t.Errorf("Got unexpected error: %s", err)
t.Errorf("Got unexpected error: %v", err)
}
if err == nil && test.err {
t.Errorf("Expected error but got none: %s", err)
t.Errorf("Expected error but got none: %v", err)
}
if !ip.Equal(test.ip) {
t.Errorf("IP returned: %s does not match ip given: %s", ip, test.ip)

View File

@ -66,7 +66,7 @@ func GetClient() (kubernetes.Interface, error) {
kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides)
config, err := kubeConfig.ClientConfig()
if err != nil {
return nil, fmt.Errorf("Error creating kubeConfig: %s", err)
return nil, fmt.Errorf("Error creating kubeConfig: %v", err)
}
client, err := kubernetes.NewForConfig(config)
if err != nil {

View File

@ -46,7 +46,7 @@ func (r RetriableError) Error() string { return "Temporary Error: " + r.Err.Erro
func CalculateDiskSizeInMB(humanReadableDiskSize string) int {
diskSize, err := units.FromHumanSize(humanReadableDiskSize)
if err != nil {
glog.Errorf("Invalid disk size: %s", err)
glog.Errorf("Invalid disk size: %v", err)
}
return int(diskSize / units.MB)
}

View File

@ -130,12 +130,12 @@ func TestMultiError(t *testing.T) {
expected := `Error 1
Error 2`
if err.Error() != expected {
t.Fatalf("%s != %s", err, expected)
t.Fatalf("%s != %s", err.Error(), expected)
}
m = MultiError{}
if err := m.ToError(); err != nil {
t.Fatalf("Unexpected error: %s", err)
t.Fatalf("Unexpected error: %v", err)
}
}

View File

@ -37,7 +37,7 @@ func testAddons(t *testing.T) {
t.Parallel()
client, err := pkgutil.GetClient()
if err != nil {
t.Fatalf("Could not get kubernetes client: %s", err)
t.Fatalf("Could not get kubernetes client: %v", err)
}
selector := labels.SelectorFromSet(labels.Set(map[string]string{"component": "kube-addon-manager"}))
if err := pkgutil.WaitForPodsWithLabelRunning(client, "kube-system", selector); err != nil {
@ -65,7 +65,7 @@ func testDashboard(t *testing.T) {
}
if err := util.Retry(t, checkDashboard, 2*time.Second, 60); err != nil {
t.Fatalf("error checking dashboard URL: %s", err)
t.Fatalf("error checking dashboard URL: %v", err)
}
if u.Scheme != "http" {
@ -87,25 +87,25 @@ func testIngressController(t *testing.T) {
minikubeRunner.RunCommand("addons enable ingress", true)
if err := util.WaitForIngressControllerRunning(t); err != nil {
t.Fatalf("waiting for ingress-controller to be up: %s", err)
t.Fatalf("waiting for ingress-controller to be up: %v", err)
}
if err := util.WaitForIngressDefaultBackendRunning(t); err != nil {
t.Fatalf("waiting for default-http-backend to be up: %s", err)
t.Fatalf("waiting for default-http-backend to be up: %v", err)
}
ingressPath, _ := filepath.Abs("testdata/nginx-ing.yaml")
if _, err := kubectlRunner.RunCommand([]string{"create", "-f", ingressPath}); err != nil {
t.Fatalf("creating nginx ingress resource: %s", err)
t.Fatalf("creating nginx ingress resource: %v", err)
}
podPath, _ := filepath.Abs("testdata/nginx-pod-svc.yaml")
if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil {
t.Fatalf("creating nginx ingress resource: %s", err)
t.Fatalf("creating nginx ingress resource: %v", err)
}
if err := util.WaitForNginxRunning(t); err != nil {
t.Fatalf("waiting for nginx to be up: %s", err)
t.Fatalf("waiting for nginx to be up: %v", err)
}
checkIngress := func() error {

View File

@ -19,56 +19,69 @@ limitations under the License.
package integration
import (
"bytes"
"path/filepath"
"strings"
"testing"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkgutil "k8s.io/minikube/pkg/util"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/kubernetes"
commonutil "k8s.io/minikube/pkg/util"
pkgutil "k8s.io/minikube/pkg/util"
"k8s.io/minikube/test/integration/util"
)
func testClusterDNS(t *testing.T) {
t.Parallel()
kubectlRunner := util.NewKubectlRunner(t)
podPath := filepath.Join(*testdataDir, "busybox.yaml")
client, err := pkgutil.GetClient()
if err != nil {
t.Fatalf("Error getting kubernetes client %s", err)
t.Fatalf("Error getting kubernetes client %v", err)
}
waitForDNS(t, client)
if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil {
t.Fatalf("creating busybox pod: %s", err)
}
kr := util.NewKubectlRunner(t)
busybox := busyBoxPod(t, client, kr)
defer kr.RunCommand([]string{"delete", "po", busybox})
if err := util.WaitForBusyboxRunning(t, "default"); err != nil {
t.Fatalf("Waiting for busybox pod to be up: %s", err)
}
listOpts := metav1.ListOptions{LabelSelector: "integration-test=busybox"}
pods, err := client.CoreV1().Pods("default").List(listOpts)
// The query result is not as important as service reachability
out, err := kr.RunCommand([]string{"exec", busybox, "nslookup", "localhost"})
if err != nil {
t.Fatalf("Unable to list default pods: %v", err)
t.Errorf("nslookup within busybox failed: %v", err)
}
clusterIP := []byte("10.96.0.1")
if !bytes.Contains(out, clusterIP) {
t.Errorf("nslookup did not mention %s:\n%s", clusterIP, out)
}
}
func waitForDNS(t *testing.T, c kubernetes.Interface) {
// Implementation note: both kube-dns and coredns have k8s-app=kube-dns labels.
sel := labels.SelectorFromSet(labels.Set(map[string]string{"k8s-app": "kube-dns"}))
if err := commonutil.WaitForPodsWithLabelRunning(c, "kube-system", sel); err != nil {
t.Fatalf("Waited too long for k8s-app=kube-dns pods")
}
if err := commonutil.WaitForDeploymentToStabilize(c, "kube-system", "kube-dns", time.Minute*2); err != nil {
t.Fatalf("kube-dns deployment failed became stable within 2 minutes")
}
}
func busyBoxPod(t *testing.T, c kubernetes.Interface, kr *util.KubectlRunner) string {
if _, err := kr.RunCommand([]string{"create", "-f", filepath.Join(*testdataDir, "busybox.yaml")}); err != nil {
t.Fatalf("creating busybox pod: %v", err)
- }
// TODO(tstromberg): Refactor WaitForBusyboxRunning to return name of pod.
if err := util.WaitForBusyboxRunning(t, "default"); err != nil {
t.Fatalf("Waiting for busybox pod to be up: %v", err)
}
pods, err := c.CoreV1().Pods("default").List(metav1.ListOptions{LabelSelector: "integration-test=busybox"})
if err != nil {
t.Fatalf("list error: %v", err)
}
if len(pods.Items) == 0 {
t.Fatal("Expected a busybox pod to be running")
}
bbox := pods.Items[0].Name
defer func() {
if out, err := kubectlRunner.RunCommand([]string{"delete", "po", bbox}); err != nil {
t.Logf("delete po %s failed: %v\noutput: %s\n", bbox, err, out)
}
}()
dnsByteArr, err := kubectlRunner.RunCommand([]string{"exec", bbox, "nslookup", "kubernetes"})
if err != nil {
t.Fatalf("running nslookup in pod:%s", err)
}
dnsOutput := string(dnsByteArr)
if !strings.Contains(dnsOutput, "10.96.0.1") || !strings.Contains(dnsOutput, "10.96.0.10") {
t.Errorf("DNS lookup failed, could not find both 10.96.0.1 and 10.96.0.10. Output: %s", dnsOutput)
}
return pods.Items[0].Name
}

View File

@ -33,7 +33,7 @@ func testClusterEnv(t *testing.T) {
dockerEnvVars := minikubeRunner.RunCommand("docker-env", true)
if err := minikubeRunner.SetEnvFromEnvCmdOutput(dockerEnvVars); err != nil {
t.Fatalf("Error parsing output: %s", err)
t.Fatalf("Error parsing output: %v", err)
}
path, err := exec.LookPath("docker")
@ -47,6 +47,6 @@ func testClusterEnv(t *testing.T) {
return nil
}
if err := util.Retry(t, dockerPs, 3*time.Second, 5); err != nil {
t.Fatalf("Error running command: %s. Error: %s Output: %s", "docker ps", err, output)
t.Fatalf("Error running command: %s. Error: %v Output: %s", "docker ps", err, output)
}
}

View File

@ -47,7 +47,7 @@ func testClusterStatus(t *testing.T) {
}
if status != api.ConditionTrue {
err := fmt.Errorf("Component %s is not Healthy! Status: %s", i.GetName(), status)
t.Logf("Retrying, %s", err)
t.Logf("Retrying, %v", err)
return err
}
}
@ -55,6 +55,6 @@ func testClusterStatus(t *testing.T) {
}
if err := util.Retry(t, healthy, 1*time.Second, 5); err != nil {
t.Fatalf("Cluster is not healthy: %s", err)
t.Fatalf("Cluster is not healthy: %v", err)
}
}

View File

@ -74,7 +74,7 @@ func testPackages(t *testing.T) {
for _, pkg := range packages {
if output, err := minikubeRunner.SSH(fmt.Sprintf("which %s", pkg)); err != nil {
t.Errorf("Error finding package: %s. Error: %s. Output: %s", pkg, err, output)
t.Errorf("Error finding package: %s. Error: %v. Output: %s", pkg, err, output)
}
}
@ -94,7 +94,7 @@ func testPersistence(t *testing.T) {
} {
output, err := minikubeRunner.SSH(fmt.Sprintf("df %s | tail -n 1 | awk '{print $1}'", dir))
if err != nil {
t.Errorf("Error checking device for %s. Error: %s.", dir, err)
t.Errorf("Error checking device for %s. Error: %v", dir, err)
}
if !strings.Contains(output, "/dev/sda1") {
t.Errorf("Path %s is not mounted persistently. %s", dir, output)

View File

@ -41,7 +41,7 @@ func testMounting(t *testing.T) {
tempDir, err := ioutil.TempDir("", "mounttest")
if err != nil {
t.Fatalf("Unexpected error while creating tempDir: %s", err)
t.Fatalf("Unexpected error while creating tempDir: %v", err)
}
defer os.RemoveAll(tempDir)
@ -88,11 +88,11 @@ func testMounting(t *testing.T) {
client, err := pkgutil.GetClient()
if err != nil {
t.Fatalf("getting kubernetes client: %s", err)
t.Fatalf("getting kubernetes client: %v", err)
}
selector := labels.SelectorFromSet(labels.Set(map[string]string{"integration-test": "busybox-mount"}))
if err := pkgutil.WaitForPodsWithLabelRunning(client, "default", selector); err != nil {
t.Fatalf("Error waiting for busybox mount pod to be up: %s", err)
t.Fatalf("Error waiting for busybox mount pod to be up: %v", err)
}
mountTest := func() error {

View File

@ -40,16 +40,16 @@ func TestPersistence(t *testing.T) {
// Create a pod and wait for it to be running.
if _, err := kubectlRunner.RunCommand([]string{"create", "-f", podPath}); err != nil {
t.Fatalf("Error creating test pod: %s", err)
t.Fatalf("Error creating test pod: %v", err)
}
verify := func(t *testing.T) {
if err := util.WaitForDashboardRunning(t); err != nil {
t.Fatalf("waiting for dashboard to be up: %s", err)
t.Fatalf("waiting for dashboard to be up: %v", err)
}
if err := util.WaitForBusyboxRunning(t, "default"); err != nil {
t.Fatalf("waiting for busybox to be up: %s", err)
t.Fatalf("waiting for busybox to be up: %v", err)
}
}
@ -66,7 +66,7 @@ func TestPersistence(t *testing.T) {
}
if err := util.Retry(t, checkStop, 5*time.Second, 6); err != nil {
t.Fatalf("timed out while checking stopped status: %s", err)
t.Fatalf("timed out while checking stopped status: %v", err)
}
minikubeRunner.Start()

View File

@ -64,7 +64,7 @@ func testProvisioning(t *testing.T) {
}
if err := util.Retry(t, checkStorageClass, 5*time.Second, 20); err != nil {
t.Fatalf("no default storage class after retry: %s", err)
t.Fatalf("no default storage class after retry: %v", err)
}
// Check that the storage provisioner pod is running
@ -83,13 +83,13 @@ func testProvisioning(t *testing.T) {
}
if err := checkPodRunning(); err != nil {
t.Fatal("Check storage-provisioner pod running failed with error: ", err)
t.Fatalf("Check storage-provisioner pod running failed with error: %v", err)
}
// Now create the PVC
pvcPath := filepath.Join(*testdataDir, "pvc.yaml")
if _, err := kubectlRunner.RunCommand([]string{"create", "-f", pvcPath}); err != nil {
t.Fatalf("Error creating pvc")
t.Fatalf("Error creating pvc: %v", err)
}
// And check that it gets bound to a PV.
@ -106,7 +106,7 @@ func testProvisioning(t *testing.T) {
}
if err := util.Retry(t, checkStorage, 2*time.Second, 5); err != nil {
t.Fatal("PV Creation failed with error:", err)
t.Fatalf("PV Creation failed with error: %v", err)
}
}

View File

@ -50,7 +50,7 @@ func TestStartStop(t *testing.T) {
}
if err := util.Retry(t, checkStop, 5*time.Second, 6); err != nil {
t.Fatalf("timed out while checking stopped status: %s", err)
t.Fatalf("timed out while checking stopped status: %v", err)
}
runner.Start()

View File

@ -75,7 +75,7 @@ func (m *MinikubeRunner) RunCommand(command string, checkError bool) string {
if exitError, ok := err.(*exec.ExitError); ok {
m.T.Fatalf("Error running command: %s %s. Output: %s", command, exitError.Stderr, stdout)
} else {
m.T.Fatalf("Error running command: %s %s. Output: %s", command, err, stdout)
m.T.Fatalf("Error running command: %s %v. Output: %s", command, err, stdout)
}
}
return string(stdout)
@ -87,7 +87,7 @@ func (m *MinikubeRunner) RunDaemon(command string) *exec.Cmd {
cmd := exec.Command(path, commandArr...)
err := cmd.Start()
if err != nil {
m.T.Fatalf("Error running command: %s %s", command, err)
m.T.Fatalf("Error running command: %s %v", command, err)
}
return cmd
}
@ -182,8 +182,8 @@ func (k *KubectlRunner) RunCommand(args []string) (stdout []byte, err error) {
cmd := exec.Command(k.BinaryPath, args...)
stdout, err = cmd.CombinedOutput()
if err != nil {
k.T.Logf("Error %s running command %s. Return code: %s", stdout, args, err)
return &commonutil.RetriableError{Err: fmt.Errorf("Error running command. Error %s. Output: %s", err, stdout)}
k.T.Logf("Error %s running command %s. Return code: %v", stdout, args, err)
return &commonutil.RetriableError{Err: fmt.Errorf("Error running command: %v. Output: %s", err, stdout)}
}
return nil
}
@ -196,7 +196,7 @@ func (k *KubectlRunner) CreateRandomNamespace() string {
const strLen = 20
name := genRandString(strLen)
if _, err := k.RunCommand([]string{"create", "namespace", name}); err != nil {
k.T.Fatalf("Error creating namespace: %s", err)
k.T.Fatalf("Error creating namespace: %v", err)
}
return name
}
@ -300,7 +300,7 @@ func Retry(t *testing.T, callback func() error, d time.Duration, attempts int) (
if err == nil {
return nil
}
t.Logf("Error: %s, Retrying in %s. %d Retries remaining.", err, d, attempts-i)
t.Logf("Error: %v, Retrying in %s. %d Retries remaining.", err, d, attempts-i)
time.Sleep(d)
}
return err