Forráskód Böngészése

removed wait that is not the root cause for metrics flakyness

Signed-off-by: Guillaume Tardif <[email protected]>
Guillaume Tardif 5 éve
szülő
commit
9138a3c76b
2 módosított fájl, 6 hozzáadás és 11 törlés
  1. 3 3
      tests/e2e/e2e_test.go
  2. 3 8
      tests/framework/mockmetrics.go

+ 3 - 3
tests/e2e/e2e_test.go

@@ -151,7 +151,7 @@ func TestContextMetrics(t *testing.T) {
 		c.RunDockerCmd("--help")
 		c.RunDockerCmd("run", "--help")
 
-		usage := s.GetUsage(3)
+		usage := s.GetUsage()
 		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(3)
+		usage := s.GetUsage()
 		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(7)
+		usage := s.GetUsage()
 		assert.DeepEqual(t, []string{
 			`{"command":"context create","context":"moby","source":"cli","status":"success"}`,
 			`{"command":"ps","context":"moby","source":"cli","status":"success"}`,

+ 3 - 8
tests/framework/mockmetrics.go

@@ -22,7 +22,6 @@ import (
 	"net"
 	"net/http"
 	"strings"
-	"time"
 
 	"github.com/labstack/echo"
 )
@@ -42,8 +41,7 @@ func NewMetricsServer(socket string) *MockMetricsServer {
 	}
 }
 
-// Handler
-func (s *MockMetricsServer) hello(c echo.Context) error {
+func (s *MockMetricsServer) handlePostUsage(c echo.Context) error {
 	body, error := ioutil.ReadAll(c.Request().Body)
 	if error != nil {
 		return error
@@ -54,10 +52,7 @@ func (s *MockMetricsServer) hello(c echo.Context) error {
 }
 
 // GetUsage get usage
-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
-	}
+func (s *MockMetricsServer) GetUsage() []string {
 	return s.usage
 }
 
@@ -79,7 +74,7 @@ func (s *MockMetricsServer) Start() {
 			log.Fatal(err)
 		}
 		s.e.Listener = listener
-		s.e.POST("/usage", s.hello)
+		s.e.POST("/usage", s.handlePostUsage)
 		_ = s.e.Start(":1323")
 	}()
 }