Skip to content

Commit

Permalink
Respond to review
Browse files Browse the repository at this point in the history
Add godoc comment to DumpAllDescribeAll function.

use t.cleanup instead of defer.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
  • Loading branch information
astoycos committed Apr 24, 2023
1 parent 9f9923f commit 563dc36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions pkg/clusters/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
"strings"
)

// DumpAllDescribeAll gathers diagnostic information from the cluster. Specifically
// it runs "kubectl get all" and "kubectl describe all" for all resources and stores
// the output into two respective yaml files (kubectl_get_all.yaml and
// kubectl_describe_all.yaml).
func DumpAllDescribeAll(ctx context.Context, c Cluster, output string) error {
// Obtain a kubeconfig
kubeconfig, err := TempKubeconfig(c)
Expand Down
10 changes: 5 additions & 5 deletions test/integration/kind_diagnostics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ func TestKindDiagnosticDump(t *testing.T) {
require.NoError(t, err)

t.Logf("setting up the environment cleanup for environment %s and cluster %s", env.Name(), env.Cluster().Name())
defer func() {
t.Cleanup(func() {
t.Logf("cleaning up environment %s and cluster %s", env.Name(), env.Cluster().Name())
require.NoError(t, env.Cleanup(ctx))
}()
})

t.Log("waiting for the test environment to be ready for use")
require.NoError(t, <-env.WaitForReady(ctx))
Expand All @@ -41,14 +41,14 @@ func TestKindDiagnosticDump(t *testing.T) {

cluster := env.Cluster()

t.Log("verifying that DumpDiagnostics Functions as expected")
output, err := cluster.DumpDiagnostics(ctx, t.Name())
t.Log("verifying that DumpDiagnostics functions as expected")
output, err := cluster.DumpDiagnostics(ctx, t.Name())
require.NoError(t, err)
defer func() {
require.NoError(t, os.RemoveAll(output))
}()

logsPath, _ := filepath.Glob(filepath.Join(output, fmt.Sprintf("%s-control-plane",cluster.Name()), "containers", "kindnet-*"))
logsPath, _ := filepath.Glob(filepath.Join(output, fmt.Sprintf("%s-control-plane", cluster.Name()), "containers", "kindnet-*"))
require.NotZero(t, len(logsPath))
logs, err := os.ReadFile(logsPath[0])
require.NoError(t, err)
Expand Down

0 comments on commit 563dc36

Please sign in to comment.