mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-25 12:17:52 +00:00
Refactor tests to split ObjectMeta from TypeMeta
This commit is contained in:
@@ -95,7 +95,7 @@ func TestGenericScheduler(t *testing.T) {
|
||||
predicates: []FitPredicate{matchesPredicate},
|
||||
prioritizer: EqualPriority,
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
pod: api.Pod{TypeMeta: api.TypeMeta{Name: "machine2"}},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Name: "machine2"}},
|
||||
expectedHost: "machine2",
|
||||
},
|
||||
{
|
||||
@@ -108,7 +108,7 @@ func TestGenericScheduler(t *testing.T) {
|
||||
predicates: []FitPredicate{matchesPredicate},
|
||||
prioritizer: numericPriority,
|
||||
nodes: []string{"3", "2", "1"},
|
||||
pod: api.Pod{TypeMeta: api.TypeMeta{Name: "2"}},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Name: "2"}},
|
||||
expectedHost: "2",
|
||||
},
|
||||
{
|
||||
|
@@ -27,7 +27,7 @@ import (
|
||||
|
||||
func makeMinion(node string, cpu, memory int) api.Minion {
|
||||
return api.Minion{
|
||||
TypeMeta: api.TypeMeta{Name: node},
|
||||
ObjectMeta: api.ObjectMeta{Name: node},
|
||||
NodeResources: api.NodeResources{
|
||||
Capacity: api.ResourceList{
|
||||
resources.CPU: util.NewIntOrStringFromInt(cpu),
|
||||
@@ -87,10 +87,10 @@ func TestLeastRequested(t *testing.T) {
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
|
||||
test: "no resources requested",
|
||||
pods: []api.Pod{
|
||||
{DesiredState: machine1State, Labels: labels2},
|
||||
{DesiredState: machine1State, Labels: labels1},
|
||||
{DesiredState: machine2State, Labels: labels1},
|
||||
{DesiredState: machine2State, Labels: labels1},
|
||||
{DesiredState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{DesiredState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{DesiredState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{DesiredState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@@ -51,47 +51,47 @@ func TestSpreadPriority(t *testing.T) {
|
||||
test: "nothing scheduled",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{{CurrentState: machine1State}},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
|
||||
test: "no labels",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pods: []api.Pod{{CurrentState: machine1State, Labels: labels2}},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}}},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 0}},
|
||||
test: "different labels",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{
|
||||
{CurrentState: machine1State, Labels: labels2},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 0}, {"machine2", 1}},
|
||||
test: "one label match",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{
|
||||
{CurrentState: machine1State, Labels: labels2},
|
||||
{CurrentState: machine1State, Labels: labels1},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 1}, {"machine2", 1}},
|
||||
test: "two label matches on different machines",
|
||||
},
|
||||
{
|
||||
pod: api.Pod{Labels: labels1},
|
||||
pod: api.Pod{ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
pods: []api.Pod{
|
||||
{CurrentState: machine1State, Labels: labels2},
|
||||
{CurrentState: machine1State, Labels: labels1},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine2State, Labels: labels1},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels2}},
|
||||
{CurrentState: machine1State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
{CurrentState: machine2State, ObjectMeta: api.ObjectMeta{Labels: labels1}},
|
||||
},
|
||||
nodes: []string{"machine1", "machine2"},
|
||||
expectedList: []HostPriority{{"machine1", 1}, {"machine2", 2}},
|
||||
|
Reference in New Issue
Block a user