mirror of https://github.com/docker/compose.git
Merge pull request #1038 from gtardif/fix_metrics_flaky_test
Trying to fix flakyness on metrics e2e tests
This commit is contained in:
commit
8faa501dd8
|
@ -151,7 +151,7 @@ func TestContextMetrics(t *testing.T) {
|
|||
c.RunDockerCmd("--help")
|
||||
c.RunDockerCmd("run", "--help")
|
||||
|
||||
usage := s.GetUsage()
|
||||
usage := s.GetUsage(3)
|
||||
assert.DeepEqual(t, []string{
|
||||
`{"command":"help run","context":"moby","source":"cli","status":"success"}`,
|
||||
`{"command":"--help","context":"moby","source":"cli","status":"success"}`,
|
||||
|
@ -166,7 +166,7 @@ func TestContextMetrics(t *testing.T) {
|
|||
c.RunDockerCmd("version")
|
||||
c.RunDockerOrExitError("version", "--xxx")
|
||||
|
||||
usage := s.GetUsage()
|
||||
usage := s.GetUsage(3)
|
||||
assert.DeepEqual(t, []string{
|
||||
`{"command":"ps","context":"moby","source":"cli","status":"success"}`,
|
||||
`{"command":"version","context":"moby","source":"cli","status":"success"}`,
|
||||
|
@ -185,7 +185,7 @@ func TestContextMetrics(t *testing.T) {
|
|||
c.RunDockerCmd("context", "use", "default")
|
||||
c.RunDockerCmd("--context", "test-example", "ps")
|
||||
|
||||
usage := s.GetUsage()
|
||||
usage := s.GetUsage(7)
|
||||
assert.DeepEqual(t, []string{
|
||||
`{"command":"context create","context":"moby","source":"cli","status":"success"}`,
|
||||
`{"command":"ps","context":"moby","source":"cli","status":"success"}`,
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo"
|
||||
)
|
||||
|
@ -53,7 +54,10 @@ func (s *MockMetricsServer) hello(c echo.Context) error {
|
|||
}
|
||||
|
||||
// GetUsage get usage
|
||||
func (s *MockMetricsServer) GetUsage() []string {
|
||||
func (s *MockMetricsServer) GetUsage(expectedCommands int) []string {
|
||||
if len(s.usage) < expectedCommands {
|
||||
time.Sleep(1 * time.Second) // a simple sleep 1s here should be enough, if not there are real issues
|
||||
}
|
||||
return s.usage
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue