mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #95055 from vinaykul/e2e-tests
Add LookForStringInPodExecToContainer(...) that takes container name as argument.
This commit is contained in:
commit
aaf9883747
@ -503,12 +503,21 @@ func RandomSuffix() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LookForStringInPodExec looks for the given string in the output of a command
|
// LookForStringInPodExec looks for the given string in the output of a command
|
||||||
// executed in a specific pod container.
|
// executed in the first container of specified pod.
|
||||||
// TODO(alejandrox1): move to pod/ subpkg once kubectl methods are refactored.
|
// TODO(alejandrox1): move to pod/ subpkg once kubectl methods are refactored.
|
||||||
func LookForStringInPodExec(ns, podName string, command []string, expectedString string, timeout time.Duration) (result string, err error) {
|
func LookForStringInPodExec(ns, podName string, command []string, expectedString string, timeout time.Duration) (result string, err error) {
|
||||||
|
return LookForStringInPodExecToContainer(ns, podName, "", command, expectedString, timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LookForStringInPodExecToContainer looks for the given string in the output of a
|
||||||
|
// command executed in specified pod container, or first container if not specified.
|
||||||
|
func LookForStringInPodExecToContainer(ns, podName, containerName string, command []string, expectedString string, timeout time.Duration) (result string, err error) {
|
||||||
return lookForString(expectedString, timeout, func() string {
|
return lookForString(expectedString, timeout, func() string {
|
||||||
// use the first container
|
args := []string{"exec", podName, fmt.Sprintf("--namespace=%v", ns)}
|
||||||
args := []string{"exec", podName, fmt.Sprintf("--namespace=%v", ns), "--"}
|
if len(containerName) > 0 {
|
||||||
|
args = append(args, fmt.Sprintf("--container=%s", containerName))
|
||||||
|
}
|
||||||
|
args = append(args, "--")
|
||||||
args = append(args, command...)
|
args = append(args, command...)
|
||||||
return RunKubectlOrDie(ns, args...)
|
return RunKubectlOrDie(ns, args...)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user