Skip to content

Commit

Permalink
more unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
doupache committed Oct 27, 2023
1 parent f379bf1 commit 4ca2782
Showing 1 changed file with 160 additions and 0 deletions.
160 changes: 160 additions & 0 deletions pkg/scheduler/ugm/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,27 @@ func TestUserGroupLimitChange(t *testing.T) { //nolint:funlen
limits []configs.Limit
newLimits []configs.Limit
}{
// in a same limit
{
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),
},
},
{
name: "maxresources with an updated specific group limit",
user: security.UserGroup{User: "user1", Groups: []string{"group1"}},
Expand All @@ -1081,6 +1102,145 @@ 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),
},
},
{
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),
},
},
{
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 4ca2782

Please sign in to comment.