reuse fake topology manager
This commit is contained in:
		@@ -44,7 +44,6 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/kubelet/config"
 | 
						"k8s.io/kubernetes/pkg/kubelet/config"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/lifecycle"
 | 
						"k8s.io/kubernetes/pkg/kubelet/lifecycle"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/pluginmanager"
 | 
						"k8s.io/kubernetes/pkg/kubelet/pluginmanager"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/util/format"
 | 
					 | 
				
			||||||
	schedulerframework "k8s.io/kubernetes/pkg/scheduler/framework"
 | 
						schedulerframework "k8s.io/kubernetes/pkg/scheduler/framework"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -727,7 +726,7 @@ func TestFilterByAffinity(t *testing.T) {
 | 
				
			|||||||
		Preferred:        true,
 | 
							Preferred:        true,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	testManager := ManagerImpl{
 | 
						testManager := ManagerImpl{
 | 
				
			||||||
		topologyAffinityStore: NewFakeTopologyManagerWithHint(t, &fakeHint),
 | 
							topologyAffinityStore: topologymanager.NewFakeManagerWithHint(&fakeHint),
 | 
				
			||||||
		allDevices:            allDevices,
 | 
							allDevices:            allDevices,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -764,39 +763,6 @@ type fakeTopologyManagerWithHint struct {
 | 
				
			|||||||
	hint *topologymanager.TopologyHint
 | 
						hint *topologymanager.TopologyHint
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewFakeTopologyManagerWithHint returns an instance of fake topology manager with specified topology hints
 | 
					 | 
				
			||||||
func NewFakeTopologyManagerWithHint(t *testing.T, hint *topologymanager.TopologyHint) topologymanager.Manager {
 | 
					 | 
				
			||||||
	return &fakeTopologyManagerWithHint{
 | 
					 | 
				
			||||||
		t:    t,
 | 
					 | 
				
			||||||
		hint: hint,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (m *fakeTopologyManagerWithHint) AddHintProvider(h topologymanager.HintProvider) {
 | 
					 | 
				
			||||||
	m.t.Logf("[fake topologymanager] AddHintProvider HintProvider:  %v", h)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (m *fakeTopologyManagerWithHint) AddContainer(pod *v1.Pod, container *v1.Container, containerID string) {
 | 
					 | 
				
			||||||
	m.t.Logf("[fake topologymanager] AddContainer  pod: %v container name: %v container id:  %v", format.Pod(pod), container.Name, containerID)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (m *fakeTopologyManagerWithHint) RemoveContainer(containerID string) error {
 | 
					 | 
				
			||||||
	m.t.Logf("[fake topologymanager] RemoveContainer container id:  %v", containerID)
 | 
					 | 
				
			||||||
	return nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (m *fakeTopologyManagerWithHint) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAdmitResult {
 | 
					 | 
				
			||||||
	m.t.Logf("[fake topologymanager] Topology Admit Handler")
 | 
					 | 
				
			||||||
	return lifecycle.PodAdmitResult{
 | 
					 | 
				
			||||||
		Admit: true,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (m *fakeTopologyManagerWithHint) GetAffinity(podUID string, containerName string) topologymanager.TopologyHint {
 | 
					 | 
				
			||||||
	m.t.Logf("[fake topologymanager] GetAffinity podUID: %v container name:  %v", podUID, containerName)
 | 
					 | 
				
			||||||
	return *m.hint
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestPodContainerDeviceAllocation(t *testing.T) {
 | 
					func TestPodContainerDeviceAllocation(t *testing.T) {
 | 
				
			||||||
	res1 := TestResource{
 | 
						res1 := TestResource{
 | 
				
			||||||
		resourceName:     "domain1.com/resource1",
 | 
							resourceName:     "domain1.com/resource1",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,8 +28,6 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/kubelet/cm/memorymanager/state"
 | 
						"k8s.io/kubernetes/pkg/kubelet/cm/memorymanager/state"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager"
 | 
						"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager/bitmask"
 | 
						"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager/bitmask"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/lifecycle"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubelet/util/format"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@@ -66,44 +64,6 @@ var (
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type fakeTopologyManagerWithHint struct {
 | 
					 | 
				
			||||||
	t    *testing.T
 | 
					 | 
				
			||||||
	hint *topologymanager.TopologyHint
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// NewFakeTopologyManagerWithHint returns an instance of fake topology manager with specified topology hints
 | 
					 | 
				
			||||||
func NewFakeTopologyManagerWithHint(t *testing.T, hint *topologymanager.TopologyHint) topologymanager.Manager {
 | 
					 | 
				
			||||||
	return &fakeTopologyManagerWithHint{
 | 
					 | 
				
			||||||
		t:    t,
 | 
					 | 
				
			||||||
		hint: hint,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (m *fakeTopologyManagerWithHint) AddHintProvider(h topologymanager.HintProvider) {
 | 
					 | 
				
			||||||
	m.t.Logf("[fake topologymanager] AddHintProvider HintProvider:  %v", h)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (m *fakeTopologyManagerWithHint) AddContainer(pod *v1.Pod, container *v1.Container, containerID string) {
 | 
					 | 
				
			||||||
	m.t.Logf("[fake topologymanager] AddContainer  pod: %v container name: %v container id:  %v", format.Pod(pod), container.Name, containerID)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (m *fakeTopologyManagerWithHint) RemoveContainer(containerID string) error {
 | 
					 | 
				
			||||||
	m.t.Logf("[fake topologymanager] RemoveContainer container id:  %v", containerID)
 | 
					 | 
				
			||||||
	return nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (m *fakeTopologyManagerWithHint) Admit(attrs *lifecycle.PodAdmitAttributes) lifecycle.PodAdmitResult {
 | 
					 | 
				
			||||||
	m.t.Logf("[fake topologymanager] Topology Admit Handler")
 | 
					 | 
				
			||||||
	return lifecycle.PodAdmitResult{
 | 
					 | 
				
			||||||
		Admit: true,
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (m *fakeTopologyManagerWithHint) GetAffinity(podUID string, containerName string) topologymanager.TopologyHint {
 | 
					 | 
				
			||||||
	m.t.Logf("[fake topologymanager] GetAffinity podUID: %v container name:  %v", podUID, containerName)
 | 
					 | 
				
			||||||
	return *m.hint
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func areMemoryBlocksEqual(mb1, mb2 []state.Block) bool {
 | 
					func areMemoryBlocksEqual(mb1, mb2 []state.Block) bool {
 | 
				
			||||||
	if len(mb1) != len(mb2) {
 | 
						if len(mb1) != len(mb2) {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
@@ -171,7 +131,7 @@ type testStaticPolicy struct {
 | 
				
			|||||||
func initTests(t *testing.T, testCase *testStaticPolicy, hint *topologymanager.TopologyHint) (Policy, state.State, error) {
 | 
					func initTests(t *testing.T, testCase *testStaticPolicy, hint *topologymanager.TopologyHint) (Policy, state.State, error) {
 | 
				
			||||||
	manager := topologymanager.NewFakeManager()
 | 
						manager := topologymanager.NewFakeManager()
 | 
				
			||||||
	if hint != nil {
 | 
						if hint != nil {
 | 
				
			||||||
		manager = NewFakeTopologyManagerWithHint(t, hint)
 | 
							manager = topologymanager.NewFakeManagerWithHint(hint)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p, err := NewPolicyStatic(testCase.machineInfo, testCase.systemReserved, manager)
 | 
						p, err := NewPolicyStatic(testCase.machineInfo, testCase.systemReserved, manager)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user