diff --git a/cf_cli_java_plugin.go b/cf_cli_java_plugin.go index 22ebb31..62cbbaf 100644 --- a/cf_cli_java_plugin.go +++ b/cf_cli_java_plugin.go @@ -29,7 +29,7 @@ import ( var _ plugin.Plugin = (*JavaPlugin)(nil) // The JavaPlugin is a cf cli plugin that supports taking heap and thread dumps on demand -type JavaPlugin struct{ +type JavaPlugin struct { verbose bool } @@ -732,7 +732,7 @@ func (c *JavaPlugin) execute(commandExecutor cmd.CommandExecutor, uuidGenerator return "", fmt.Errorf("Command execution failed: %w\nOutput: %s", err, strings.Join(output, "\n")) } - if command.GenerateFiles && !noDownload { + if command.GenerateFiles { logVerbose("Processing file generation and download") finalFile := "" @@ -751,12 +751,17 @@ func (c *JavaPlugin) execute(commandExecutor cmd.CommandExecutor, uuidGenerator fileName = finalFile logVerbose("Found file: %s", finalFile) fmt.Println("Successfully created " + command.FileLabel + " in application container at: " + fileName) - } else { + } else if !noDownload { logVerbose("Failed to find file, error: %v", err) fmt.Println("Failed to find " + command.FileLabel + " in application container") return "", err } + if noDownload { + fmt.Println("No download requested, skipping file download") + return strings.Join(output, "\n"), nil + } + localFileFullPath := localDir + "/" + applicationName + "-" + command.FileNamePart + "-" + uuidGenerator.Generate() + command.FileExtension logVerbose("Downloading file to: %s", localFileFullPath) err = utils.CopyOverCat(cfSSHArguments, fileName, localFileFullPath) diff --git a/test/README.md b/test/README.md index 79560d1..cb749d3 100644 --- a/test/README.md +++ b/test/README.md @@ -25,6 +25,17 @@ A modern, efficient testing framework for the CF Java Plugin using Python and py ./test.py --start-with TestClass::test_method all # Start with a specific test (inclusive) ``` +## Possible Problems + +The following error might occur when connected to the SAP internal network: + +```sh + ssh: handshake failed: read tcp 10.16.73.196:64531->18.157.52.48:2222: read: connection reset by peer +``` + +Just connect directly to the internet without the VPN. + + ## State of Testing - `heap-dump` is thoroughly tested, including all flags, so that less has to be tested for the other commands. diff --git a/test/test_basic_commands.py b/test/test_basic_commands.py index c07e607..187192c 100644 --- a/test/test_basic_commands.py +++ b/test/test_basic_commands.py @@ -43,7 +43,7 @@ def test_no_download(self, t, app): """Test heap dump without downloading - file stays remote.""" t.run(f"heap-dump {app} --no-download").should_succeed().should_create_no_files().should_create_remote_file( "*.hprof" - ) + ).should_contain("Successfully created heap dump").should_contain("No download requested") @test(no_restart=True) def test_custom_container_dir(self, t, app):