Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YUNIKORN-1957] Add user/group limit config change e2e test #735

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 232 additions & 0 deletions test/e2e/user_group_limit/user_group_limit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,238 @@ var _ = ginkgo.Describe("UserGroupLimit", func() {
checkUsage(userTestType, user2, "root.sandbox1", []*v1.Pod{usergroup2Sandbox1Pod1})
})

ginkgo.It("Verify_maxresources_with_users_limits_changed", func() {
ginkgo.By("Update config")
annotation = "ann-" + common.RandSeq(10)

// The wait wrapper still can't fully guarantee that the config in AdmissionController has been updated.
yunikorn.WaitForAdmissionControllerRefreshConfAfterAction(func() {
yunikorn.UpdateCustomConfigMapWrapperWithMap(oldConfigMap, "", annotation, admissionCustomConfig, func(sc *configs.SchedulerConfig) error {
// remove placement rules so we can control queue
sc.Partitions[0].PlacementRules = nil

return common.AddQueue(sc, "default", "root", configs.QueueConfig{
Name: "sandbox1",
Limits: []configs.Limit{
{
Limit: "user entry",
Users: []string{user1},
MaxApplications: 1,
MaxResources: map[string]string{
siCommon.Memory: fmt.Sprintf("%dM", largeMem),
},
},
},
})
})
})

usergroup1 := &si.UserGroupInformation{User: user1, Groups: []string{group1}}
// usergroup1 can deploy the second sleep pod to root.sandbox1
usergroup1Sandbox1Pod1 := deploySleepPod(usergroup1, "root.sandbox1", true, "because memory usage is less than maxresources")
_ = deploySleepPod(usergroup1, "root.sandbox1", false, "because final memory usage is more than maxresources")
checkUsage(userTestType, user1, "root.sandbox1", []*v1.Pod{usergroup1Sandbox1Pod1})

// The wait wrapper still can't fully guarantee that the config in AdmissionController has been updated.
yunikorn.WaitForAdmissionControllerRefreshConfAfterAction(func() {
yunikorn.UpdateCustomConfigMapWrapperWithMap(oldConfigMap, "", annotation, admissionCustomConfig, func(sc *configs.SchedulerConfig) error {
// remove placement rules so we can control queue
sc.Partitions[0].PlacementRules = nil

return common.AddQueue(sc, "default", "root", configs.QueueConfig{
Name: "sandbox1",
Limits: []configs.Limit{
{
Limit: "user entry",
Users: []string{user1},
MaxApplications: 2,
MaxResources: map[string]string{
siCommon.Memory: fmt.Sprintf("%dM", largeMem),
},
},
},
})
})
})

usergroup1Sandbox1Pod1 = deploySleepPod(usergroup1, "root.sandbox1", true, "because memory usage is less than maxresources")
checkUsage(userTestType, user1, "root.sandbox1", []*v1.Pod{usergroup1Sandbox1Pod1})
})

ginkgo.It("Verify_maxapplications_with_users_limits_changed", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

groups ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this block is for users as I can see 2 blocks below for groups. If it is true, then we need to check the config in this block as it doesn't have any limits for users

ginkgo.By("Update config")
annotation = "ann-" + common.RandSeq(10)

// The wait wrapper still can't fully guarantee that the config in AdmissionController has been updated.
yunikorn.WaitForAdmissionControllerRefreshConfAfterAction(func() {
yunikorn.UpdateCustomConfigMapWrapperWithMap(oldConfigMap, "", annotation, admissionCustomConfig, func(sc *configs.SchedulerConfig) error {
// remove placement rules so we can control queue
sc.Partitions[0].PlacementRules = nil

return common.AddQueue(sc, "default", "root", configs.QueueConfig{
Name: "sandbox1",
Limits: []configs.Limit{
{
Limit: "user entry",
Groups: []string{group1},
MaxApplications: 1,
MaxResources: map[string]string{
siCommon.Memory: fmt.Sprintf("%dM", largeMem),
},
},
},
})
})
})

usergroup1 := &si.UserGroupInformation{User: user1, Groups: []string{group1}}
// usergroup1 can deploy the second sleep pod to root.sandbox1
usergroup1Sandbox1Pod1 := deploySleepPod(usergroup1, "root.sandbox1", true, "because applications is less than applications")
_ = deploySleepPod(usergroup1, "root.sandbox1", false, "because final applications is more than applications")
checkUsage(userTestType, user1, "root.sandbox1", []*v1.Pod{usergroup1Sandbox1Pod1})

// The wait wrapper still can't fully guarantee that the config in AdmissionController has been updated.
yunikorn.WaitForAdmissionControllerRefreshConfAfterAction(func() {
yunikorn.UpdateCustomConfigMapWrapperWithMap(oldConfigMap, "", annotation, admissionCustomConfig, func(sc *configs.SchedulerConfig) error {
// remove placement rules so we can control queue
sc.Partitions[0].PlacementRules = nil

return common.AddQueue(sc, "default", "root", configs.QueueConfig{
Name: "sandbox1",
Limits: []configs.Limit{
{
Limit: "user entry",
Groups: []string{group1},
MaxApplications: 2,
MaxResources: map[string]string{
siCommon.Memory: fmt.Sprintf("%dM", largeMem),
},
},
},
})
})
})

usergroup1Sandbox1Pod1 = deploySleepPod(usergroup1, "root.sandbox1", true, "because applications is less than new maxapplications")
checkUsage(userTestType, user1, "root.sandbox1", []*v1.Pod{usergroup1Sandbox1Pod1})
})

