k3s/cmd/kube-scheduler/app/options/deprecated_test.go

56 lines
1.4 KiB
Go
Raw Normal View History

Add validation for kube-scheduler adding validation for componentconfig adding validation to cmd kube-scheduler Add support for ipv6 in IsValidSocketAddr function updating copyright date in componentconfig/validation/validation.go updating copyright date in componentconfig/validation/validation_test.go adding validation for cli options adding BUILD files updating validate function to return []errors in cmd/kube-scheduler ok, really returning []error this time adding comments for exported componentconfig Validation functions silly me, not checking structs along the way :'( refactor to avoid else statement moving policy nil check up one function rejigging some deprecated cmd validations stumbling my way around validation slowly but surely updating according to review from @bsalamat - not validating leader election config unless leader election is enabled - leader election time values cannot be zero - removing validation for KubeConfigFile - removing validation for scheduler policy leader elect options should be non-negative adding test cases for renewDeadline and leaseDuration being zero fixing logic in componentconfig validation :sweat_smile: removing KubeConfigFile reference from tests as it was removed in master https://github.com/kubernetes/kubernetes/commit/2ff9bd6699ccdfb1f46c4aeda01518990ff71eda removing bogus space after var assignment adding more tests for componentconfig based on feedback making updates to validation because types were moved on master update bazel build adding validation for staging/apimachinery adding validation for staging/apiserver adding fieldPaths for staging validations moving staging validations out of componentconfig updating test case scenario for staging/apimachinery ./hack/update-bazel.sh moving kube-scheduler validations from componentconfig ./hack/update-bazel.sh removing non-negative check for QPS resourceLock required adding HardPodAffinitySymmetricWeight 0-100 range to cmd flag help section
2018-07-30 20:22:22 +00:00
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package options
import (
"testing"
)
func TestValidateDeprecatedKubeSchedulerConfiguration(t *testing.T) {
scenarios := map[string]struct {
expectedToFail bool
config *DeprecatedOptions
}{
"good": {
expectedToFail: false,
config: &DeprecatedOptions{
PolicyConfigFile: "/some/file",
UseLegacyPolicyConfig: true,
AlgorithmProvider: "",
},
},
"bad-policy-config-file-null": {
expectedToFail: true,
config: &DeprecatedOptions{
PolicyConfigFile: "",
UseLegacyPolicyConfig: true,
AlgorithmProvider: "",
},
},
}
for name, scenario := range scenarios {
errs := scenario.config.Validate()
if len(errs) == 0 && scenario.expectedToFail {
t.Errorf("Unexpected success for scenario: %s", name)
}
if len(errs) > 0 && !scenario.expectedToFail {
t.Errorf("Unexpected failure for scenario: %s - %+v", name, errs)
}
}
}