yunikorn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-yunikorn-k8shim] wilfred-s commented on a change in pull request #74: Identify spark pod with label spark-app-selector
Date Thu, 06 Feb 2020 08:49:37 GMT
wilfred-s commented on a change in pull request #74: Identify spark pod with label spark-app-selector
URL: https://github.com/apache/incubator-yunikorn-k8shim/pull/74#discussion_r375704216
 
 

 ##########
 File path: pkg/dispatcher/dispatcher_test.go
 ##########
 @@ -201,31 +204,57 @@ func TestDispatchTimeout(t *testing.T) {
 	}()
 
 	// pretend to be an time-consuming event-handler
-	handledChan := make(chan bool)
 	RegisterEventHandler(EventTypeApp, func(obj interface{}) {
-		if _, ok := obj.(events.ApplicationEvent); ok {
-			time.Sleep(2 * time.Second)
-			handledChan <- true
+		if appEvent, ok := obj.(TestAppEvent); ok {
+			fmt.Println(fmt.Sprintf("handling %s", appEvent.appID))
+			<- appEvent.flag
+			fmt.Println(fmt.Sprintf("handling %s DONE", appEvent.appID))
 		}
 	})
 	// start the dispatcher
 	Start()
 	// dispatch 3 events, the third event will be dispatched asynchronously
-	for i := 0; i < 3; i++ {
-		Dispatch(TestAppEvent{
-			appID:     "test",
-			eventType: events.RunApplication,
-		})
+	event0 := TestAppEvent{
+		appID:     "test-00",
+		eventType: events.RunApplication,
+		flag:      make(chan bool),
 	}
-	assert.Equal(t, int32(1), atomic.LoadInt32(&asyncDispatchCount))
-	// sleep 200ms to verify that Dispatcher#asyncDispatch is called
-	time.Sleep(200 * time.Millisecond)
+	event1 := TestAppEvent{
+		appID:     "test-01",
+		eventType: events.RunApplication,
+		flag:      make(chan bool),
+	}
+	event2 := TestAppEvent{
+		appID:     "test-02",
+		eventType: events.RunApplication,
+		flag:      make(chan bool),
+	}
+
+	// dispatch all events
+	Dispatch(event0)
+	Dispatch(event1)
+	Dispatch(event2)
 
 Review comment:
   Why unwrap the for loop? A loop makes the code much more readable and easier to maintain.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: dev-help@yunikorn.apache.org


Mime
View raw message