mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Avoid using negative words in PreFilter and PreScore tests.
This commit is contained in:
		@@ -42,14 +42,15 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
		wantPreFilterStatus *framework.Status
 | 
							wantPreFilterStatus *framework.Status
 | 
				
			||||||
		wantPreFilterResult *framework.PreFilterResult
 | 
							wantPreFilterResult *framework.PreFilterResult
 | 
				
			||||||
		args                config.NodeAffinityArgs
 | 
							args                config.NodeAffinityArgs
 | 
				
			||||||
		disablePreFilter    bool
 | 
							runPreFilter        bool
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "missing labels",
 | 
								name: "missing labels",
 | 
				
			||||||
			pod: st.MakePod().NodeSelector(map[string]string{
 | 
								pod: st.MakePod().NodeSelector(map[string]string{
 | 
				
			||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
			}).Obj(),
 | 
								}).Obj(),
 | 
				
			||||||
			wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:   framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "same labels",
 | 
								name: "same labels",
 | 
				
			||||||
@@ -59,6 +60,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "node labels are superset",
 | 
								name: "node labels are superset",
 | 
				
			||||||
@@ -69,6 +71,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
				"baz": "blah",
 | 
									"baz": "blah",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "node labels are subset",
 | 
								name: "node labels are subset",
 | 
				
			||||||
@@ -79,7 +82,8 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:   framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with matchExpressions using In operator that matches the existing node",
 | 
								name: "Pod with matchExpressions using In operator that matches the existing node",
 | 
				
			||||||
@@ -107,6 +111,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with matchExpressions using Gt operator that matches the existing node",
 | 
								name: "Pod with matchExpressions using Gt operator that matches the existing node",
 | 
				
			||||||
@@ -135,6 +140,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
				// We use two digit to denote major version and two digit for minor version.
 | 
									// We use two digit to denote major version and two digit for minor version.
 | 
				
			||||||
				"kernel-version": "0206",
 | 
									"kernel-version": "0206",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with matchExpressions using NotIn operator that matches the existing node",
 | 
								name: "Pod with matchExpressions using NotIn operator that matches the existing node",
 | 
				
			||||||
@@ -162,6 +168,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"mem-type": "DDR3",
 | 
									"mem-type": "DDR3",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with matchExpressions using Exists operator that matches the existing node",
 | 
								name: "Pod with matchExpressions using Exists operator that matches the existing node",
 | 
				
			||||||
@@ -188,6 +195,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"GPU": "NVIDIA-GRID-K1",
 | 
									"GPU": "NVIDIA-GRID-K1",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with affinity that don't match node's labels won't schedule onto the node",
 | 
								name: "Pod with affinity that don't match node's labels won't schedule onto the node",
 | 
				
			||||||
@@ -215,7 +223,8 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:   framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with empty MatchExpressions is not a valid value will match no objects and won't schedule onto the node",
 | 
								name: "Pod with empty MatchExpressions is not a valid value will match no objects and won't schedule onto the node",
 | 
				
			||||||
@@ -237,7 +246,8 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:   framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with no Affinity will schedule onto a node",
 | 
								name: "Pod with no Affinity will schedule onto a node",
 | 
				
			||||||
@@ -246,6 +256,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantPreFilterStatus: framework.NewStatus(framework.Skip),
 | 
								wantPreFilterStatus: framework.NewStatus(framework.Skip),
 | 
				
			||||||
 | 
								runPreFilter:        true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with Affinity but nil NodeSelector will schedule onto a node",
 | 
								name: "Pod with Affinity but nil NodeSelector will schedule onto a node",
 | 
				
			||||||
@@ -262,6 +273,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantPreFilterStatus: framework.NewStatus(framework.Skip),
 | 
								wantPreFilterStatus: framework.NewStatus(framework.Skip),
 | 
				
			||||||
 | 
								runPreFilter:        true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with multiple matchExpressions ANDed that matches the existing node",
 | 
								name: "Pod with multiple matchExpressions ANDed that matches the existing node",
 | 
				
			||||||
@@ -292,6 +304,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"GPU": "NVIDIA-GRID-K1",
 | 
									"GPU": "NVIDIA-GRID-K1",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with multiple matchExpressions ANDed that doesn't match the existing node",
 | 
								name: "Pod with multiple matchExpressions ANDed that doesn't match the existing node",
 | 
				
			||||||
