mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-12-09 11:04:46 +00:00
Add test
This commit is contained in:
@@ -388,7 +388,7 @@ func (pl *InterPodAffinity) RemovePod(ctx context.Context, cycleState *framework
|
||||
func getPreFilterState(cycleState *framework.CycleState) (*preFilterState, error) {
|
||||
c, err := cycleState.Read(preFilterStateKey)
|
||||
if err != nil {
|
||||
// The preFilterState wasn't pre-computed in prefilter.
|
||||
// preFilterState doesn't exist, likely PreFilter wasn't invoked.
|
||||
return nil, fmt.Errorf("error reading %q from cycleState: %v", preFilterStateKey, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -1634,6 +1634,20 @@ func TestRequiredAffinityMultipleNodes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreFilterDisabled(t *testing.T) {
|
||||
pod := &v1.Pod{}
|
||||
nodeInfo := nodeinfo.NewNodeInfo()
|
||||
node := v1.Node{}
|
||||
nodeInfo.SetNode(&node)
|
||||
p := &InterPodAffinity{}
|
||||
cycleState := framework.NewCycleState()
|
||||
gotStatus := p.Filter(context.Background(), cycleState, pod, nodeInfo)
|
||||
wantStatus := framework.NewStatus(framework.Error, `error reading "PreFilterInterPodAffinity" from cycleState: not found`)
|
||||
if !reflect.DeepEqual(gotStatus, wantStatus) {
|
||||
t.Errorf("status does not match: %v, want: %v", gotStatus, wantStatus)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreFilterStateAddRemovePod(t *testing.T) {
|
||||
var label1 = map[string]string{
|
||||
"region": "r1",
|
||||
|
||||
Reference in New Issue
Block a user