manirajv06 commented on code in PR #883:
URL: https://github.com/apache/yunikorn-core/pull/883#discussion_r1635919836


##########
pkg/scheduler/ugm/queue_tracker_test.go:
##########
@@ -318,6 +318,49 @@ func TestNewQueueTracker(t *testing.T) {
        assert.Assert(t, resources.IsZero(parent.resourceUsage))
 }
 
+func TestSetLimit(t *testing.T) {
+       manager := GetUserManager()
+       defer manager.ClearConfigLimits()
+       manager.userWildCardLimitsConfig = map[string]*LimitConfig{
+               path1: {
+                       maxApplications: 3,
+                       maxResources:    resources.NewResource(),
+               },
+       }
+       root := newRootQueueTracker(user)
+

Review Comment:
   assert user max apps, max resource and usewildcard flag here.



##########
pkg/scheduler/ugm/queue_tracker_test.go:
##########
@@ -318,6 +318,49 @@ func TestNewQueueTracker(t *testing.T) {
        assert.Assert(t, resources.IsZero(parent.resourceUsage))
 }
 
+func TestSetLimit(t *testing.T) {
+       manager := GetUserManager()
+       defer manager.ClearConfigLimits()
+       manager.userWildCardLimitsConfig = map[string]*LimitConfig{
+               path1: {
+                       maxApplications: 3,
+                       maxResources:    resources.NewResource(),
+               },
+       }
+       root := newRootQueueTracker(user)
+
+       // create tracker hierarchy
+       limit := resources.NewResourceFromMap(map[string]resources.Quantity{
+               "mem":   10,
+               "vcore": 10})
+       root.setLimit(strings.Split(queuePath1, configs.DOT), limit.Clone(), 9, 
true, user, true)
+
+       // check settings
+       parentQ := root.childQueueTrackers["parent"]
+       assert.Assert(t, parentQ.maxResources == nil)
+       assert.Equal(t, uint64(0), parentQ.maxRunningApps)
+       childQ := parentQ.childQueueTrackers["child1"]
+       assert.Assert(t, parentQ.maxResources == nil)
+       assert.Equal(t, uint64(9), childQ.maxRunningApps)
+       assert.Assert(t, resources.Equals(limit, childQ.maxResources))
+
+       // check if settings are overridden
+       newLimit := resources.NewResourceFromMap(map[string]resources.Quantity{
+               "mem":   20,
+               "vcore": 20})
+       root.setLimit(strings.Split(queuePath1, configs.DOT), newLimit.Clone(), 
3, false, user, true) // override
+       assert.Assert(t, resources.Equals(newLimit, childQ.maxResources))
+       newLimit2 := resources.NewResourceFromMap(map[string]resources.Quantity{
+               "mem":   30,
+               "vcore": 30})
+       root.setLimit(strings.Split(queuePath1, configs.DOT), 
newLimit2.Clone(), 3, true, user, true) // no override
+       assert.Assert(t, resources.Equals(newLimit, childQ.maxResources))
+       root.setLimit(strings.Split(queuePath1, configs.DOT), 
newLimit2.Clone(), 3, true, user, false) // override -> changes 
qt.doWildCardCheck
+       assert.Assert(t, resources.Equals(newLimit2, childQ.maxResources))
+       root.setLimit(strings.Split(queuePath1, configs.DOT), 
newLimit2.Clone(), 3, false, user, false) // no override

Review Comment:
   Same limit (newLimit2) has applied here too. So how do we ensure override 
really happens or not?
   
   useWildCard flag helps to know whether wild card user (*) settings has 
applied for that specific user or not. True means applied, false means no. In 
case user specific settings applied for that specific use, useWildcard flag is 
"no".
   
   doWildCheck is required only when we are trying to clear or reset wild card 
user settings for all existing users not clearing or resetting user specific 
settings for that specific user. For example, When config had settings for wild 
card user (*) earlier but not now.  Before clearing/reset settings for specific 
user object, there is a need to pass this flag to do the actual clearance.
   



##########
pkg/scheduler/ugm/queue_tracker_test.go:
##########
@@ -318,6 +318,49 @@ func TestNewQueueTracker(t *testing.T) {
        assert.Assert(t, resources.IsZero(parent.resourceUsage))
 }
 
+func TestSetLimit(t *testing.T) {
+       manager := GetUserManager()
+       defer manager.ClearConfigLimits()
+       manager.userWildCardLimitsConfig = map[string]*LimitConfig{
+               path1: {
+                       maxApplications: 3,
+                       maxResources:    resources.NewResource(),
+               },
+       }
+       root := newRootQueueTracker(user)
+
+       // create tracker hierarchy
+       limit := resources.NewResourceFromMap(map[string]resources.Quantity{
+               "mem":   10,
+               "vcore": 10})
+       root.setLimit(strings.Split(queuePath1, configs.DOT), limit.Clone(), 9, 
true, user, true)
+
+       // check settings
+       parentQ := root.childQueueTrackers["parent"]
+       assert.Assert(t, parentQ.maxResources == nil)
+       assert.Equal(t, uint64(0), parentQ.maxRunningApps)
+       childQ := parentQ.childQueueTrackers["child1"]
+       assert.Assert(t, parentQ.maxResources == nil)
+       assert.Equal(t, uint64(9), childQ.maxRunningApps)
+       assert.Assert(t, resources.Equals(limit, childQ.maxResources))
+
+       // check if settings are overridden
+       newLimit := resources.NewResourceFromMap(map[string]resources.Quantity{
+               "mem":   20,
+               "vcore": 20})
+       root.setLimit(strings.Split(queuePath1, configs.DOT), newLimit.Clone(), 
3, false, user, true) // override
+       assert.Assert(t, resources.Equals(newLimit, childQ.maxResources))

Review Comment:
   assert usewildcard flag here.



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