lixmgl commented on code in PR #581:
URL: https://github.com/apache/yunikorn-core/pull/581#discussion_r1266227706
##########
pkg/scheduler/objects/application_state_test.go:
##########
@@ -19,15 +19,22 @@
package objects
import (
+ "fmt"
"testing"
"time"
"gotest.tools/v3/assert"
"github.com/apache/yunikorn-core/pkg/common"
+ "github.com/apache/yunikorn-core/pkg/events"
+ "github.com/apache/yunikorn-scheduler-interface/lib/go/si"
)
func TestAcceptStateTransition(t *testing.T) {
+ events.CreateAndSetEventSystem()
Review Comment:
Done. Thanks.
##########
pkg/scheduler/objects/application_test.go:
##########
@@ -269,26 +269,19 @@ func TestAppAllocReservation(t *testing.T) {
// wait for events to be processed
err = common.WaitFor(10*time.Millisecond, time.Second, func() bool {
fmt.Printf("checking event length: %d\n",
eventSystem.Store.CountStoredEvents())
- return eventSystem.Store.CountStoredEvents() == 2
+ return eventSystem.Store.CountStoredEvents() == 5
})
assert.NilError(t, err, "the event should have been processed")
records := eventSystem.Store.CollectEvents()
if records == nil {
t.Fatal("collecting eventChannel should return something")
}
- assert.Equal(t, 2, len(records), "expecting 2 events: 1 new alloc ask
and 1 alloc ask cancel")
- allocAskRecord := records[0]
- assert.Equal(t, si.EventRecord_APP, allocAskRecord.Type, "incorrect
event type, expect app")
- assert.Equal(t, ask.applicationID, allocAskRecord.ObjectID, "incorrect
object ID, expected application ID")
- assert.Equal(t, ask.allocationKey, allocAskRecord.ReferenceID,
"incorrect reference ID, expected alloc ask ID")
- assert.Equal(t, si.EventRecord_ADD, allocAskRecord.EventChangeType,
"incorrect change type, expected add")
- assert.Equal(t, si.EventRecord_APP_REQUEST,
allocAskRecord.EventChangeDetail, "incorrect change detail, expected new alloc
ask")
- allocAskCancelRecord := records[1]
- assert.Equal(t, si.EventRecord_APP, allocAskCancelRecord.Type,
"incorrect event type, expect app")
- assert.Equal(t, ask.applicationID, allocAskCancelRecord.ObjectID,
"incorrect object ID, expected application ID")
- assert.Equal(t, ask.allocationKey, allocAskCancelRecord.ReferenceID,
"incorrect reference ID, expected alloc ask ID")
- assert.Equal(t, si.EventRecord_REMOVE,
allocAskCancelRecord.EventChangeType, "incorrect change type, expected remove")
- assert.Equal(t, si.EventRecord_REQUEST_CANCEL,
allocAskCancelRecord.EventChangeDetail, "incorrect change detail, expected new
alloc ask")
+ assert.Equal(t, 5, len(records), "expecting 5 events")
+ isNewApplicationEvent(t, app, records[0])
+ isStateChangeEvent(t, app, si.EventRecord_APP_ACCEPTED, records[1])
+ isNewAllocAskEvent(t, ask, records[2])
+ isAllocCancelEvent(t, ask, records[3])
+ isStateChangeEvent(t, app, si.EventRecord_APP_COMPLETING, records[4])
Review Comment:
Done.
--
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]