cleanup: move scheduler plugin tests to use PodWrapper

Move scheduler plugin unit tests use testing PodWrapper
where applicable to reduce duplicating pod creation
code and shorten number of lines.

Signed-off-by: Yibo Zhuang <yibzhuang@gmail.com>
This commit is contained in:
Yibo Zhuang
2022-05-05 10:48:55 -07:00
parent fd08d47d8b
commit bc8f3198d5
18 changed files with 862 additions and 2830 deletions

View File

@@ -26,6 +26,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes/fake"
st "k8s.io/kubernetes/pkg/scheduler/testing"
)
func TestGetPodServices(t *testing.T) {
@@ -48,16 +49,11 @@ func TestGetPodServices(t *testing.T) {
}
var pods []*v1.Pod
for i := 0; i < 5; i++ {
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Name: fmt.Sprintf("test-pod-%d", i),
Labels: map[string]string{
"app": fmt.Sprintf("test-%d", i),
"label": fmt.Sprintf("label-%d", i),
},
},
}
pod := st.MakePod().Name(fmt.Sprintf("test-pod-%d", i)).
Namespace("test").
Label("app", fmt.Sprintf("test-%d", i)).
Label("label", fmt.Sprintf("label-%d", i)).
Obj()
pods = append(pods, pod)
}