mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 02:08:13 +00:00 
			
		
		
		
	Added InterPodAffinity unit test case with Namespace.
This commit is contained in:
		| @@ -2887,6 +2887,78 @@ func TestInterPodAffinityWithMultipleNodes(t *testing.T) { | ||||
| 			test:   "NodeA and nodeB have same topologyKey and label value. NodeA has an existing pod that match the inter pod affinity rule. NodeC has an existing pod that match the inter pod affinity rule. The pod can not be scheduled onto nodeA, nodeB and nodeC but can be schedulerd onto nodeD", | ||||
| 			nometa: true, | ||||
| 		}, | ||||
| 		{ | ||||
| 			pod: &v1.Pod{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Labels:    map[string]string{"foo": "123"}, | ||||
| 					Namespace: "NS1", | ||||
| 				}, | ||||
| 				Spec: v1.PodSpec{ | ||||
| 					Affinity: &v1.Affinity{ | ||||
| 						PodAntiAffinity: &v1.PodAntiAffinity{ | ||||
| 							RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ | ||||
| 								{ | ||||
| 									LabelSelector: &metav1.LabelSelector{ | ||||
| 										MatchExpressions: []metav1.LabelSelectorRequirement{ | ||||
| 											{ | ||||
| 												Key:      "foo", | ||||
| 												Operator: metav1.LabelSelectorOpIn, | ||||
| 												Values:   []string{"bar"}, | ||||
| 											}, | ||||
| 										}, | ||||
| 									}, | ||||
| 									TopologyKey: "region", | ||||
| 								}, | ||||
| 							}, | ||||
| 						}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			pods: []*v1.Pod{ | ||||
| 				{ | ||||
| 					ObjectMeta: metav1.ObjectMeta{ | ||||
| 						Labels:    map[string]string{"foo": "bar"}, | ||||
| 						Namespace: "NS1", | ||||
| 					}, | ||||
| 					Spec: v1.PodSpec{NodeName: "nodeA"}, | ||||
| 				}, | ||||
| 				{ | ||||
| 					ObjectMeta: metav1.ObjectMeta{Namespace: "NS2"}, | ||||
| 					Spec: v1.PodSpec{ | ||||
| 						NodeName: "nodeC", | ||||
| 						Affinity: &v1.Affinity{ | ||||
| 							PodAntiAffinity: &v1.PodAntiAffinity{ | ||||
| 								RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{ | ||||
| 									{ | ||||
| 										LabelSelector: &metav1.LabelSelector{ | ||||
| 											MatchExpressions: []metav1.LabelSelectorRequirement{ | ||||
| 												{ | ||||
| 													Key:      "foo", | ||||
| 													Operator: metav1.LabelSelectorOpIn, | ||||
| 													Values:   []string{"123"}, | ||||
| 												}, | ||||
| 											}, | ||||
| 										}, | ||||
| 										TopologyKey: "region", | ||||
| 									}, | ||||
| 								}, | ||||
| 							}, | ||||
| 						}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			nodes: []v1.Node{ | ||||
| 				{ObjectMeta: metav1.ObjectMeta{Name: "nodeA", Labels: labelRgChina}}, | ||||
| 				{ObjectMeta: metav1.ObjectMeta{Name: "nodeB", Labels: labelRgChinaAzAz1}}, | ||||
| 				{ObjectMeta: metav1.ObjectMeta{Name: "nodeC", Labels: labelRgIndia}}, | ||||
| 			}, | ||||
| 			fits: map[string]bool{ | ||||
| 				"nodeA": false, | ||||
| 				"nodeB": false, | ||||
| 				"nodeC": true, | ||||
| 			}, | ||||
| 			test: "NodeA and nodeB have same topologyKey and label value. NodeA has an existing pod that match the inter pod affinity rule. The pod can not be scheduled onto nodeA, nodeB, but can be schedulerd onto nodeC (NodeC has an existing pod that match the inter pod affinity rule but in different namespace)", | ||||
| 		}, | ||||
| 	} | ||||
| 	affinityExpectedFailureReasons := []algorithm.PredicateFailureReason{ErrPodAffinityNotMatch} | ||||
| 	selectorExpectedFailureReasons := []algorithm.PredicateFailureReason{ErrNodeSelectorNotMatch} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Klaus Ma
					Klaus Ma