pbacsko commented on code in PR #722:
URL: https://github.com/apache/yunikorn-core/pull/722#discussion_r1399836211


##########
pkg/scheduler/tests/mockscheduler_test.go:
##########
@@ -55,6 +60,25 @@ func (m *mockScheduler) Init(config string, autoSchedule 
bool, withWebapp bool)
 
        m.mockRM = newMockRMCallbackHandler()
 
+       if withWebapp {
+               ctx, cancel := context.WithTimeout(context.TODO(), 
10*time.Second)
+               defer cancel()
+               for {
+                       select {
+                       case <-ctx.Done():
+                               return fmt.Errorf("webapp can't be ready in 10 
seconds")

Review Comment:
   "webapp failed to start in 10 seconds"



##########
pkg/scheduler/tests/mockscheduler_test.go:
##########
@@ -55,6 +60,25 @@ func (m *mockScheduler) Init(config string, autoSchedule 
bool, withWebapp bool)
 
        m.mockRM = newMockRMCallbackHandler()
 
+       if withWebapp {
+               ctx, cancel := context.WithTimeout(context.TODO(), 
10*time.Second)
+               defer cancel()
+               for {
+                       select {
+                       case <-ctx.Done():
+                               return fmt.Errorf("webapp can't be ready in 10 
seconds")
+                       default:
+                       }
+
+                       conn, err := net.DialTimeout("tcp", 
net.JoinHostPort("127.0.0.1", "9080"), 1*time.Second)

Review Comment:
   Nit: `1*` multiplier can be removed.



##########
pkg/scheduler/tests/mockscheduler_test.go:
##########
@@ -55,6 +60,25 @@ func (m *mockScheduler) Init(config string, autoSchedule 
bool, withWebapp bool)
 
        m.mockRM = newMockRMCallbackHandler()
 
+       if withWebapp {
+               ctx, cancel := context.WithTimeout(context.TODO(), 
10*time.Second)

Review Comment:
   Nit: can be decreased to eg. 2 seconds. That's plenty.



##########
pkg/scheduler/tests/mockscheduler_test.go:
##########
@@ -55,6 +60,25 @@ func (m *mockScheduler) Init(config string, autoSchedule 
bool, withWebapp bool)
 
        m.mockRM = newMockRMCallbackHandler()
 
+       if withWebapp {
+               ctx, cancel := context.WithTimeout(context.TODO(), 
10*time.Second)
+               defer cancel()
+               for {
+                       select {
+                       case <-ctx.Done():
+                               return fmt.Errorf("webapp can't be ready in 10 
seconds")
+                       default:
+                       }
+
+                       conn, err := net.DialTimeout("tcp", 
net.JoinHostPort("127.0.0.1", "9080"), 1*time.Second)
+                       if err == nil {
+                               defer conn.Close()
+                               break
+                       }
+                       time.Sleep(500 * time.Millisecond)

Review Comment:
   We have `common.WaitFor()` or `WaitForCondition()` that makes this easier.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to