Skip to content

Commit aaf9883

Browse files
authored
Merge pull request kubernetes#95055 from vinaykul/e2e-tests
Add LookForStringInPodExecToContainer(...) that takes container name as argument.
2 parents b9d2df8 + 334cde5 commit aaf9883

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

test/e2e/framework/util.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,21 @@ func RandomSuffix() string {
503503
}
504504

505505
// LookForStringInPodExec looks for the given string in the output of a command
506-
// executed in a specific pod container.
506+
// executed in the first container of specified pod.
507507
// TODO(alejandrox1): move to pod/ subpkg once kubectl methods are refactored.
508508
func LookForStringInPodExec(ns, podName string, command []string, expectedString string, timeout time.Duration) (result string, err error) {
509+
return LookForStringInPodExecToContainer(ns, podName, "", command, expectedString, timeout)
510+
}
511+
512+
// LookForStringInPodExecToContainer looks for the given string in the output of a
513+
// command executed in specified pod container, or first container if not specified.
514+
func LookForStringInPodExecToContainer(ns, podName, containerName string, command []string, expectedString string, timeout time.Duration) (result string, err error) {
509515
return lookForString(expectedString, timeout, func() string {
510-
// use the first container
511-
args := []string{"exec", podName, fmt.Sprintf("--namespace=%v", ns), "--"}
516+
args := []string{"exec", podName, fmt.Sprintf("--namespace=%v", ns)}
517+
if len(containerName) > 0 {
518+
args = append(args, fmt.Sprintf("--container=%s", containerName))
519+
}
520+
args = append(args, "--")
512521
args = append(args, command...)
513522
return RunKubectlOrDie(ns, args...)
514523
})

0 commit comments

Comments
 (0)