@@ -322,7 +335,8 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"GPU": "NVIDIA-GRID-K1",
 | 
									"GPU": "NVIDIA-GRID-K1",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:   framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with multiple NodeSelectorTerms ORed in affinity, matches the node's labels and will schedule onto the node",
 | 
								name: "Pod with multiple NodeSelectorTerms ORed in affinity, matches the node's labels and will schedule onto the node",
 | 
				
			||||||
@@ -359,6 +373,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with an Affinity and a PodSpec.NodeSelector(the old thing that we are deprecating) " +
 | 
								name: "Pod with an Affinity and a PodSpec.NodeSelector(the old thing that we are deprecating) " +
 | 
				
			||||||
@@ -389,6 +404,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with an Affinity matches node's labels but the PodSpec.NodeSelector(the old thing that we are deprecating) " +
 | 
								name: "Pod with an Affinity matches node's labels but the PodSpec.NodeSelector(the old thing that we are deprecating) " +
 | 
				
			||||||
@@ -419,7 +435,8 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"foo": "barrrrrr",
 | 
									"foo": "barrrrrr",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:   framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with an invalid value in Affinity term won't be scheduled onto the node",
 | 
								name: "Pod with an invalid value in Affinity term won't be scheduled onto the node",
 | 
				
			||||||
@@ -447,7 +464,8 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:   framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with matchFields using In operator that matches the existing node",
 | 
								name: "Pod with matchFields using In operator that matches the existing node",
 | 
				
			||||||
@@ -474,6 +492,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			},
 | 
								},
 | 
				
			||||||
			nodeName:            "node1",
 | 
								nodeName:            "node1",
 | 
				
			||||||
			wantPreFilterResult: &framework.PreFilterResult{NodeNames: sets.NewString("node1")},
 | 
								wantPreFilterResult: &framework.PreFilterResult{NodeNames: sets.NewString("node1")},
 | 
				
			||||||
 | 
								runPreFilter:        true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with matchFields using In operator that does not match the existing node",
 | 
								name: "Pod with matchFields using In operator that does not match the existing node",
 | 
				
			||||||
@@ -501,6 +520,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			nodeName:            "node2",
 | 
								nodeName:            "node2",
 | 
				
			||||||
			wantStatus:          framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:          framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
			wantPreFilterResult: &framework.PreFilterResult{NodeNames: sets.NewString("node1")},
 | 
								wantPreFilterResult: &framework.PreFilterResult{NodeNames: sets.NewString("node1")},
 | 
				
			||||||
 | 
								runPreFilter:        true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with two terms: matchFields does not match, but matchExpressions matches",
 | 
								name: "Pod with two terms: matchFields does not match, but matchExpressions matches",
 | 
				
			||||||
@@ -534,8 +554,9 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			nodeName: "node2",
 | 
								nodeName:     "node2",
 | 
				
			||||||
			labels:   map[string]string{"foo": "bar"},
 | 
								labels:       map[string]string{"foo": "bar"},
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with one term: matchFields does not match, but matchExpressions matches",
 | 
								name: "Pod with one term: matchFields does not match, but matchExpressions matches",
 | 
				
			||||||
@@ -571,6 +592,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels:              map[string]string{"foo": "bar"},
 | 
								labels:              map[string]string{"foo": "bar"},
 | 
				
			||||||
			wantPreFilterResult: &framework.PreFilterResult{NodeNames: sets.NewString("node1")},
 | 
								wantPreFilterResult: &framework.PreFilterResult{NodeNames: sets.NewString("node1")},
 | 
				
			||||||
			wantStatus:          framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:          framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
 | 
								runPreFilter:        true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with one term: both matchFields and matchExpressions match",
 | 
								name: "Pod with one term: both matchFields and matchExpressions match",
 | 
				
			||||||
@@ -605,6 +627,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			nodeName:            "node1",
 | 
								nodeName:            "node1",
 | 
				
			||||||
			labels:              map[string]string{"foo": "bar"},
 | 
								labels:              map[string]string{"foo": "bar"},
 | 
				
			||||||
			wantPreFilterResult: &framework.PreFilterResult{NodeNames: sets.NewString("node1")},
 | 
								wantPreFilterResult: &framework.PreFilterResult{NodeNames: sets.NewString("node1")},
 | 
				
			||||||
 | 
								runPreFilter:        true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with two terms: both matchFields and matchExpressions do not match",
 | 
								name: "Pod with two terms: both matchFields and matchExpressions do not match",
 | 
				
			||||||
