test/e2e/framework/util.go:make function LookForString private

This commit is contained in:
tanjunchen 2020-02-13 20:29:27 +08:00
parent 8ca96f3e07
commit 15bc88785a

View File

@ -607,7 +607,7 @@ func AssertCleanup(ns string, selectors ...string) {
// executed in a specific pod container.
// 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) {
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 = append(args, command...)
@ -615,11 +615,11 @@ func LookForStringInPodExec(ns, podName string, command []string, expectedString
})
}
// LookForString looks for the given string in the output of fn, repeatedly calling fn until
// lookForString looks for the given string in the output of fn, repeatedly calling fn until
// the timeout is reached or the string is found. Returns last log and possibly
// error if the string was not found.
// TODO(alejandrox1): move to pod/ subpkg once kubectl methods are refactored.
func LookForString(expectedString string, timeout time.Duration, fn func() string) (result string, err error) {
func lookForString(expectedString string, timeout time.Duration, fn func() string) (result string, err error) {
for t := time.Now(); time.Since(t) < timeout; time.Sleep(Poll) {
result = fn()
if strings.Contains(result, expectedString) {
@ -1570,7 +1570,7 @@ func OpenWebSocketForURL(url *url.URL, config *restclient.Config, protocols []st
// LookForStringInLog looks for the given string in the log of a specific pod container
func LookForStringInLog(ns, podName, container, expectedString string, timeout time.Duration) (result string, err error) {
return LookForString(expectedString, timeout, func() string {
return lookForString(expectedString, timeout, func() string {
return RunKubectlOrDie(ns, "logs", podName, container, fmt.Sprintf("--namespace=%v", ns))
})
}