From 03540c247ea7beb0b72477a7d0de4598f756c2ef Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 4 May 2020 14:15:50 -0700 Subject: [PATCH 1/4] add docker logs to postmortem --- test/integration/helpers.go | 14 ++++++++++++-- test/integration/pause_test.go | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index bd1fe19525..ebc1890ac1 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -195,13 +195,23 @@ func CleanupWithLogs(t *testing.T, profile string, cancel context.CancelFunc) { // clusterLogs shows logs for debugging a failed cluster func clusterLogs(t *testing.T, profile string) { + t.Logf("-----------------------post-mortem--------------------------------") + + if DockerDriver() { + t.Logf("======> post-mortem[%s]: docker logs <======", t.Name()) + rr, err := Run(t, exec.Command("docker", "logs", profile)) + if err != nil { + t.Logf("failed to get docker logs : %v", err) + return + } + t.Logf("(dbg) %s:\n%s", rr.Command(), rr.Output()) + + } st := Status(context.Background(), t, Target(), profile, "Host") if st != state.Running.String() { t.Logf("%q host is not running, skipping log retrieval (state=%q)", profile, st) return } - - t.Logf("-----------------------post-mortem--------------------------------") t.Logf("<<< %s FAILED: start of post-mortem logs <<<", t.Name()) t.Logf("======> post-mortem[%s]: minikube logs <======", t.Name()) diff --git a/test/integration/pause_test.go b/test/integration/pause_test.go index 91ab1a7ca3..ba8a28109b 100644 --- a/test/integration/pause_test.go +++ b/test/integration/pause_test.go @@ -70,11 +70,14 @@ func validateStartNoReset(ctx context.Context, t *testing.T, profile string) { args := []string{"start", "-p", profile, "--alsologtostderr", "-v=5"} rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) if err != nil { + clusterLogs(t, profile) t.Fatalf("failed to second start a running minikube with args: %q : %v", rr.Command(), err) + } if !NoneDriver() { softLog := "The running cluster does not need a reset" if !strings.Contains(rr.Output(), softLog) { + clusterLogs(t, profile) t.Errorf("expected the second start log outputs to include %q but got: %s", softLog, rr.Output()) } } From d776a22851e516a8a44284835b3d32ed4449029f Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 4 May 2020 14:18:13 -0700 Subject: [PATCH 2/4] add --details --- test/integration/helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index ebc1890ac1..c614fab52e 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -199,7 +199,7 @@ func clusterLogs(t *testing.T, profile string) { if DockerDriver() { t.Logf("======> post-mortem[%s]: docker logs <======", t.Name()) - rr, err := Run(t, exec.Command("docker", "logs", profile)) + rr, err := Run(t, exec.Command("docker", "logs", "--details", profile)) if err != nil { t.Logf("failed to get docker logs : %v", err) return From d2a9180edca52ecb0ca63e918faa433fe6d1a1aa Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 4 May 2020 14:19:43 -0700 Subject: [PATCH 3/4] dont return --- test/integration/helpers.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/integration/helpers.go b/test/integration/helpers.go index c614fab52e..e2e94be44d 100644 --- a/test/integration/helpers.go +++ b/test/integration/helpers.go @@ -202,10 +202,9 @@ func clusterLogs(t *testing.T, profile string) { rr, err := Run(t, exec.Command("docker", "logs", "--details", profile)) if err != nil { t.Logf("failed to get docker logs : %v", err) - return + } else { + t.Logf("(dbg) %s:\n%s", rr.Command(), rr.Output()) } - t.Logf("(dbg) %s:\n%s", rr.Command(), rr.Output()) - } st := Status(context.Background(), t, Target(), profile, "Host") if st != state.Running.String() { From 4fcd30dd433342b98e14ef645564833a6d14381a Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 4 May 2020 14:23:42 -0700 Subject: [PATCH 4/4] add defer --- test/integration/pause_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/integration/pause_test.go b/test/integration/pause_test.go index ba8a28109b..e0d98a0f6f 100644 --- a/test/integration/pause_test.go +++ b/test/integration/pause_test.go @@ -70,14 +70,13 @@ func validateStartNoReset(ctx context.Context, t *testing.T, profile string) { args := []string{"start", "-p", profile, "--alsologtostderr", "-v=5"} rr, err := Run(t, exec.CommandContext(ctx, Target(), args...)) if err != nil { - clusterLogs(t, profile) + defer clusterLogs(t, profile) t.Fatalf("failed to second start a running minikube with args: %q : %v", rr.Command(), err) - } if !NoneDriver() { softLog := "The running cluster does not need a reset" if !strings.Contains(rr.Output(), softLog) { - clusterLogs(t, profile) + defer clusterLogs(t, profile) t.Errorf("expected the second start log outputs to include %q but got: %s", softLog, rr.Output()) } }