From b3c9eea3d8042a1f6b7a2eab8099b726ce4d97d9 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 21 Aug 2019 09:58:22 -0700 Subject: [PATCH] improve logging, fix expected filename for downloadonly --- test/integration/a_download_only_test.go | 14 +++++++++----- test/integration/util/minikube_runner.go | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/integration/a_download_only_test.go b/test/integration/a_download_only_test.go index 2f5679cb78..b21b14148b 100644 --- a/test/integration/a_download_only_test.go +++ b/test/integration/a_download_only_test.go @@ -24,6 +24,7 @@ import ( "os" "path/filepath" "runtime" + "strings" "testing" "time" @@ -48,20 +49,23 @@ func TestDownloadOnly(t *testing.T) { minHome := constants.GetMinipath() for _, v := range []string{constants.OldestKubernetesVersion, constants.NewestKubernetesVersion} { mk.StartWithFail("--download-only", fmt.Sprintf("--kubernetes-version=%s", v)) - // checking if cached images are downloaded to + // checking if cached images are downloaded for example (kube-apiserver_v1.15.2, kube-scheduler_v1.15.2, ...) _, imgs := constants.GetKubeadmCachedImages("", v) for _, img := range imgs { - _, err := os.Stat(filepath.Join(minHome, fmt.Sprintf("images/%s", img))) + img = strings.Replace(img, ":", "_", 1) // for example kube-scheduler:v1.15.2 --> kube-scheduler_v1.15.2 + fp := filepath.Join(minHome, "cache", "images", img) + _, err := os.Stat(fp) if err != nil { - t.Errorf("error expected download-only to cachne image %q but got error %v", img, err) + t.Errorf("expected image file exist at %q but got error: %v", fp, err) } } // checking binaries downloaded (kubelet,kubeadm) for _, bin := range constants.GetKubeadmCachedBinaries() { - _, err := os.Stat(filepath.Join(minHome, fmt.Sprintf("cache/%s/%s", v, bin))) + fp := filepath.Join(minHome, "cache", v, bin) + _, err := os.Stat(fp) if err != nil { - t.Errorf("error expected download-only to cachne binary %q but got error %v", bin, err) + t.Errorf("expected the file for binary exist at %q but got error %v", fp, err) } } } diff --git a/test/integration/util/minikube_runner.go b/test/integration/util/minikube_runner.go index c8fd71c85f..a8fb81d683 100644 --- a/test/integration/util/minikube_runner.go +++ b/test/integration/util/minikube_runner.go @@ -239,8 +239,9 @@ func (m *MinikubeRunner) start(opts ...string) (stdout string, stderr string, er // StartWithFail starts the cluster and fail the test if error func (m *MinikubeRunner) StartWithFail(opts ...string) (stdout string, stderr string) { stdout, stderr, err := m.start(opts...) + // the reason for this formatting is, the logs are very big but useful and also in parallel testing logs are harder to identify if err != nil { - m.T.Fatalf("%s Failed to start minikube (for profile %s) error: %v \n\twith opts %v, \n\t Global Args: %s \n\t Driver Args: %s \n\t STDOUT: \n\t\t %s \n\t STDERR: \n\t\t %s", m.T.Name(), m.Profile, err, strings.Join(opts, " "), m.GlobalArgs, m.StartArgs, stdout, stderr) + m.T.Fatalf("%s Failed to start minikube With error: %v \n\t Start log block ---> \n\t With Profile: %s \n\t With Args: %v \n\t With Global Args: %s \n\t With Driver Args: %s \n\t With STDOUT: \n \t %s \n\t With STDERR: \n \t %s \n\t <--- End of log block", m.T.Name(), err, m.Profile, strings.Join(opts, " "), m.GlobalArgs, m.StartArgs, stdout, stderr) } return stdout, stderr }