yangwwei commented on a change in pull request #203:
URL:
https://github.com/apache/incubator-yunikorn-k8shim/pull/203#discussion_r514616281
##########
File path: pkg/cache/application_test.go
##########
@@ -181,19 +190,192 @@ func TestGetNonTerminatedTaskAlias(t *testing.T) {
assert.Assert(t, is.Contains(res, "/test-00001"))
assert.Assert(t, is.Contains(res, "/test-00002"))
- //set two tasks to terminated states
+ // set two tasks to terminated states
task1.sm.SetState(events.States().Task.Rejected)
task2.sm.SetState(events.States().Task.Rejected)
// check the tasks both in terminated states
// res should retuen empty
res = app.getNonTerminatedTaskAlias()
assert.Equal(t, len(res), 0)
- //set two tasks to one is terminated, another is non-terminated
+ // set two tasks to one is terminated, another is non-terminated
task1.sm.SetState(events.States().Task.Rejected)
task2.sm.SetState(events.States().Task.Allocated)
// check the task, should only return task2's alias
res = app.getNonTerminatedTaskAlias()
assert.Equal(t, len(res), 1)
assert.Equal(t, res[0], "/test-00002")
}
+
+func TestSetTaskGroupsAndSchedulingPolicy(t *testing.T) {
+ app := NewApplication("app01", "root.a", "test-user",
map[string]string{}, newMockSchedulerAPI())
+ assert.Assert(t, app.getSchedulingPolicy() == nil)
+ assert.Assert(t, app.getTaskGroups() == nil)
+
+ app.setSchedulingPolicy(&v1alpha1.SchedulingPolicy{
+ Type: v1alpha1.TryReserve,
+ Parameters: map[string]string{
+ "option-1": "value-1",
+ "option-2": "value-2",
+ },
+ })
+
+ assert.Equal(t, app.getSchedulingPolicy().Type, v1alpha1.TryReserve)
+ assert.Equal(t, len(app.getSchedulingPolicy().Parameters), 2)
+ assert.Equal(t, app.getSchedulingPolicy().Parameters["option-1"],
"value-1")
+ assert.Equal(t, app.getSchedulingPolicy().Parameters["option-2"],
"value-2")
+
+ duration := int64(3000)
+ app.setTaskGroups([]*v1alpha1.TaskGroup{
+ {
+ Name: "test-group-1",
+ MinMember: 10,
+ MinResource: map[string]resource.Quantity{
+ "cpu": resource.MustParse("500m"),
+ "memory": resource.MustParse("500Mi"),
+ },
+ },
+ {
+ Name: "test-group-2",
+ MinMember: 20,
+ MinResource: map[string]resource.Quantity{
+ "cpu": resource.MustParse("1000m"),
+ "memory": resource.MustParse("1000Mi"),
Review comment:
I've changed to `v1.ResourceMemory.String()`.
This is because in yunikorn we are calling "vcore", not "cpu".
that is slight different that K8s.
And here, since the annotation is user-facing, we should follow the K8s
convention.
----------------------------------------------------------------
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]