Merge pull request #90041 from tanjunchen/sche-remove-dependency-001

Scheduler:remove direct dependency for pkg/api/testing
This commit is contained in:
Kubernetes Prow Robot 2020-04-13 20:01:11 -07:00 committed by GitHub
commit fca197c748
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 51 deletions

View File

@ -13,7 +13,6 @@ go_library(
"doc.go",
"fuzzer.go",
"install.go",
"pod_specs.go",
],
importpath = "k8s.io/kubernetes/pkg/api/testing",
deps = [

View File

@ -1,45 +0,0 @@
/*
Copyright 2015 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 testing
import (
"k8s.io/api/core/v1"
api "k8s.io/kubernetes/pkg/apis/core"
)
// DeepEqualSafePodSpec returns a PodSpec which is ready to be used with apiequality.Semantic.DeepEqual
func DeepEqualSafePodSpec() api.PodSpec {
grace := int64(30)
return api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
TerminationGracePeriodSeconds: &grace,
SecurityContext: &api.PodSecurityContext{},
SchedulerName: api.DefaultSchedulerName,
}
}
// V1DeepEqualSafePodSpec returns a PodSpec which is ready to be used with apiequality.Semantic.DeepEqual
func V1DeepEqualSafePodSpec() v1.PodSpec {
grace := int64(30)
return v1.PodSpec{
RestartPolicy: v1.RestartPolicyAlways,
DNSPolicy: v1.DNSClusterFirst,
TerminationGracePeriodSeconds: &grace,
SecurityContext: &v1.PodSecurityContext{},
}
}

View File

@ -60,7 +60,6 @@ go_test(
],
embed = [":go_default_library"],
deps = [
"//pkg/api/testing:go_default_library",
"//pkg/apis/core:go_default_library",
"//pkg/controller/volume/scheduling:go_default_library",
"//pkg/features:go_default_library",

View File

@ -20,8 +20,6 @@ import (
"context"
"encoding/json"
"errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
apicore "k8s.io/kubernetes/pkg/apis/core"
"reflect"
"strings"
"testing"
@ -29,6 +27,7 @@ import (
"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/clock"
@ -40,7 +39,7 @@ import (
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/events"
extenderv1 "k8s.io/kube-scheduler/extender/v1"
apitesting "k8s.io/kubernetes/pkg/api/testing"
apicore "k8s.io/kubernetes/pkg/apis/core"
kubefeatures "k8s.io/kubernetes/pkg/features"
schedulerapi "k8s.io/kubernetes/pkg/scheduler/apis/config"
"k8s.io/kubernetes/pkg/scheduler/apis/config/scheme"
@ -314,9 +313,15 @@ func TestCreateFromConfigWithUnspecifiedPredicatesOrPriorities(t *testing.T) {
}
func TestDefaultErrorFunc(t *testing.T) {
grace := int64(30)
testPod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"},
Spec: apitesting.V1DeepEqualSafePodSpec(),
Spec: v1.PodSpec{
RestartPolicy: v1.RestartPolicyAlways,
DNSPolicy: v1.DNSClusterFirst,
TerminationGracePeriodSeconds: &grace,
SecurityContext: &v1.PodSecurityContext{},
},
}
nodeBar, nodeFoo :=