wilfred-s commented on code in PR #1034:
URL: https://github.com/apache/yunikorn-k8shim/pull/1034#discussion_r3354074177


##########
pkg/dispatcher/dispatch_test.go:
##########
@@ -302,6 +306,23 @@ func TestExceedAsyncDispatchLimit(t *testing.T) {
 }
 
 func createDispatcher() {
+       if dispatcher != nil {
+               d := dispatcher
+               if d.isRunning() {
+                       Stop()
+               }
+               if d.asyncDispatchCount.Load() > 0 {
+                       waitTimeout := d.dispatchTimeout + 
d.asyncDispatchCheckInterval + time.Second
+                       if waitTimeout > maxTestAsyncDispatchDrain {
+                               waitTimeout = maxTestAsyncDispatchDrain
+                       }
+                       if err := utils.WaitForCondition(func() bool {
+                               return d.asyncDispatchCount.Load() == 0
+                       }, testAsyncDispatchPollPeriod, waitTimeout); err != 
nil {
+                               fmt.Printf("warning: async dispatch did not 
drain before re-init: %v\n", err)

Review Comment:
   This is an automatic drain of left over events before creating a new 
dispatcher. The drain works and repeated tests do not fail anymore when adding 
this code.



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