mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
utils.go: Changed bashExec to shExec, bash not guaranteed.
This commit is contained in:
parent
2fac3f2c20
commit
373909946e
@ -64,44 +64,44 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// PodExec runs f.ExecCommandInContainerWithFullOutput to execute a shell cmd in target pod
|
// PodExec runs f.ExecCommandInContainerWithFullOutput to execute a shell cmd in target pod
|
||||||
func PodExec(f *framework.Framework, pod *v1.Pod, bashExec string) (string, error) {
|
func PodExec(f *framework.Framework, pod *v1.Pod, shExec string) (string, error) {
|
||||||
stdout, _, err := f.ExecCommandInContainerWithFullOutput(pod.Name, pod.Spec.Containers[0].Name, "/bin/sh", "-c", bashExec)
|
stdout, _, err := f.ExecCommandInContainerWithFullOutput(pod.Name, pod.Spec.Containers[0].Name, "/bin/sh", "-c", shExec)
|
||||||
return stdout, err
|
return stdout, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyExecInPodSucceed verifies bash cmd in target pod succeed
|
// VerifyExecInPodSucceed verifies shell cmd in target pod succeed
|
||||||
func VerifyExecInPodSucceed(f *framework.Framework, pod *v1.Pod, bashExec string) {
|
func VerifyExecInPodSucceed(f *framework.Framework, pod *v1.Pod, shExec string) {
|
||||||
_, err := PodExec(f, pod, bashExec)
|
_, err := PodExec(f, pod, shExec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err, ok := err.(uexec.CodeExitError); ok {
|
if err, ok := err.(uexec.CodeExitError); ok {
|
||||||
exitCode := err.ExitStatus()
|
exitCode := err.ExitStatus()
|
||||||
framework.ExpectNoError(err,
|
framework.ExpectNoError(err,
|
||||||
"%q should succeed, but failed with exit code %d and error message %q",
|
"%q should succeed, but failed with exit code %d and error message %q",
|
||||||
bashExec, exitCode, err)
|
shExec, exitCode, err)
|
||||||
} else {
|
} else {
|
||||||
framework.ExpectNoError(err,
|
framework.ExpectNoError(err,
|
||||||
"%q should succeed, but failed with error message %q",
|
"%q should succeed, but failed with error message %q",
|
||||||
bashExec, err)
|
shExec, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// VerifyExecInPodFail verifies bash cmd in target pod fail with certain exit code
|
// VerifyExecInPodFail verifies shell cmd in target pod fail with certain exit code
|
||||||
func VerifyExecInPodFail(f *framework.Framework, pod *v1.Pod, bashExec string, exitCode int) {
|
func VerifyExecInPodFail(f *framework.Framework, pod *v1.Pod, shExec string, exitCode int) {
|
||||||
_, err := PodExec(f, pod, bashExec)
|
_, err := PodExec(f, pod, shExec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err, ok := err.(clientexec.ExitError); ok {
|
if err, ok := err.(clientexec.ExitError); ok {
|
||||||
actualExitCode := err.ExitStatus()
|
actualExitCode := err.ExitStatus()
|
||||||
framework.ExpectEqual(actualExitCode, exitCode,
|
framework.ExpectEqual(actualExitCode, exitCode,
|
||||||
"%q should fail with exit code %d, but failed with exit code %d and error message %q",
|
"%q should fail with exit code %d, but failed with exit code %d and error message %q",
|
||||||
bashExec, exitCode, actualExitCode, err)
|
shExec, exitCode, actualExitCode, err)
|
||||||
} else {
|
} else {
|
||||||
framework.ExpectNoError(err,
|
framework.ExpectNoError(err,
|
||||||
"%q should fail with exit code %d, but failed with error message %q",
|
"%q should fail with exit code %d, but failed with error message %q",
|
||||||
bashExec, exitCode, err)
|
shExec, exitCode, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectError(err, "%q should fail with exit code %d, but exit without error", bashExec, exitCode)
|
framework.ExpectError(err, "%q should fail with exit code %d, but exit without error", shExec, exitCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isSudoPresent(nodeIP string, provider string) bool {
|
func isSudoPresent(nodeIP string, provider string) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user