@@ -638,9 +661,10 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			nodeName:   "node2",
 | 
								nodeName:     "node2",
 | 
				
			||||||
			labels:     map[string]string{"foo": "bar"},
 | 
								labels:       map[string]string{"foo": "bar"},
 | 
				
			||||||
			wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:   framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with two terms of node.Name affinity",
 | 
								name: "Pod with two terms of node.Name affinity",
 | 
				
			||||||
@@ -676,6 +700,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			},
 | 
								},
 | 
				
			||||||
			nodeName:            "node2",
 | 
								nodeName:            "node2",
 | 
				
			||||||
			wantPreFilterResult: &framework.PreFilterResult{NodeNames: sets.NewString("node1", "node2")},
 | 
								wantPreFilterResult: &framework.PreFilterResult{NodeNames: sets.NewString("node1", "node2")},
 | 
				
			||||||
 | 
								runPreFilter:        true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Pod with two conflicting mach field requirements",
 | 
								name: "Pod with two conflicting mach field requirements",
 | 
				
			||||||
@@ -709,6 +734,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels:              map[string]string{"foo": "bar"},
 | 
								labels:              map[string]string{"foo": "bar"},
 | 
				
			||||||
			wantPreFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, errReasonConflict),
 | 
								wantPreFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, errReasonConflict),
 | 
				
			||||||
			wantStatus:          framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:          framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
 | 
								runPreFilter:        true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Matches added affinity and Pod's node affinity",
 | 
								name: "Matches added affinity and Pod's node affinity",
 | 
				
			||||||
@@ -748,6 +774,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Matches added affinity but not Pod's node affinity",
 | 
								name: "Matches added affinity but not Pod's node affinity",
 | 
				
			||||||
@@ -787,7 +814,8 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
								wantStatus:   framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonPod),
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name:     "Doesn't match added affinity",
 | 
								name:     "Doesn't match added affinity",
 | 
				
			||||||
@@ -809,7 +837,8 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, errReasonEnforced),
 | 
								wantStatus:   framework.NewStatus(framework.UnschedulableAndUnresolvable, errReasonEnforced),
 | 
				
			||||||
 | 
								runPreFilter: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Matches node selector correctly even if PreFilter is not called",
 | 
								name: "Matches node selector correctly even if PreFilter is not called",
 | 
				
			||||||
@@ -824,7 +853,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
				"foo": "bar",
 | 
									"foo": "bar",
 | 
				
			||||||
				"baz": "blah",
 | 
									"baz": "blah",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			disablePreFilter: true,
 | 
								runPreFilter: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "Matches node affinity correctly even if PreFilter is not called",
 | 
								name: "Matches node affinity correctly even if PreFilter is not called",
 | 
				
			||||||
