chenyulin0719 commented on code in PR #879:
URL: https://github.com/apache/yunikorn-k8shim/pull/879#discussion_r1683206605


##########
pkg/common/utils/utils_test.go:
##########
@@ -1140,3 +1211,30 @@ func TestConvert2PriorityClass(t *testing.T) {
        assert.Assert(t, result != nil)
        assert.Equal(t, result.PreemptionPolicy, &preemptLower)
 }
+
+func TestWaitForCondition(t *testing.T) {
+       target := false
+       eval := func() bool {
+               return target
+       }
+       tests := []struct {
+               input    bool
+               interval time.Duration
+               timeout  time.Duration
+               output   error
+       }{
+               {true, time.Duration(1) * time.Second, time.Duration(2) * 
time.Second, nil},
+               {false, time.Duration(1) * time.Second, time.Duration(2) * 
time.Second, ErrorTimeout},
+               {true, time.Duration(3) * time.Second, time.Duration(2) * 
time.Second, nil},
+               {false, time.Duration(3) * time.Second, time.Duration(2) * 
time.Second, ErrorTimeout},
+       }
+       for _, test := range tests {
+               target = test.input
+               get := WaitForCondition(eval, test.timeout, test.interval)
+               if test.output == nil {
+                       assert.NilError(t, get)
+               } else {
+                       assert.Equal(t, get.Error(), test.output.Error())
+               }
+       }
+}

Review Comment:
   The TestWaitForCondition() takes 5~6 secs (the second and forth test cases) 
, I guess it's acceptable. But  I'm also thinking about whether we could use a 
smaller `interval` and `timout`, like 100 Millisecond and 200 Millisecond?
   
   The only concern is I'm not sure whehter our CI env's goroutine could got 
CPU in time.
   @chia7712 WDYT?
   



-- 
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