mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
* Make 'helper.Component#Exec' accept an additional parameter that allows checking (or not) the remote command execution * In E2E tests, wait until the app is completely ready before sending requests to the local forwarded port Otherwise, sending a request too early causes "connection refused" errors, which causes port-forwarding to be restarted (with new local ports because "odo dev" is running with "--random-ports"). As a first start, here we are making sure that the application port is available in the container, prior to sending requests to the local forwarded port. This should reduce the likeliness of port-forwarding restarts. In the future, we might want to make the test detect the new local ports and use those instead. We could even make sure to make "odo dev" reuse the previous random ports it had, provided they are available again. * Increase timeout and polling interval when waiting for port-forward restart * Add a '/ping' endpoint to the sample Go app used in E2E This allows checking the application running in the container. * Do not stop the DevSession process before removing the Binding from the Devfile https://github.com/redhat-developer/odo/issues/6101 has been fixed. * fixup! Make 'helper.Component#Exec' accept an additional parameter that allows checking (or not) the remote command execution * fixup! In E2E tests, wait until the app is completely ready before sending requests to the local forwarded port * Create reusable 'helper.WaitAppReadyInContainer' helper function, as suggested in review Co-authored-by: Philippe Martin <phmartin@redhat.com> --------- Co-authored-by: Philippe Martin <phmartin@redhat.com>
36 lines
1014 B
Go
36 lines
1014 B
Go
package helper
|
|
|
|
import (
|
|
"time"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
"github.com/onsi/gomega/types"
|
|
)
|
|
|
|
// WaitAppReadyInContainer probes the remote container using the specified command (cmd).
|
|
// It waits until the specified timeout is reached or until the provided matchers match the remote command output.
|
|
// At least one of the matchers must be provided.
|
|
func WaitAppReadyInContainer(
|
|
cmp Component,
|
|
container string,
|
|
cmd []string,
|
|
pollingInterval time.Duration,
|
|
timeout time.Duration,
|
|
stdoutMatcher types.GomegaMatcher,
|
|
stderrMatcher types.GomegaMatcher,
|
|
) {
|
|
if stdoutMatcher == nil && stderrMatcher == nil {
|
|
Fail("Please specify either stdoutMatcher or stderrMatcher!")
|
|
}
|
|
Eventually(func(g Gomega) {
|
|
stdout, stderr := cmp.Exec(container, cmd, nil)
|
|
if stdoutMatcher != nil {
|
|
g.Expect(stdout).Should(stdoutMatcher)
|
|
}
|
|
if stderrMatcher != nil {
|
|
g.Expect(stderr).Should(stderrMatcher)
|
|
}
|
|
}).WithPolling(pollingInterval).WithTimeout(timeout).Should(Succeed())
|
|
}
|