@@ -67,41 +67,41 @@ const (
67
67
)
68
68
69
69
// PodExec runs f.ExecCommandInContainerWithFullOutput to execute a shell cmd in target pod
70
- func PodExec (f * framework.Framework , pod * v1.Pod , shExec string ) (string , error ) {
71
- stdout , _ , err := f .ExecCommandInContainerWithFullOutput (pod .Name , pod .Spec .Containers [0 ].Name , "/bin/sh" , "-c" , shExec )
72
- return stdout , err
70
+ func PodExec (f * framework.Framework , pod * v1.Pod , shExec string ) (string , string , error ) {
71
+ stdout , stderr , err := f .ExecCommandInContainerWithFullOutput (pod .Name , pod .Spec .Containers [0 ].Name , "/bin/sh" , "-c" , shExec )
72
+ return stdout , stderr , err
73
73
}
74
74
75
75
// VerifyExecInPodSucceed verifies shell cmd in target pod succeed
76
76
func VerifyExecInPodSucceed (f * framework.Framework , pod * v1.Pod , shExec string ) {
77
- _ , err := PodExec (f , pod , shExec )
77
+ stdout , stderr , err := PodExec (f , pod , shExec )
78
78
if err != nil {
79
79
if exiterr , ok := err .(uexec.CodeExitError ); ok {
80
80
exitCode := exiterr .ExitStatus ()
81
81
framework .ExpectNoError (err ,
82
- "%q should succeed, but failed with exit code %d and error message %q" ,
83
- shExec , exitCode , exiterr )
82
+ "%q should succeed, but failed with exit code %d and error message %q\n stdout: %s \n stderr: %s " ,
83
+ shExec , exitCode , exiterr , stdout , stderr )
84
84
} else {
85
85
framework .ExpectNoError (err ,
86
- "%q should succeed, but failed with error message %q" ,
87
- shExec , err )
86
+ "%q should succeed, but failed with error message %q\n stdout: %s \n stderr: %s " ,
87
+ shExec , err , stdout , stderr )
88
88
}
89
89
}
90
90
}
91
91
92
92
// VerifyExecInPodFail verifies shell cmd in target pod fail with certain exit code
93
93
func VerifyExecInPodFail (f * framework.Framework , pod * v1.Pod , shExec string , exitCode int ) {
94
- _ , err := PodExec (f , pod , shExec )
94
+ stdout , stderr , err := PodExec (f , pod , shExec )
95
95
if err != nil {
96
96
if exiterr , ok := err .(clientexec.ExitError ); ok {
97
97
actualExitCode := exiterr .ExitStatus ()
98
98
framework .ExpectEqual (actualExitCode , exitCode ,
99
- "%q should fail with exit code %d, but failed with exit code %d and error message %q" ,
100
- shExec , exitCode , actualExitCode , exiterr )
99
+ "%q should fail with exit code %d, but failed with exit code %d and error message %q\n stdout: %s \n stderr: %s " ,
100
+ shExec , exitCode , actualExitCode , exiterr , stdout , stderr )
101
101
} else {
102
102
framework .ExpectNoError (err ,
103
- "%q should fail with exit code %d, but failed with error message %q" ,
104
- shExec , exitCode , err )
103
+ "%q should fail with exit code %d, but failed with error message %q\n stdout: %s \n stderr: %s " ,
104
+ shExec , exitCode , err , stdout , stderr )
105
105
}
106
106
}
107
107
framework .ExpectError (err , "%q should fail with exit code %d, but exit without error" , shExec , exitCode )
0 commit comments