...

Source file src/github.com/redhat-developer/odo/tests/helper/helper_component.go

Documentation: github.com/redhat-developer/odo/tests/helper

     1  package helper
     2  
     3  import (
     4  	"time"
     5  
     6  	. "github.com/onsi/ginkgo/v2"
     7  	. "github.com/onsi/gomega"
     8  	"github.com/onsi/gomega/types"
     9  )
    10  
    11  // WaitAppReadyInContainer probes the remote container using the specified command (cmd).
    12  // It waits until the specified timeout is reached or until the provided matchers match the remote command output.
    13  // At least one of the matchers must be provided.
    14  func WaitAppReadyInContainer(
    15  	cmp Component,
    16  	container string,
    17  	cmd []string,
    18  	pollingInterval time.Duration,
    19  	timeout time.Duration,
    20  	stdoutMatcher types.GomegaMatcher,
    21  	stderrMatcher types.GomegaMatcher,
    22  ) {
    23  	if stdoutMatcher == nil && stderrMatcher == nil {
    24  		Fail("Please specify either stdoutMatcher or stderrMatcher!")
    25  	}
    26  	Eventually(func(g Gomega) {
    27  		stdout, stderr := cmp.Exec(container, cmd, nil)
    28  		if stdoutMatcher != nil {
    29  			g.Expect(stdout).Should(stdoutMatcher)
    30  		}
    31  		if stderrMatcher != nil {
    32  			g.Expect(stderr).Should(stderrMatcher)
    33  		}
    34  	}).WithPolling(pollingInterval).WithTimeout(timeout).Should(Succeed())
    35  }
    36  

View as plain text