ginkgo.It("Verify_maxresources_with_groups_limits_changed", func() {
ginkgo.By("Update config")
annotation = "ann-" + common.RandSeq(10)

// The wait wrapper still can't fully guarantee that the config in AdmissionController has been updated.
yunikorn.WaitForAdmissionControllerRefreshConfAfterAction(func() {
yunikorn.UpdateCustomConfigMapWrapperWithMap(oldConfigMap, "", annotation, admissionCustomConfig, func(sc *configs.SchedulerConfig) error {
// remove placement rules so we can control queue
sc.Partitions[0].PlacementRules = nil

return common.AddQueue(sc, "default", "root", configs.QueueConfig{
Name: "sandbox1",
Limits: []configs.Limit{
{
Limit: "group entry",
Groups: []string{group1},
MaxApplications: 1,
MaxResources: map[string]string{
siCommon.Memory: fmt.Sprintf("%dM", mediumMem),
},
},
},
})
})
})

usergroup1 := &si.UserGroupInformation{User: user1, Groups: []string{group1}}
// usergroup1 can deploy the second sleep pod to root.sandbox1
usergroup1Sandbox1Pod1 := deploySleepPod(usergroup1, "root.sandbox1", true, "because memory usage is less than maxresources")
_ = deploySleepPod(usergroup1, "root.sandbox1", false, "because final memory usage is more than maxresources")
checkUsage(groupTestType, group1, "root.sandbox1", []*v1.Pod{usergroup1Sandbox1Pod1})

// The wait wrapper still can't fully guarantee that the config in AdmissionController has been updated.
yunikorn.WaitForAdmissionControllerRefreshConfAfterAction(func() {
yunikorn.UpdateCustomConfigMapWrapperWithMap(oldConfigMap, "", annotation, admissionCustomConfig, func(sc *configs.SchedulerConfig) error {
// remove placement rules so we can control queue
sc.Partitions[0].PlacementRules = nil

return common.AddQueue(sc, "default", "root", configs.QueueConfig{
Name: "sandbox1",
Limits: []configs.Limit{
{
Limit: "group entry",
Groups: []string{group1},
MaxApplications: 2,
MaxResources: map[string]string{
siCommon.Memory: fmt.Sprintf("%dM", largeMem),
},
},
},
})
})
})

usergroup1Sandbox1Pod1 = deploySleepPod(usergroup1, "root.sandbox1", true, "because memory usage is less than maxresources")
checkUsage(groupTestType, group1, "root.sandbox1", []*v1.Pod{usergroup1Sandbox1Pod1})
})

ginkgo.It("Verify_maxapplications_with_groups_limits_changed", func() {
ginkgo.By("Update config")
annotation = "ann-" + common.RandSeq(10)

// The wait wrapper still can't fully guarantee that the config in AdmissionController has been updated.
yunikorn.WaitForAdmissionControllerRefreshConfAfterAction(func() {
yunikorn.UpdateCustomConfigMapWrapperWithMap(oldConfigMap, "", annotation, admissionCustomConfig, func(sc *configs.SchedulerConfig) error {
// remove placement rules so we can control queue
sc.Partitions[0].PlacementRules = nil

return common.AddQueue(sc, "default", "root", configs.QueueConfig{
Name: "sandbox1",
Limits: []configs.Limit{
{
Limit: "group entry",
Groups: []string{group1},
MaxApplications: 1,
MaxResources: map[string]string{
siCommon.Memory: fmt.Sprintf("%dM", largeMem),
},
},
},
})
})
})

usergroup1 := &si.UserGroupInformation{User: user1, Groups: []string{group1}}
// usergroup1 can deploy the second sleep pod to root.sandbox1
usergroup1Sandbox1Pod1 := deploySleepPod(usergroup1, "root.sandbox1", true, "because applications is less than applications")
_ = deploySleepPod(usergroup1, "root.sandbox1", false, "because final applications is more than applications")
checkUsage(groupTestType, group1, "root.sandbox1", []*v1.Pod{usergroup1Sandbox1Pod1})

// The wait wrapper still can't fully guarantee that the config in AdmissionController has been updated.
yunikorn.WaitForAdmissionControllerRefreshConfAfterAction(func() {
yunikorn.UpdateCustomConfigMapWrapperWithMap(oldConfigMap, "", annotation, admissionCustomConfig, func(sc *configs.SchedulerConfig) error {
// remove placement rules so we can control queue
sc.Partitions[0].PlacementRules = nil

return common.AddQueue(sc, "default", "root", configs.QueueConfig{
Name: "sandbox1",
Limits: []configs.Limit{
{
Limit: "group entry",
Groups: []string{group1},
MaxApplications: 2,
MaxResources: map[string]string{
siCommon.Memory: fmt.Sprintf("%dM", largeMem),
},
},
},
})
})
})

usergroup1Sandbox1Pod1 = deploySleepPod(usergroup1, "root.sandbox1", true, "because applications is less than new maxapplications")
checkUsage(groupTestType, group1, "root.sandbox1", []*v1.Pod{usergroup1Sandbox1Pod1})
})

ginkgo.AfterEach(func() {
testDescription := ginkgo.CurrentSpecReport()
if testDescription.Failed() {
Expand Down
Loading