Skip to content

Commit 25c428c

Browse files
FrankYang0529manirajv06
authored andcommitted
[YUNIKORN-1687] add e2e for user & group quota enforcement
Closes: #634 Signed-off-by: Manikandan R <[email protected]>
1 parent 8b26c37 commit 25c428c

File tree

7 files changed

+528
-3
lines changed

7 files changed

+528
-3
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ go 1.20
2222

2323
require (
2424
github.com/GoogleCloudPlatform/spark-on-k8s-operator v0.0.0-20201215015655-2e8b733f5ad0
25-
github.com/apache/yunikorn-core v0.0.0-20230809131940-0ecf24d2aad2
25+
github.com/apache/yunikorn-core v0.0.0-20230831174655-2feb6ecc1384
2626
github.com/apache/yunikorn-scheduler-interface v0.0.0-20230831133811-e7622cf54e95
2727
github.com/google/go-cmp v0.5.9
2828
github.com/google/uuid v1.3.0

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
108108
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220418222510-f25a4f6275ed/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
109109
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves=
110110
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
111-
github.com/apache/yunikorn-core v0.0.0-20230809131940-0ecf24d2aad2 h1:8slKtc1QS7NFVcNk5nqrl5/1ZhBrSsdsc9x9i8/gGqs=
112-
github.com/apache/yunikorn-core v0.0.0-20230809131940-0ecf24d2aad2/go.mod h1:yI17LJoTnaNipTgk+uuJTdgBzfwLNrsRVktNYqYjAwI=
111+
github.com/apache/yunikorn-core v0.0.0-20230831174655-2feb6ecc1384 h1:yczvF3glSsCVz+vANH3md5vHHk1U8JoxSJdGEAw1IU0=
112+
github.com/apache/yunikorn-core v0.0.0-20230831174655-2feb6ecc1384/go.mod h1:g58rxTrJWK80i21F1YC85lXEH1YlHzefPqv/dXmMHxo=
113113
github.com/apache/yunikorn-scheduler-interface v0.0.0-20230831133811-e7622cf54e95 h1:ssLPAWkGdrBJwfPEPiv0np99IgynCmmR402TM0FxgPg=
114114
github.com/apache/yunikorn-scheduler-interface v0.0.0-20230831133811-e7622cf54e95/go.mod h1:/n67iTTOytyVor6wETVjleqzsp/NxCUmPslHcTvJ+Nw=
115115
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=

test/e2e/framework/configmanager/constants.go

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const (
4545
AppPath = "ws/v1/partition/%s/queue/%s/application/%s"
4646
ClustersPath = "ws/v1/clusters"
4747
NodesPath = "ws/v1/partition/%s/nodes"
48+
UserUsagePath = "ws/v1/partition/%s/usage/user/%s"
49+
GroupUsagePath = "ws/v1/partition/%s/usage/group/%s"
4850
HealthCheckPath = "ws/v1/scheduler/healthcheck"
4951
ValidateConfPath = "ws/v1/validate-conf"
5052

test/e2e/framework/helpers/yunikorn/rest_api_utils.go

+20
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,23 @@ func (c *RClient) GetPartitions(partition string) (*dao.PartitionQueueDAOInfo, e
398398
_, err = c.do(req, &partitions)
399399
return partitions, err
400400
}
401+
402+
func (c *RClient) GetUserUsage(partition string, userName string) (*dao.UserResourceUsageDAOInfo, error) {
403+
req, err := c.newRequest("GET", fmt.Sprintf(configmanager.UserUsagePath, partition, userName), nil)
404+
if err != nil {
405+
return nil, err
406+
}
407+
var userUsage *dao.UserResourceUsageDAOInfo
408+
_, err = c.do(req, &userUsage)
409+
return userUsage, err
410+
}
411+
412+
func (c *RClient) GetGroupUsage(partition string, groupName string) (*dao.GroupResourceUsageDAOInfo, error) {
413+
req, err := c.newRequest("GET", fmt.Sprintf(configmanager.GroupUsagePath, partition, groupName), nil)
414+
if err != nil {
415+
return nil, err
416+
}
417+
var groupUsage *dao.GroupResourceUsageDAOInfo
418+
_, err = c.do(req, &groupUsage)
419+
return groupUsage, err
420+
}

test/e2e/framework/helpers/yunikorn/wrappers.go

+9
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ func UpdateConfigMapWrapper(oldConfigMap *v1.ConfigMap, schedPolicy string, anno
7070
}
7171

7272
func UpdateCustomConfigMapWrapper(oldConfigMap *v1.ConfigMap, schedPolicy string, annotation string, mutator func(sc *configs.SchedulerConfig) error) {
73+
UpdateCustomConfigMapWrapperWithMap(oldConfigMap, schedPolicy, annotation, nil, mutator)
74+
}
75+
76+
func UpdateCustomConfigMapWrapperWithMap(oldConfigMap *v1.ConfigMap, schedPolicy string, annotation string, customMap map[string]string, mutator func(sc *configs.SchedulerConfig) error) {
7377
Ω(k.SetClient()).To(BeNil())
7478
By("Port-forward the scheduler pod")
7579
fwdErr := k.PortForwardYkSchedulerPod()
@@ -104,6 +108,10 @@ func UpdateCustomConfigMapWrapper(oldConfigMap *v1.ConfigMap, schedPolicy string
104108
configStr, yamlErr := common.ToYAML(sc)
105109
Ω(yamlErr).NotTo(HaveOccurred())
106110
c.Data[configmanager.DefaultPolicyGroup] = configStr
111+
112+
for k, v := range customMap {
113+
c.Data[k] = v
114+
}
107115
var d, err3 = k.UpdateConfigMap(c, configmanager.YuniKornTestConfig.YkNamespace)
108116
Ω(err3).NotTo(HaveOccurred())
109117
Ω(d).NotTo(BeNil())
@@ -125,6 +133,7 @@ func RestoreConfigMapWrapper(oldConfigMap *v1.ConfigMap, annotation string) {
125133
Ω(err).NotTo(HaveOccurred())
126134
ts, tsErr := common.SetQueueTimestamp(oldSC, "default", "root")
127135
Ω(tsErr).NotTo(HaveOccurred())
136+
c.Data = oldConfigMap.Data
128137
c.Data[configmanager.DefaultPolicyGroup], err = common.ToYAML(oldSC)
129138
Ω(err).NotTo(HaveOccurred())
130139

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package user_group_limit_test
20+
21+
import (
22+
"path/filepath"
23+
"testing"
24+
25+
"github.com/onsi/ginkgo/v2"
26+
"github.com/onsi/ginkgo/v2/reporters"
27+
"github.com/onsi/gomega"
28+
29+
"github.com/apache/yunikorn-k8shim/test/e2e/framework/configmanager"
30+
)
31+
32+
func init() {
33+
configmanager.YuniKornTestConfig.ParseFlags()
34+
}
35+
36+
func TestUserGroupLimit(t *testing.T) {
37+
ginkgo.ReportAfterSuite("TestUserGroupLimit", func(report ginkgo.Report) {
38+
err := reporters.GenerateJUnitReportWithConfig(
39+
report,
40+
filepath.Join(configmanager.YuniKornTestConfig.LogDir, "TEST-user_group_limit_junit.xml"),
41+
reporters.JunitReportConfig{OmitSpecLabels: true},
42+
)
43+
Ω(err).NotTo(HaveOccurred())
44+
})
45+
gomega.RegisterFailHandler(ginkgo.Fail)
46+
ginkgo.RunSpecs(t, "TestUserGroupLimit", ginkgo.Label("TestUserGroupLimit"))
47+
}
48+
49+
var Ω = gomega.Ω
50+
var HaveOccurred = gomega.HaveOccurred

0 commit comments

Comments
 (0)