0yukali0 commented on a change in pull request #320:
URL: 
https://github.com/apache/incubator-yunikorn-core/pull/320#discussion_r706324727



##########
File path: pkg/scheduler/objects/allocation_ask_test.go
##########
@@ -155,3 +155,39 @@ func TestGetRequiredNode(t *testing.T) {
        ask = NewAllocationAsk(siAsk)
        assert.Equal(t, ask.GetRequiredNode(), "NodeName", "required node 
should be NodeName")
 }
+
+func TestSetPriority(t *testing.T) {
+       var tests = []struct {
+               testMessage string
+               in          int32
+               out         int32
+       }{
+               {"no priority setting", -1, 0},
+               {"set default priority value", 0, 0},
+               {"set priority", 2, 2},
+       }
+
+       for _, tt := range tests {
+               res := 
resources.NewResourceFromMap(map[string]resources.Quantity{"first": 10})
+               siAsk := &si.AllocationAsk{
+                       AllocationKey:  "ask-1",
+                       ApplicationID:  "app-1",
+                       MaxAllocations: 1,
+                       ResourceAsk:    res.ToProto(),
+               }
+               t.Run(tt.testMessage, func(t *testing.T) {
+                       ask := NewAllocationAsk(siAsk)
+                       if tt.in >= 0 {
+                               priority := 
si.Priority_PriorityValue{PriorityValue: tt.in}
+                               siAsk.Priority = &si.Priority{
+                                       Priority: &priority,
+                               }
+                               
ask.setPriority(siAsk.Priority.GetPriorityValue())

Review comment:
       I add two situation in this commit.
   1.Set priority via "NewAllocationAsk" function
   2.Priority initialized by "NewAllocationAsk"  is  assigned new value by 
SetPriority.




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