You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by GitBox <gi...@apache.org> on 2021/09/07 22:48:30 UTC

[GitHub] [incubator-yunikorn-core] yangwwei commented on a change in pull request #320: [YUNIKORN-838] Improve coverage of allocation_ask.go

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



##########
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 guess it's better to do this in a different way because this is not how we usually assign the priority value.
   can we assign the value directly in `AllocationAsk`?
   
   ```
   siAsk := &si.AllocationAsk{
     AllocationKey:  "ask-1",
     ApplicationID:  "app-1",
     MaxAllocations: 1,
     Priority:   xxxx,
     ResourceAsk:    res.ToProto(),
   }
   ```




-- 
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: reviews-unsubscribe@yunikorn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org