yangwwei 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_r375995119
##########
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:
This is no longer needed. Earlier I need to access each of the events to
verify something. But that is now removed. I just changed to use a simple loop.
Thanks.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]