Introduce priority class in the resource quota

This commit is contained in:
vikaschoudhary16
2017-12-22 06:06:29 -05:00
committed by vikaschoudhary16
parent 4c13f5fdf5
commit 3cfe6412c7
30 changed files with 2966 additions and 1067 deletions

View File

@@ -11508,6 +11508,18 @@ func TestValidateResourceQuota(t *testing.T) {
Scopes: []core.ResourceQuotaScope{core.ResourceQuotaScopeNotBestEffort},
}
scopeSelectorSpec := core.ResourceQuotaSpec{
ScopeSelector: &core.ScopeSelector{
MatchExpressions: []core.ScopedResourceSelectorRequirement{
{
ScopeName: core.ResourceQuotaScopePriorityClass,
Operator: core.ScopeSelectorOpIn,
Values: []string{"cluster-services"},
},
},
},
}
// storage is not yet supported as a quota tracked resource
invalidQuotaResourceSpec := core.ResourceQuotaSpec{
Hard: core.ResourceList{
@@ -11600,6 +11612,13 @@ func TestValidateResourceQuota(t *testing.T) {
},
Spec: bestEffortSpec,
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "abc",
Namespace: "foo",
},
Spec: scopeSelectorSpec,
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "abc",
@@ -11608,12 +11627,13 @@ func TestValidateResourceQuota(t *testing.T) {
Spec: nonBestEffortSpec,
},
}
utilfeature.DefaultFeatureGate.Set("ResourceQuotaScopeSelectors=true")
for _, successCase := range successCases {
if errs := ValidateResourceQuota(&successCase); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
}
utilfeature.DefaultFeatureGate.Set("ResourceQuotaScopeSelectors=false")
errorCases := map[string]struct {
R core.ResourceQuota
@@ -11659,6 +11679,10 @@ func TestValidateResourceQuota(t *testing.T) {
core.ResourceQuota{ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: "foo"}, Spec: invalidScopeNameSpec},
"unsupported scope",
},
"forbidden-quota-scope-selector": {
core.ResourceQuota{ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: "foo"}, Spec: scopeSelectorSpec},
"feature-gate is disabled",
},
}
for k, v := range errorCases {
errs := ValidateResourceQuota(&v.R)