mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
remove legacy scheduler policy config, as well as associated flags policy-config-file, policy-configmap, policy-configmap-namespace and use-legacy-policy-config
Signed-off-by: kerthcet <kerthcet@gmail.com>
This commit is contained in:
@@ -20,9 +20,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"sort"
|
||||
@@ -1136,83 +1133,6 @@ func TestSchedulerWithVolumeBinding(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestInitPolicyFromFile(t *testing.T) {
|
||||
dir, err := ioutil.TempDir(os.TempDir(), "policy")
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
for i, test := range []struct {
|
||||
policy string
|
||||
expectedPredicates sets.String
|
||||
}{
|
||||
// Test json format policy file
|
||||
{
|
||||
policy: `{
|
||||
"kind" : "Policy",
|
||||
"apiVersion" : "v1",
|
||||
"predicates" : [
|
||||
{"name" : "PredicateOne"},
|
||||
{"name" : "PredicateTwo"}
|
||||
],
|
||||
"priorities" : [
|
||||
{"name" : "PriorityOne", "weight" : 1},
|
||||
{"name" : "PriorityTwo", "weight" : 5}
|
||||
]
|
||||
}`,
|
||||
expectedPredicates: sets.NewString(
|
||||
"PredicateOne",
|
||||
"PredicateTwo",
|
||||
),
|
||||
},
|
||||
// Test yaml format policy file
|
||||
{
|
||||
policy: `apiVersion: v1
|
||||
kind: Policy
|
||||
predicates:
|
||||
- name: PredicateOne
|
||||
- name: PredicateTwo
|
||||
priorities:
|
||||
- name: PriorityOne
|
||||
weight: 1
|
||||
- name: PriorityTwo
|
||||
weight: 5
|
||||
`,
|
||||
expectedPredicates: sets.NewString(
|
||||
"PredicateOne",
|
||||
"PredicateTwo",
|
||||
),
|
||||
},
|
||||
} {
|
||||
file := fmt.Sprintf("scheduler-policy-config-file-%d", i)
|
||||
fullPath := path.Join(dir, file)
|
||||
|
||||
if err := ioutil.WriteFile(fullPath, []byte(test.policy), 0644); err != nil {
|
||||
t.Fatalf("Failed writing a policy config file: %v", err)
|
||||
}
|
||||
|
||||
policy := &schedulerapi.Policy{}
|
||||
|
||||
if err := initPolicyFromFile(fullPath, policy); err != nil {
|
||||
t.Fatalf("Failed writing a policy config file: %v", err)
|
||||
}
|
||||
|
||||
// Verify that the policy is initialized correctly.
|
||||
schedPredicates := sets.NewString()
|
||||
for _, p := range policy.Predicates {
|
||||
schedPredicates.Insert(p.Name)
|
||||
}
|
||||
schedPrioritizers := sets.NewString()
|
||||
for _, p := range policy.Priorities {
|
||||
schedPrioritizers.Insert(p.Name)
|
||||
}
|
||||
if !schedPredicates.Equal(test.expectedPredicates) {
|
||||
t.Errorf("Expected predicates %v, got %v", test.expectedPredicates, schedPredicates)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSchedulerBinding(t *testing.T) {
|
||||
table := []struct {
|
||||
podName string
|
||||
|
||||
Reference in New Issue
Block a user