Skip to content

Commit

Permalink
[YUNIKORN-1950] Improving test coverage for user/group limit
Browse files Browse the repository at this point in the history
  • Loading branch information
doupache committed Dec 1, 2023
1 parent 2291cea commit 4dd8bb8
Showing 1 changed file with 170 additions and 0 deletions.
170 changes: 170 additions & 0 deletions pkg/scheduler/ugm/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,32 @@ func TestUserGroupLimitChange(t *testing.T) { //nolint:funlen
limits []configs.Limit
newLimits []configs.Limit
}{
// user limit only
{

name: "maxresources with an updated specific user limit",
user: security.UserGroup{User: "user1", Groups: []string{"group1"}},
limits: []configs.Limit{
createLimit([]string{"user1"}, nil, largeResource, 2),
},
newLimits: []configs.Limit{
createLimit([]string{"user1"}, nil, mediumResource, 2),
},
},
{
name: "maxapplications with an updated specific user limit",
user: security.UserGroup{User: "user1", Groups: []string{"group1"}},
limits: []configs.Limit{
createLimit([]string{"user1"}, nil, largeResource, 2),
},
newLimits: []configs.Limit{
createLimit([]string{"user1"}, nil, largeResource, 1),
},
},

// group limit only
{

name: "maxresources with an updated specific group limit",
user: security.UserGroup{User: "user1", Groups: []string{"group1"}},
limits: []configs.Limit{
Expand All @@ -1133,6 +1158,151 @@ func TestUserGroupLimitChange(t *testing.T) { //nolint:funlen
createLimit(nil, []string{"group1"}, mediumResource, 2),
},
},
{
name: "maxapplications with an updated specific group limit",
user: security.UserGroup{User: "user1", Groups: []string{"group1"}},
limits: []configs.Limit{
createLimit(nil, []string{"group1"}, largeResource, 2),
},
newLimits: []configs.Limit{
createLimit(nil, []string{"group1"}, largeResource, 1),
},
},

// user wilcard limit
{
name: "maxresources with an updated wildcard user limit",
user: security.UserGroup{User: "user2", Groups: []string{"group2"}},
limits: []configs.Limit{
createLimit([]string{"user1"}, nil, tinyResource, 2),
createLimit([]string{"*"}, nil, largeResource, 2),
},
newLimits: []configs.Limit{
createLimit([]string{"user1"}, nil, largeResource, 2),
createLimit([]string{"*"}, nil, mediumResource, 2),
},
},
{
name: "maxapplications with an updated wildcard user limit",
user: security.UserGroup{User: "user2", Groups: []string{"group2"}},
limits: []configs.Limit{
createLimit([]string{"user1"}, nil, tinyResource, 1),
createLimit([]string{"*"}, nil, largeResource, 2),
},
newLimits: []configs.Limit{
createLimit([]string{"user1"}, nil, largeResource, 2),
createLimit([]string{"*"}, nil, largeResource, 1),
},
},

// group wilcard limit
{

name: "maxresources with an updated wildcard group limit",
user: security.UserGroup{User: "user2", Groups: []string{"group2"}},
limits: []configs.Limit{
createLimit(nil, []string{"group1"}, tinyResource, 2),
createLimit(nil, []string{"*"}, largeResource, 2),
},
newLimits: []configs.Limit{
createLimit(nil, []string{"group1"}, largeResource, 2),
createLimit(nil, []string{"*"}, mediumResource, 2),
},
},
{
name: "maxapplications with an updated wildcard group limit",
user: security.UserGroup{User: "user2", Groups: []string{"group2"}},
limits: []configs.Limit{
createLimit(nil, []string{"group1"}, tinyResource, 1),
createLimit(nil, []string{"*"}, largeResource, 2),
},
newLimits: []configs.Limit{
createLimit(nil, []string{"group1"}, largeResource, 2),
createLimit(nil, []string{"*"}, largeResource, 1),
},
},

// in a different limit
{
name: "maxresources with a new specific user limit",
user: security.UserGroup{User: "user1", Groups: []string{"group1"}},
limits: []configs.Limit{
{
Limit: "parent queue limit for specific user",
Users: []string{"user1"},
MaxResources: map[string]string{"memory": "100", "vcores": "100"},
MaxApplications: 2,
},
},
newLimits: []configs.Limit{
{
Limit: "new parent queue limit for specific user",
Users: []string{"user1"},
MaxResources: map[string]string{"memory": "50", "vcores": "50"},
MaxApplications: 2,
},
},
},
{
name: "maxapplications with a new specific user limit",
user: security.UserGroup{User: "user1", Groups: []string{"group1"}},
limits: []configs.Limit{
{
Limit: "parent queue limit for specific user",
Users: []string{"user1"},
MaxResources: map[string]string{"memory": "100", "vcores": "100"},
MaxApplications: 2,
},
},
newLimits: []configs.Limit{
{
Limit: "new parent queue limit for specific user",
Users: []string{"user1"},
MaxResources: map[string]string{"memory": "100", "vcores": "100"},
MaxApplications: 1,
},
},
},
{
name: "maxresources with a new specific group limit",
user: security.UserGroup{User: "user1", Groups: []string{"group1"}},
limits: []configs.Limit{
{
Limit: "parent queue limit for specific group",
Groups: []string{"group1"},
MaxResources: map[string]string{"memory": "100", "vcores": "100"},
MaxApplications: 2,
},
},
newLimits: []configs.Limit{
{
Limit: "new parent queue limit for specific group",
Groups: []string{"group1"},
MaxResources: map[string]string{"memory": "50", "vcores": "50"},
MaxApplications: 2,
},
},
},
{
name: "maxapplications with a new specific group limit",
user: security.UserGroup{User: "user1", Groups: []string{"group1"}},
limits: []configs.Limit{
{
Limit: "parent queue limit for specific group",
Groups: []string{"group1"},
MaxResources: map[string]string{"memory": "100", "vcores": "100"},
MaxApplications: 2,
},
},
newLimits: []configs.Limit{
{
Limit: "new parent queue limit for specific group",
Groups: []string{"group1"},
MaxResources: map[string]string{"memory": "100", "vcores": "100"},
MaxApplications: 1,
},
},
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 4dd8bb8

Please sign in to comment.