Skip to content

Commit ba5a81b

Browse files
authored
chore(e2e): make sure we log stderr output from the API (#2164)
* chore(e2e): make sure we log stderr output from the API * chore: format * chore: remove auxiliary function * chore: add back comments * chore: add back comments
1 parent 2e9f269 commit ba5a81b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

e2e/cluster/cmx/cluster.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ func NewNetwork(in *ClusterInput) (*Network, error) {
9191

9292
output, err := exec.Command("replicated", "network", "create", "--name", name, "--wait", "5m", "-ojson").Output() // stderr can break json parsing
9393
if err != nil {
94-
return nil, fmt.Errorf("create network %s: %v: %s", name, err, string(output))
94+
if exitErr, ok := err.(*exec.ExitError); ok {
95+
return nil, fmt.Errorf("create network %s: %w: stderr: %s: stdout: %s", name, err, string(exitErr.Stderr), string(output))
96+
}
97+
return nil, fmt.Errorf("create network %s: %w: stdout: %s", name, err, string(output))
9598
}
9699

97100
var networks []Network
@@ -135,7 +138,10 @@ func NewNode(in *ClusterInput, index int, networkID string) (*Node, error) {
135138

136139
output, err := exec.Command("replicated", args...).Output() // stderr can break json parsing
137140
if err != nil {
138-
return nil, fmt.Errorf("create node %s: %v: %s", nodeName, err, string(output))
141+
if exitErr, ok := err.(*exec.ExitError); ok {
142+
return nil, fmt.Errorf("create node %s: %w: stderr: %s: stdout: %s", nodeName, err, string(exitErr.Stderr), string(output))
143+
}
144+
return nil, fmt.Errorf("create node %s: %w: stdout: %s", nodeName, err, string(output))
139145
}
140146

141147
var nodes []Node
@@ -459,7 +465,10 @@ func exposePort(node Node, port string) (string, error) {
459465

460466
output, err = exec.Command("replicated", "vm", "port", "ls", node.ID, "-ojson").Output() // stderr can break json parsing
461467
if err != nil {
462-
return "", fmt.Errorf("get port info: %v: %s", err, string(output))
468+
if exitErr, ok := err.(*exec.ExitError); ok {
469+
return "", fmt.Errorf("get port info: %w: stderr: %s: stdout: %s", err, string(exitErr.Stderr), string(output))
470+
}
471+
return "", fmt.Errorf("get port info: %w: stdout: %s", err, string(output))
463472
}
464473

465474
var ports []struct {

0 commit comments

Comments
 (0)