Skip to content

Commit ebf9adb

Browse files
committed
Fix -no-download output, fix #40
1 parent f792cf1 commit ebf9adb

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

cf_cli_java_plugin.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
var _ plugin.Plugin = (*JavaPlugin)(nil)
3030

3131
// The JavaPlugin is a cf cli plugin that supports taking heap and thread dumps on demand
32-
type JavaPlugin struct{
32+
type JavaPlugin struct {
3333
verbose bool
3434
}
3535

@@ -732,7 +732,7 @@ func (c *JavaPlugin) execute(commandExecutor cmd.CommandExecutor, uuidGenerator
732732
return "", fmt.Errorf("Command execution failed: %w\nOutput: %s", err, strings.Join(output, "\n"))
733733
}
734734

735-
if command.GenerateFiles && !noDownload {
735+
if command.GenerateFiles {
736736
logVerbose("Processing file generation and download")
737737

738738
finalFile := ""
@@ -751,12 +751,17 @@ func (c *JavaPlugin) execute(commandExecutor cmd.CommandExecutor, uuidGenerator
751751
fileName = finalFile
752752
logVerbose("Found file: %s", finalFile)
753753
fmt.Println("Successfully created " + command.FileLabel + " in application container at: " + fileName)
754-
} else {
754+
} else if !noDownload {
755755
logVerbose("Failed to find file, error: %v", err)
756756
fmt.Println("Failed to find " + command.FileLabel + " in application container")
757757
return "", err
758758
}
759759

760+
if noDownload {
761+
fmt.Println("No download requested, skipping file download")
762+
return strings.Join(output, "\n"), nil
763+
}
764+
760765
localFileFullPath := localDir + "/" + applicationName + "-" + command.FileNamePart + "-" + uuidGenerator.Generate() + command.FileExtension
761766
logVerbose("Downloading file to: %s", localFileFullPath)
762767
err = utils.CopyOverCat(cfSSHArguments, fileName, localFileFullPath)

test/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ A modern, efficient testing framework for the CF Java Plugin using Python and py
2525
./test.py --start-with TestClass::test_method all # Start with a specific test (inclusive)
2626
```
2727

28+
## Possible Problems
29+
30+
The following error might occur when connected to the SAP internal network:
31+
32+
```sh
33+
ssh: handshake failed: read tcp 10.16.73.196:64531->18.157.52.48:2222: read: connection reset by peer
34+
```
35+
36+
Just connect directly to the internet without the VPN.
37+
38+
2839
## State of Testing
2940

3041
- `heap-dump` is thoroughly tested, including all flags, so that less has to be tested for the other commands.

test/test_basic_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_no_download(self, t, app):
4343
"""Test heap dump without downloading - file stays remote."""
4444
t.run(f"heap-dump {app} --no-download").should_succeed().should_create_no_files().should_create_remote_file(
4545
"*.hprof"
46-
)
46+
).should_contain("Successfully created heap dump").should_contain("No download requested")
4747

4848
@test(no_restart=True)
4949
def test_custom_container_dir(self, t, app):

0 commit comments

Comments
 (0)