@@ -855,7 +884,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
			labels: map[string]string{
 | 
								labels: map[string]string{
 | 
				
			||||||
				"GPU": "NVIDIA-GRID-K1",
 | 
									"GPU": "NVIDIA-GRID-K1",
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			disablePreFilter: true,
 | 
								runPreFilter: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -875,7 +904,7 @@ func TestNodeAffinity(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			state := framework.NewCycleState()
 | 
								state := framework.NewCycleState()
 | 
				
			||||||
			var gotStatus *framework.Status
 | 
								var gotStatus *framework.Status
 | 
				
			||||||
			if !test.disablePreFilter {
 | 
								if test.runPreFilter {
 | 
				
			||||||
				gotPreFilterResult, gotStatus := p.(framework.PreFilterPlugin).PreFilter(context.Background(), state, test.pod)
 | 
									gotPreFilterResult, gotStatus := p.(framework.PreFilterPlugin).PreFilter(context.Background(), state, test.pod)
 | 
				
			||||||
				if diff := cmp.Diff(test.wantPreFilterStatus, gotStatus); diff != "" {
 | 
									if diff := cmp.Diff(test.wantPreFilterStatus, gotStatus); diff != "" {
 | 
				
			||||||
					t.Errorf("unexpected PreFilter Status (-want,+got):\n%s", diff)
 | 
										t.Errorf("unexpected PreFilter Status (-want,+got):\n%s", diff)
 | 
				
			||||||
@@ -968,12 +997,12 @@ func TestNodeAffinityPriority(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tests := []struct {
 | 
						tests := []struct {
 | 
				
			||||||
		name            string
 | 
							name         string
 | 
				
			||||||
		pod             *v1.Pod
 | 
							pod          *v1.Pod
 | 
				
			||||||
		nodes           []*v1.Node
 | 
							nodes        []*v1.Node
 | 
				
			||||||
		expectedList    framework.NodeScoreList
 | 
							expectedList framework.NodeScoreList
 | 
				
			||||||
		args            config.NodeAffinityArgs
 | 
							args         config.NodeAffinityArgs
 | 
				
			||||||
		disablePreScore bool
 | 
							runPreScore  bool
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "all nodes are same priority as NodeAffinity is nil",
 | 
								name: "all nodes are same priority as NodeAffinity is nil",
 | 
				
			||||||
@@ -988,6 +1017,7 @@ func TestNodeAffinityPriority(t *testing.T) {
 | 
				
			|||||||
				{ObjectMeta: metav1.ObjectMeta{Name: "node3", Labels: label3}},
 | 
									{ObjectMeta: metav1.ObjectMeta{Name: "node3", Labels: label3}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedList: []framework.NodeScore{{Name: "node1", Score: 0}, {Name: "node2", Score: 0}, {Name: "node3", Score: 0}},
 | 
								expectedList: []framework.NodeScore{{Name: "node1", Score: 0}, {Name: "node2", Score: 0}, {Name: "node3", Score: 0}},
 | 
				
			||||||
 | 
								runPreScore:  true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "no node matches preferred scheduling requirements in NodeAffinity of pod so all nodes' priority is zero",
 | 
								name: "no node matches preferred scheduling requirements in NodeAffinity of pod so all nodes' priority is zero",
 | 
				
			||||||
@@ -1002,6 +1032,7 @@ func TestNodeAffinityPriority(t *testing.T) {
 | 
				
			|||||||
				{ObjectMeta: metav1.ObjectMeta{Name: "node3", Labels: label3}},
 | 
									{ObjectMeta: metav1.ObjectMeta{Name: "node3", Labels: label3}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedList: []framework.NodeScore{{Name: "node1", Score: 0}, {Name: "node2", Score: 0}, {Name: "node3", Score: 0}},
 | 
								expectedList: []framework.NodeScore{{Name: "node1", Score: 0}, {Name: "node2", Score: 0}, {Name: "node3", Score: 0}},
 | 
				
			||||||
 | 
								runPreScore:  true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "only node1 matches the preferred scheduling requirements of pod",
 | 
								name: "only node1 matches the preferred scheduling requirements of pod",
 | 
				
			||||||
@@ -1016,6 +1047,7 @@ func TestNodeAffinityPriority(t *testing.T) {
 | 
				
			|||||||
				{ObjectMeta: metav1.ObjectMeta{Name: "node3", Labels: label3}},
 | 
									{ObjectMeta: metav1.ObjectMeta{Name: "node3", Labels: label3}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedList: []framework.NodeScore{{Name: "node1", Score: framework.MaxNodeScore}, {Name: "node2", Score: 0}, {Name: "node3", Score: 0}},
 | 
								expectedList: []framework.NodeScore{{Name: "node1", Score: framework.MaxNodeScore}, {Name: "node2", Score: 0}, {Name: "node3", Score: 0}},
 | 
				
			||||||
 | 
								runPreScore:  true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "all nodes matches the preferred scheduling requirements of pod but with different priorities ",
 | 
								name: "all nodes matches the preferred scheduling requirements of pod but with different priorities ",
 | 
				
			||||||
@@ -1030,6 +1062,7 @@ func TestNodeAffinityPriority(t *testing.T) {
 | 
				
			|||||||
				{ObjectMeta: metav1.ObjectMeta{Name: "node2", Labels: label2}},
 | 
									{ObjectMeta: metav1.ObjectMeta{Name: "node2", Labels: label2}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedList: []framework.NodeScore{{Name: "node1", Score: 18}, {Name: "node5", Score: framework.MaxNodeScore}, {Name: "node2", Score: 36}},
 | 
								expectedList: []framework.NodeScore{{Name: "node1", Score: 18}, {Name: "node5", Score: framework.MaxNodeScore}, {Name: "node2", Score: 36}},
 | 
				
			||||||
 | 
								runPreScore:  true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "added affinity",
 | 
								name: "added affinity",
 | 
				
			||||||
@@ -1042,6 +1075,7 @@ func TestNodeAffinityPriority(t *testing.T) {
 | 
				
			|||||||
			args: config.NodeAffinityArgs{
 | 
								args: config.NodeAffinityArgs{
 | 
				
			||||||
				AddedAffinity: affinity1.NodeAffinity,
 | 
									AddedAffinity: affinity1.NodeAffinity,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreScore: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "added affinity and pod has default affinity",
 | 
								name: "added affinity and pod has default affinity",
 | 
				
			||||||
@@ -1074,6 +1108,7 @@ func TestNodeAffinityPriority(t *testing.T) {
 | 
				
			|||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
 | 
								runPreScore: true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name: "calculate the priorities correctly even if PreScore is not called",
 | 
								name: "calculate the priorities correctly even if PreScore is not called",
 | 
				
			||||||
@@ -1087,8 +1122,8 @@ func TestNodeAffinityPriority(t *testing.T) {
 | 
				
			|||||||
				{ObjectMeta: metav1.ObjectMeta{Name: "node5", Labels: label5}},
 | 
									{ObjectMeta: metav1.ObjectMeta{Name: "node5", Labels: label5}},
 | 
				
			||||||
				{ObjectMeta: metav1.ObjectMeta{Name: "node2", Labels: label2}},
 | 
									{ObjectMeta: metav1.ObjectMeta{Name: "node2", Labels: label2}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedList:    []framework.NodeScore{{Name: "node1", Score: 18}, {Name: "node5", Score: framework.MaxNodeScore}, {Name: "node2", Score: 36}},
 | 
								expectedList: []framework.NodeScore{{Name: "node1", Score: 18}, {Name: "node5", Score: framework.MaxNodeScore}, {Name: "node2", Score: 36}},
 | 
				
			||||||
			disablePreScore: true,
 | 
								runPreScore:  true,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1104,7 +1139,7 @@ func TestNodeAffinityPriority(t *testing.T) {
 | 
				
			|||||||
				t.Fatalf("Creating plugin: %v", err)
 | 
									t.Fatalf("Creating plugin: %v", err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			var status *framework.Status
 | 
								var status *framework.Status
 | 
				
			||||||
			if !test.disablePreScore {
 | 
								if test.runPreScore {
 | 
				
			||||||
				status = p.(framework.PreScorePlugin).PreScore(ctx, state, test.pod, test.nodes)
 | 
									status = p.(framework.PreScorePlugin).PreScore(ctx, state, test.pod, test.nodes)
 | 
				
			||||||
				if !status.IsSuccess() {
 | 
									if !status.IsSuccess() {
 | 
				
			||||||
					t.Errorf("unexpected error: %v", status)
 | 
										t.Errorf("unexpected error: %v", status)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -390,7 +390,7 @@ func TestNodeResourcesBalancedAllocation(t *testing.T) {
 | 
				
			|||||||
			p, _ := NewBalancedAllocation(&test.args, fh, feature.Features{})
 | 
								p, _ := NewBalancedAllocation(&test.args, fh, feature.Features{})
 | 
				
			||||||
			state := framework.NewCycleState()
 | 
								state := framework.NewCycleState()
 | 
				
			||||||
			for i := range test.nodes {
 | 
								for i := range test.nodes {
 | 
				
			||||||
				if !test.runPreScore {
 | 
									if test.runPreScore {
 | 
				
			||||||
					status := p.(framework.PreScorePlugin).PreScore(ctx, state, test.pod, test.nodes)
 | 
										status := p.(framework.PreScorePlugin).PreScore(ctx, state, test.pod, test.nodes)
 | 
				
			||||||
					if !status.IsSuccess() {
 | 
										if !status.IsSuccess() {
 | 
				
			||||||
						t.Errorf("PreScore is expected to return success, but didn't. Got status: %v", status)
 | 
											t.Errorf("PreScore is expected to return success, but didn't. Got status: %v", status)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -839,7 +839,7 @@ func TestFitScore(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			var gotPriorities framework.NodeScoreList
 | 
								var gotPriorities framework.NodeScoreList
 | 
				
			||||||
			for _, n := range test.nodes {
 | 
								for _, n := range test.nodes {
 | 
				
			||||||
				if !test.runPreScore {
 | 
									if test.runPreScore {
 | 
				
			||||||
					status := p.(framework.PreScorePlugin).PreScore(ctx, state, test.requestedPod, test.nodes)
 | 
										status := p.(framework.PreScorePlugin).PreScore(ctx, state, test.requestedPod, test.nodes)
 | 
				
			||||||
					if !status.IsSuccess() {
 | 
										if !status.IsSuccess() {
 | 
				
			||||||
						t.Errorf("PreScore is expected to return success, but didn't. Got status: %v", status)
 | 
											t.Errorf("PreScore is expected to return success, but didn't. Got status: %v", status)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user