mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
rename scheduler fake listers
Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
This commit is contained in:
parent
51c8bd3113
commit
b86dbb97df
@ -453,10 +453,10 @@ func TestCSIVolumeCountPredicate(t *testing.T) {
|
|||||||
expectedFailureReasons = []PredicateFailureReason{test.expectedFailureReason}
|
expectedFailureReasons = []PredicateFailureReason{test.expectedFailureReason}
|
||||||
}
|
}
|
||||||
|
|
||||||
pred := NewCSIMaxVolumeLimitPredicate(getFakeCSINodeInfo(csiNode),
|
pred := NewCSIMaxVolumeLimitPredicate(getFakeCSINodeLister(csiNode),
|
||||||
getFakeCSIPVInfo(test.filterName, test.driverNames...),
|
getFakeCSIPVLister(test.filterName, test.driverNames...),
|
||||||
getFakeCSIPVCInfo(test.filterName, "csi-sc", test.driverNames...),
|
getFakeCSIPVCLister(test.filterName, "csi-sc", test.driverNames...),
|
||||||
getFakeCSIStorageClassInfo("csi-sc", test.driverNames[0]))
|
getFakeCSIStorageClassLister("csi-sc", test.driverNames[0]))
|
||||||
|
|
||||||
fits, reasons, err := pred(test.newPod, GetPredicateMetadata(test.newPod, nil), node)
|
fits, reasons, err := pred(test.newPod, GetPredicateMetadata(test.newPod, nil), node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -472,8 +472,8 @@ func TestCSIVolumeCountPredicate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakeCSIPVInfo(volumeName string, driverNames ...string) fakelisters.PersistentVolumeInfo {
|
func getFakeCSIPVLister(volumeName string, driverNames ...string) fakelisters.PersistentVolumeLister {
|
||||||
pvInfos := fakelisters.PersistentVolumeInfo{}
|
pvLister := fakelisters.PersistentVolumeLister{}
|
||||||
for _, driver := range driverNames {
|
for _, driver := range driverNames {
|
||||||
for j := 0; j < 4; j++ {
|
for j := 0; j < 4; j++ {
|
||||||
volumeHandle := fmt.Sprintf("%s-%s-%d", volumeName, driver, j)
|
volumeHandle := fmt.Sprintf("%s-%s-%d", volumeName, driver, j)
|
||||||
@ -510,15 +510,15 @@ func getFakeCSIPVInfo(volumeName string, driverNames ...string) fakelisters.Pers
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pvInfos = append(pvInfos, pv)
|
pvLister = append(pvLister, pv)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return pvInfos
|
return pvLister
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakeCSIPVCInfo(volumeName, scName string, driverNames ...string) fakelisters.PersistentVolumeClaimInfo {
|
func getFakeCSIPVCLister(volumeName, scName string, driverNames ...string) fakelisters.PersistentVolumeClaimLister {
|
||||||
pvcInfos := fakelisters.PersistentVolumeClaimInfo{}
|
pvcLister := fakelisters.PersistentVolumeClaimLister{}
|
||||||
for _, driver := range driverNames {
|
for _, driver := range driverNames {
|
||||||
for j := 0; j < 4; j++ {
|
for j := 0; j < 4; j++ {
|
||||||
v := fmt.Sprintf("%s-%s-%d", volumeName, driver, j)
|
v := fmt.Sprintf("%s-%s-%d", volumeName, driver, j)
|
||||||
@ -526,24 +526,24 @@ func getFakeCSIPVCInfo(volumeName, scName string, driverNames ...string) fakelis
|
|||||||
ObjectMeta: metav1.ObjectMeta{Name: v},
|
ObjectMeta: metav1.ObjectMeta{Name: v},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{VolumeName: v},
|
Spec: v1.PersistentVolumeClaimSpec{VolumeName: v},
|
||||||
}
|
}
|
||||||
pvcInfos = append(pvcInfos, pvc)
|
pvcLister = append(pvcLister, pvc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pvcInfos = append(pvcInfos, v1.PersistentVolumeClaim{
|
pvcLister = append(pvcLister, v1.PersistentVolumeClaim{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-4"},
|
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-4"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{StorageClassName: &scName},
|
Spec: v1.PersistentVolumeClaimSpec{StorageClassName: &scName},
|
||||||
})
|
})
|
||||||
pvcInfos = append(pvcInfos, v1.PersistentVolumeClaim{
|
pvcLister = append(pvcLister, v1.PersistentVolumeClaim{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-5"},
|
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-5"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{},
|
Spec: v1.PersistentVolumeClaimSpec{},
|
||||||
})
|
})
|
||||||
// a pvc with missing PV but available storageclass.
|
// a pvc with missing PV but available storageclass.
|
||||||
pvcInfos = append(pvcInfos, v1.PersistentVolumeClaim{
|
pvcLister = append(pvcLister, v1.PersistentVolumeClaim{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-6"},
|
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-6"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{StorageClassName: &scName, VolumeName: "missing-in-action"},
|
Spec: v1.PersistentVolumeClaimSpec{StorageClassName: &scName, VolumeName: "missing-in-action"},
|
||||||
})
|
})
|
||||||
return pvcInfos
|
return pvcLister
|
||||||
}
|
}
|
||||||
|
|
||||||
func enableMigrationOnNode(csiNode *storagev1beta1.CSINode, pluginName string) {
|
func enableMigrationOnNode(csiNode *storagev1beta1.CSINode, pluginName string) {
|
||||||
@ -560,8 +560,8 @@ func enableMigrationOnNode(csiNode *storagev1beta1.CSINode, pluginName string) {
|
|||||||
csiNode.Annotations = nodeInfoAnnotations
|
csiNode.Annotations = nodeInfoAnnotations
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakeCSIStorageClassInfo(scName, provisionerName string) fakelisters.StorageClassInfo {
|
func getFakeCSIStorageClassLister(scName, provisionerName string) fakelisters.StorageClassLister {
|
||||||
return fakelisters.StorageClassInfo{
|
return fakelisters.StorageClassLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: scName},
|
ObjectMeta: metav1.ObjectMeta{Name: scName},
|
||||||
Provisioner: provisionerName,
|
Provisioner: provisionerName,
|
||||||
@ -569,9 +569,9 @@ func getFakeCSIStorageClassInfo(scName, provisionerName string) fakelisters.Stor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakeCSINodeInfo(csiNode *storagev1beta1.CSINode) fakelisters.CSINodeInfo {
|
func getFakeCSINodeLister(csiNode *storagev1beta1.CSINode) fakelisters.CSINodeLister {
|
||||||
if csiNode != nil {
|
if csiNode != nil {
|
||||||
return fakelisters.CSINodeInfo(*csiNode)
|
return fakelisters.CSINodeLister(*csiNode)
|
||||||
}
|
}
|
||||||
return fakelisters.CSINodeInfo{}
|
return fakelisters.CSINodeLister{}
|
||||||
}
|
}
|
||||||
|
@ -853,10 +853,10 @@ func TestVolumeCountConflicts(t *testing.T) {
|
|||||||
os.Setenv(KubeMaxPDVols, strconv.Itoa(test.maxVols))
|
os.Setenv(KubeMaxPDVols, strconv.Itoa(test.maxVols))
|
||||||
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
||||||
pred := NewMaxPDVolumeCountPredicate(test.filterName,
|
pred := NewMaxPDVolumeCountPredicate(test.filterName,
|
||||||
getFakeCSINodeInfo(csiNode),
|
getFakeCSINodeLister(csiNode),
|
||||||
getFakeStorageClassInfo(test.filterName),
|
getFakeStorageClassLister(test.filterName),
|
||||||
getFakePVInfo(test.filterName),
|
getFakePVLister(test.filterName),
|
||||||
getFakePVCInfo(test.filterName))
|
getFakePVCLister(test.filterName))
|
||||||
|
|
||||||
fits, reasons, err := pred(test.newPod, GetPredicateMetadata(test.newPod, nil), node)
|
fits, reasons, err := pred(test.newPod, GetPredicateMetadata(test.newPod, nil), node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -876,10 +876,10 @@ func TestVolumeCountConflicts(t *testing.T) {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
||||||
pred := NewMaxPDVolumeCountPredicate(test.filterName,
|
pred := NewMaxPDVolumeCountPredicate(test.filterName,
|
||||||
getFakeCSINodeInfo(csiNode),
|
getFakeCSINodeLister(csiNode),
|
||||||
getFakeStorageClassInfo(test.filterName),
|
getFakeStorageClassLister(test.filterName),
|
||||||
getFakePVInfo(test.filterName),
|
getFakePVLister(test.filterName),
|
||||||
getFakePVCInfo(test.filterName))
|
getFakePVCLister(test.filterName))
|
||||||
fits, reasons, err := pred(test.newPod, GetPredicateMetadata(test.newPod, nil), node)
|
fits, reasons, err := pred(test.newPod, GetPredicateMetadata(test.newPod, nil), node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Using allocatable [%s]%s: unexpected error: %v", test.filterName, test.test, err)
|
t.Errorf("Using allocatable [%s]%s: unexpected error: %v", test.filterName, test.test, err)
|
||||||
@ -893,7 +893,7 @@ func TestVolumeCountConflicts(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakeStorageClassInfo(sc string) fakelisters.StorageClassInfo {
|
func getFakeStorageClassLister(sc string) fakelisters.StorageClassLister {
|
||||||
var provisioner string
|
var provisioner string
|
||||||
switch sc {
|
switch sc {
|
||||||
case EBSVolumeFilterType:
|
case EBSVolumeFilterType:
|
||||||
@ -905,9 +905,9 @@ func getFakeStorageClassInfo(sc string) fakelisters.StorageClassInfo {
|
|||||||
case CinderVolumeFilterType:
|
case CinderVolumeFilterType:
|
||||||
provisioner = csilibplugins.CinderInTreePluginName
|
provisioner = csilibplugins.CinderInTreePluginName
|
||||||
default:
|
default:
|
||||||
return fakelisters.StorageClassInfo{}
|
return fakelisters.StorageClassLister{}
|
||||||
}
|
}
|
||||||
return fakelisters.StorageClassInfo{
|
return fakelisters.StorageClassLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: sc},
|
ObjectMeta: metav1.ObjectMeta{Name: sc},
|
||||||
Provisioner: provisioner,
|
Provisioner: provisioner,
|
||||||
@ -919,8 +919,8 @@ func getFakeStorageClassInfo(sc string) fakelisters.StorageClassInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakePVInfo(filterName string) fakelisters.PersistentVolumeInfo {
|
func getFakePVLister(filterName string) fakelisters.PersistentVolumeLister {
|
||||||
return fakelisters.PersistentVolumeInfo{
|
return fakelisters.PersistentVolumeLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "some" + filterName + "Vol"},
|
ObjectMeta: metav1.ObjectMeta{Name: "some" + filterName + "Vol"},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
@ -938,8 +938,8 @@ func getFakePVInfo(filterName string) fakelisters.PersistentVolumeInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakePVCInfo(filterName string) fakelisters.PersistentVolumeClaimInfo {
|
func getFakePVCLister(filterName string) fakelisters.PersistentVolumeClaimLister {
|
||||||
return fakelisters.PersistentVolumeClaimInfo{
|
return fakelisters.PersistentVolumeClaimLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "some" + filterName + "Vol"},
|
ObjectMeta: metav1.ObjectMeta{Name: "some" + filterName + "Vol"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{
|
Spec: v1.PersistentVolumeClaimSpec{
|
||||||
|
@ -4302,7 +4302,7 @@ func createPodWithVolume(pod, pv, pvc string) *v1.Pod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestVolumeZonePredicate(t *testing.T) {
|
func TestVolumeZonePredicate(t *testing.T) {
|
||||||
pvInfo := fakelisters.PersistentVolumeInfo{
|
pvLister := fakelisters.PersistentVolumeLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
||||||
},
|
},
|
||||||
@ -4314,7 +4314,7 @@ func TestVolumeZonePredicate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pvcInfo := fakelisters.PersistentVolumeClaimInfo{
|
pvcLister := fakelisters.PersistentVolumeClaimLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
||||||
@ -4412,7 +4412,7 @@ func TestVolumeZonePredicate(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
fit := NewVolumeZonePredicate(pvInfo, pvcInfo, nil)
|
fit := NewVolumeZonePredicate(pvLister, pvcLister, nil)
|
||||||
node := &schedulernodeinfo.NodeInfo{}
|
node := &schedulernodeinfo.NodeInfo{}
|
||||||
node.SetNode(test.Node)
|
node.SetNode(test.Node)
|
||||||
|
|
||||||
@ -4431,7 +4431,7 @@ func TestVolumeZonePredicate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestVolumeZonePredicateMultiZone(t *testing.T) {
|
func TestVolumeZonePredicateMultiZone(t *testing.T) {
|
||||||
pvInfo := fakelisters.PersistentVolumeInfo{
|
pvLister := fakelisters.PersistentVolumeLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
||||||
},
|
},
|
||||||
@ -4443,7 +4443,7 @@ func TestVolumeZonePredicateMultiZone(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pvcInfo := fakelisters.PersistentVolumeClaimInfo{
|
pvcLister := fakelisters.PersistentVolumeClaimLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
||||||
@ -4506,7 +4506,7 @@ func TestVolumeZonePredicateMultiZone(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
fit := NewVolumeZonePredicate(pvInfo, pvcInfo, nil)
|
fit := NewVolumeZonePredicate(pvLister, pvcLister, nil)
|
||||||
node := &schedulernodeinfo.NodeInfo{}
|
node := &schedulernodeinfo.NodeInfo{}
|
||||||
node.SetNode(test.Node)
|
node.SetNode(test.Node)
|
||||||
|
|
||||||
@ -4533,7 +4533,7 @@ func TestVolumeZonePredicateWithVolumeBinding(t *testing.T) {
|
|||||||
classImmediate = "Class_Immediate"
|
classImmediate = "Class_Immediate"
|
||||||
)
|
)
|
||||||
|
|
||||||
classInfo := fakelisters.StorageClassInfo{
|
scLister := fakelisters.StorageClassLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: classImmediate},
|
ObjectMeta: metav1.ObjectMeta{Name: classImmediate},
|
||||||
},
|
},
|
||||||
@ -4543,13 +4543,13 @@ func TestVolumeZonePredicateWithVolumeBinding(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pvInfo := fakelisters.PersistentVolumeInfo{
|
pvLister := fakelisters.PersistentVolumeLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pvcInfo := fakelisters.PersistentVolumeClaimInfo{
|
pvcLister := fakelisters.PersistentVolumeClaimLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
||||||
@ -4622,7 +4622,7 @@ func TestVolumeZonePredicateWithVolumeBinding(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
fit := NewVolumeZonePredicate(pvInfo, pvcInfo, classInfo)
|
fit := NewVolumeZonePredicate(pvLister, pvcLister, scLister)
|
||||||
node := &schedulernodeinfo.NodeInfo{}
|
node := &schedulernodeinfo.NodeInfo{}
|
||||||
node.SetNode(test.Node)
|
node.SetNode(test.Node)
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ func TestGenericScheduler(t *testing.T) {
|
|||||||
prioritizers []priorities.PriorityConfig
|
prioritizers []priorities.PriorityConfig
|
||||||
alwaysCheckAllPredicates bool
|
alwaysCheckAllPredicates bool
|
||||||
nodes []string
|
nodes []string
|
||||||
pvcs []*v1.PersistentVolumeClaim
|
pvcs []v1.PersistentVolumeClaim
|
||||||
pod *v1.Pod
|
pod *v1.Pod
|
||||||
pods []*v1.Pod
|
pods []*v1.Pod
|
||||||
buildPredMeta bool // build predicates metadata or not
|
buildPredMeta bool // build predicates metadata or not
|
||||||
@ -404,7 +404,7 @@ func TestGenericScheduler(t *testing.T) {
|
|||||||
predicates: map[string]algorithmpredicates.FitPredicate{"true": truePredicate},
|
predicates: map[string]algorithmpredicates.FitPredicate{"true": truePredicate},
|
||||||
prioritizers: []priorities.PriorityConfig{{Map: EqualPriorityMap, Weight: 1}},
|
prioritizers: []priorities.PriorityConfig{{Map: EqualPriorityMap, Weight: 1}},
|
||||||
nodes: []string{"machine1", "machine2"},
|
nodes: []string{"machine1", "machine2"},
|
||||||
pvcs: []*v1.PersistentVolumeClaim{{ObjectMeta: metav1.ObjectMeta{Name: "existingPVC"}}},
|
pvcs: []v1.PersistentVolumeClaim{{ObjectMeta: metav1.ObjectMeta{Name: "existingPVC"}}},
|
||||||
pod: &v1.Pod{
|
pod: &v1.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "ignore", UID: types.UID("ignore")},
|
ObjectMeta: metav1.ObjectMeta{Name: "ignore", UID: types.UID("ignore")},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
@ -450,7 +450,7 @@ func TestGenericScheduler(t *testing.T) {
|
|||||||
predicates: map[string]algorithmpredicates.FitPredicate{"true": truePredicate},
|
predicates: map[string]algorithmpredicates.FitPredicate{"true": truePredicate},
|
||||||
prioritizers: []priorities.PriorityConfig{{Map: EqualPriorityMap, Weight: 1}},
|
prioritizers: []priorities.PriorityConfig{{Map: EqualPriorityMap, Weight: 1}},
|
||||||
nodes: []string{"machine1", "machine2"},
|
nodes: []string{"machine1", "machine2"},
|
||||||
pvcs: []*v1.PersistentVolumeClaim{{ObjectMeta: metav1.ObjectMeta{Name: "existingPVC", DeletionTimestamp: &metav1.Time{}}}},
|
pvcs: []v1.PersistentVolumeClaim{{ObjectMeta: metav1.ObjectMeta{Name: "existingPVC", DeletionTimestamp: &metav1.Time{}}}},
|
||||||
pod: &v1.Pod{
|
pod: &v1.Pod{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "ignore", UID: types.UID("ignore")},
|
ObjectMeta: metav1.ObjectMeta{Name: "ignore", UID: types.UID("ignore")},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
@ -654,7 +654,7 @@ func TestGenericScheduler(t *testing.T) {
|
|||||||
for _, name := range test.nodes {
|
for _, name := range test.nodes {
|
||||||
cache.AddNode(&v1.Node{ObjectMeta: metav1.ObjectMeta{Name: name, Labels: map[string]string{"hostname": name}}})
|
cache.AddNode(&v1.Node{ObjectMeta: metav1.ObjectMeta{Name: name, Labels: map[string]string{"hostname": name}}})
|
||||||
}
|
}
|
||||||
pvcs := []*v1.PersistentVolumeClaim{}
|
pvcs := []v1.PersistentVolumeClaim{}
|
||||||
pvcs = append(pvcs, test.pvcs...)
|
pvcs = append(pvcs, test.pvcs...)
|
||||||
|
|
||||||
pvcLister := fakelisters.PersistentVolumeClaimLister(pvcs)
|
pvcLister := fakelisters.PersistentVolumeClaimLister(pvcs)
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
@ -361,7 +361,7 @@ func TestAzureDiskLimits(t *testing.T) {
|
|||||||
t.Run(test.test, func(t *testing.T) {
|
t.Run(test.test, func(t *testing.T) {
|
||||||
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
||||||
p := &AzureDiskLimits{
|
p := &AzureDiskLimits{
|
||||||
predicate: predicates.NewMaxPDVolumeCountPredicate(test.filterName, getFakeCSINodeInfo(csiNode), getFakeCSIStorageClassInfo(test.filterName, test.driverName), getFakePVInfo(test.filterName), getFakePVCInfo(test.filterName)),
|
predicate: predicates.NewMaxPDVolumeCountPredicate(test.filterName, getFakeCSINodeLister(csiNode), getFakeCSIStorageClassLister(test.filterName, test.driverName), getFakePVLister(test.filterName), getFakePVCLister(test.filterName)),
|
||||||
}
|
}
|
||||||
gotStatus := p.Filter(context.Background(), nil, test.newPod, node)
|
gotStatus := p.Filter(context.Background(), nil, test.newPod, node)
|
||||||
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
@ -90,7 +90,7 @@ func TestCinderLimits(t *testing.T) {
|
|||||||
t.Run(test.test, func(t *testing.T) {
|
t.Run(test.test, func(t *testing.T) {
|
||||||
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
||||||
p := &CinderLimits{
|
p := &CinderLimits{
|
||||||
predicate: predicates.NewMaxPDVolumeCountPredicate(test.filterName, getFakeCSINodeInfo(csiNode), getFakeCSIStorageClassInfo(test.filterName, test.driverName), getFakePVInfo(test.filterName), getFakePVCInfo(test.filterName)),
|
predicate: predicates.NewMaxPDVolumeCountPredicate(test.filterName, getFakeCSINodeLister(csiNode), getFakeCSIStorageClassLister(test.filterName, test.driverName), getFakePVLister(test.filterName), getFakePVCLister(test.filterName)),
|
||||||
}
|
}
|
||||||
gotStatus := p.Filter(context.Background(), nil, test.newPod, node)
|
gotStatus := p.Filter(context.Background(), nil, test.newPod, node)
|
||||||
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
||||||
|
@ -462,7 +462,7 @@ func TestCSILimits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p := &CSILimits{
|
p := &CSILimits{
|
||||||
predicate: predicates.NewCSIMaxVolumeLimitPredicate(getFakeCSINodeInfo(csiNode), getFakeCSIPVInfo(test.filterName, test.driverNames...), getFakeCSIPVCInfo(test.filterName, "csi-sc", test.driverNames...), getFakeCSIStorageClassInfo("csi-sc", test.driverNames[0])),
|
predicate: predicates.NewCSIMaxVolumeLimitPredicate(getFakeCSINodeLister(csiNode), getFakeCSIPVLister(test.filterName, test.driverNames...), getFakeCSIPVCLister(test.filterName, "csi-sc", test.driverNames...), getFakeCSIStorageClassLister("csi-sc", test.driverNames[0])),
|
||||||
}
|
}
|
||||||
gotStatus := p.Filter(context.Background(), nil, test.newPod, node)
|
gotStatus := p.Filter(context.Background(), nil, test.newPod, node)
|
||||||
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
||||||
@ -472,8 +472,8 @@ func TestCSILimits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakeCSIPVInfo(volumeName string, driverNames ...string) fakelisters.PersistentVolumeInfo {
|
func getFakeCSIPVLister(volumeName string, driverNames ...string) fakelisters.PersistentVolumeLister {
|
||||||
pvInfos := fakelisters.PersistentVolumeInfo{}
|
pvLister := fakelisters.PersistentVolumeLister{}
|
||||||
for _, driver := range driverNames {
|
for _, driver := range driverNames {
|
||||||
for j := 0; j < 4; j++ {
|
for j := 0; j < 4; j++ {
|
||||||
volumeHandle := fmt.Sprintf("%s-%s-%d", volumeName, driver, j)
|
volumeHandle := fmt.Sprintf("%s-%s-%d", volumeName, driver, j)
|
||||||
@ -510,15 +510,15 @@ func getFakeCSIPVInfo(volumeName string, driverNames ...string) fakelisters.Pers
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pvInfos = append(pvInfos, pv)
|
pvLister = append(pvLister, pv)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return pvInfos
|
return pvLister
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakeCSIPVCInfo(volumeName, scName string, driverNames ...string) fakelisters.PersistentVolumeClaimInfo {
|
func getFakeCSIPVCLister(volumeName, scName string, driverNames ...string) fakelisters.PersistentVolumeClaimLister {
|
||||||
pvcInfos := fakelisters.PersistentVolumeClaimInfo{}
|
pvcLister := fakelisters.PersistentVolumeClaimLister{}
|
||||||
for _, driver := range driverNames {
|
for _, driver := range driverNames {
|
||||||
for j := 0; j < 4; j++ {
|
for j := 0; j < 4; j++ {
|
||||||
v := fmt.Sprintf("%s-%s-%d", volumeName, driver, j)
|
v := fmt.Sprintf("%s-%s-%d", volumeName, driver, j)
|
||||||
@ -526,24 +526,24 @@ func getFakeCSIPVCInfo(volumeName, scName string, driverNames ...string) fakelis
|
|||||||
ObjectMeta: metav1.ObjectMeta{Name: v},
|
ObjectMeta: metav1.ObjectMeta{Name: v},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{VolumeName: v},
|
Spec: v1.PersistentVolumeClaimSpec{VolumeName: v},
|
||||||
}
|
}
|
||||||
pvcInfos = append(pvcInfos, pvc)
|
pvcLister = append(pvcLister, pvc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pvcInfos = append(pvcInfos, v1.PersistentVolumeClaim{
|
pvcLister = append(pvcLister, v1.PersistentVolumeClaim{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-4"},
|
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-4"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{StorageClassName: &scName},
|
Spec: v1.PersistentVolumeClaimSpec{StorageClassName: &scName},
|
||||||
})
|
})
|
||||||
pvcInfos = append(pvcInfos, v1.PersistentVolumeClaim{
|
pvcLister = append(pvcLister, v1.PersistentVolumeClaim{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-5"},
|
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-5"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{},
|
Spec: v1.PersistentVolumeClaimSpec{},
|
||||||
})
|
})
|
||||||
// a pvc with missing PV but available storageclass.
|
// a pvc with missing PV but available storageclass.
|
||||||
pvcInfos = append(pvcInfos, v1.PersistentVolumeClaim{
|
pvcLister = append(pvcLister, v1.PersistentVolumeClaim{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-6"},
|
ObjectMeta: metav1.ObjectMeta{Name: volumeName + "-6"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{StorageClassName: &scName, VolumeName: "missing-in-action"},
|
Spec: v1.PersistentVolumeClaimSpec{StorageClassName: &scName, VolumeName: "missing-in-action"},
|
||||||
})
|
})
|
||||||
return pvcInfos
|
return pvcLister
|
||||||
}
|
}
|
||||||
|
|
||||||
func enableMigrationOnNode(csiNode *storagev1beta1.CSINode, pluginName string) {
|
func enableMigrationOnNode(csiNode *storagev1beta1.CSINode, pluginName string) {
|
||||||
@ -560,8 +560,8 @@ func enableMigrationOnNode(csiNode *storagev1beta1.CSINode, pluginName string) {
|
|||||||
csiNode.Annotations = nodeInfoAnnotations
|
csiNode.Annotations = nodeInfoAnnotations
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakeCSIStorageClassInfo(scName, provisionerName string) fakelisters.StorageClassInfo {
|
func getFakeCSIStorageClassLister(scName, provisionerName string) fakelisters.StorageClassLister {
|
||||||
return fakelisters.StorageClassInfo{
|
return fakelisters.StorageClassLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: scName},
|
ObjectMeta: metav1.ObjectMeta{Name: scName},
|
||||||
Provisioner: provisionerName,
|
Provisioner: provisionerName,
|
||||||
@ -569,11 +569,11 @@ func getFakeCSIStorageClassInfo(scName, provisionerName string) fakelisters.Stor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakeCSINodeInfo(csiNode *storagev1beta1.CSINode) fakelisters.CSINodeInfo {
|
func getFakeCSINodeLister(csiNode *storagev1beta1.CSINode) fakelisters.CSINodeLister {
|
||||||
if csiNode != nil {
|
if csiNode != nil {
|
||||||
return fakelisters.CSINodeInfo(*csiNode)
|
return fakelisters.CSINodeLister(*csiNode)
|
||||||
}
|
}
|
||||||
return fakelisters.CSINodeInfo{}
|
return fakelisters.CSINodeLister{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNodeWithPodAndVolumeLimits(limitSource string, pods []*v1.Pod, limit int64, driverNames ...string) (*schedulernodeinfo.NodeInfo, *v1beta1.CSINode) {
|
func getNodeWithPodAndVolumeLimits(limitSource string, pods []*v1.Pod, limit int64, driverNames ...string) (*schedulernodeinfo.NodeInfo, *v1beta1.CSINode) {
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||||
@ -475,7 +475,7 @@ func TestEBSLimits(t *testing.T) {
|
|||||||
t.Run(test.test, func(t *testing.T) {
|
t.Run(test.test, func(t *testing.T) {
|
||||||
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
||||||
p := &EBSLimits{
|
p := &EBSLimits{
|
||||||
predicate: predicates.NewMaxPDVolumeCountPredicate(test.filterName, getFakeCSINodeInfo(csiNode), getFakeCSIStorageClassInfo(test.filterName, test.driverName), getFakePVInfo(test.filterName), getFakePVCInfo(test.filterName)),
|
predicate: predicates.NewMaxPDVolumeCountPredicate(test.filterName, getFakeCSINodeLister(csiNode), getFakeCSIStorageClassLister(test.filterName, test.driverName), getFakePVLister(test.filterName), getFakePVCLister(test.filterName)),
|
||||||
}
|
}
|
||||||
gotStatus := p.Filter(context.Background(), nil, test.newPod, node)
|
gotStatus := p.Filter(context.Background(), nil, test.newPod, node)
|
||||||
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
||||||
@ -485,8 +485,8 @@ func TestEBSLimits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakePVCInfo(filterName string) fakelisters.PersistentVolumeClaimInfo {
|
func getFakePVCLister(filterName string) fakelisters.PersistentVolumeClaimLister {
|
||||||
return fakelisters.PersistentVolumeClaimInfo{
|
return fakelisters.PersistentVolumeClaimLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "some" + filterName + "Vol"},
|
ObjectMeta: metav1.ObjectMeta{Name: "some" + filterName + "Vol"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{
|
Spec: v1.PersistentVolumeClaimSpec{
|
||||||
@ -546,8 +546,8 @@ func getFakePVCInfo(filterName string) fakelisters.PersistentVolumeClaimInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFakePVInfo(filterName string) fakelisters.PersistentVolumeInfo {
|
func getFakePVLister(filterName string) fakelisters.PersistentVolumeLister {
|
||||||
return fakelisters.PersistentVolumeInfo{
|
return fakelisters.PersistentVolumeLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "some" + filterName + "Vol"},
|
ObjectMeta: metav1.ObjectMeta{Name: "some" + filterName + "Vol"},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
@ -361,7 +361,7 @@ func TestGCEPDLimits(t *testing.T) {
|
|||||||
t.Run(test.test, func(t *testing.T) {
|
t.Run(test.test, func(t *testing.T) {
|
||||||
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
node, csiNode := getNodeWithPodAndVolumeLimits("node", test.existingPods, int64(test.maxVols), test.filterName)
|
||||||
p := &GCEPDLimits{
|
p := &GCEPDLimits{
|
||||||
predicate: predicates.NewMaxPDVolumeCountPredicate(test.filterName, getFakeCSINodeInfo(csiNode), getFakeCSIStorageClassInfo(test.filterName, test.driverName), getFakePVInfo(test.filterName), getFakePVCInfo(test.filterName)),
|
predicate: predicates.NewMaxPDVolumeCountPredicate(test.filterName, getFakeCSINodeLister(csiNode), getFakeCSIStorageClassLister(test.filterName, test.driverName), getFakePVLister(test.filterName), getFakePVCLister(test.filterName)),
|
||||||
}
|
}
|
||||||
gotStatus := p.Filter(context.Background(), nil, test.newPod, node)
|
gotStatus := p.Filter(context.Background(), nil, test.newPod, node)
|
||||||
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
||||||
|
@ -49,7 +49,7 @@ func createPodWithVolume(pod, pv, pvc string) *v1.Pod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSingleZone(t *testing.T) {
|
func TestSingleZone(t *testing.T) {
|
||||||
pvInfo := fakelisters.PersistentVolumeInfo{
|
pvLister := fakelisters.PersistentVolumeLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
||||||
},
|
},
|
||||||
@ -61,7 +61,7 @@ func TestSingleZone(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pvcInfo := fakelisters.PersistentVolumeClaimInfo{
|
pvcLister := fakelisters.PersistentVolumeClaimLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
||||||
@ -156,7 +156,7 @@ func TestSingleZone(t *testing.T) {
|
|||||||
node := &schedulernodeinfo.NodeInfo{}
|
node := &schedulernodeinfo.NodeInfo{}
|
||||||
node.SetNode(test.Node)
|
node.SetNode(test.Node)
|
||||||
p := &VolumeZone{
|
p := &VolumeZone{
|
||||||
predicate: predicates.NewVolumeZonePredicate(pvInfo, pvcInfo, nil),
|
predicate: predicates.NewVolumeZonePredicate(pvLister, pvcLister, nil),
|
||||||
}
|
}
|
||||||
gotStatus := p.Filter(context.Background(), nil, test.Pod, node)
|
gotStatus := p.Filter(context.Background(), nil, test.Pod, node)
|
||||||
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
||||||
@ -167,7 +167,7 @@ func TestSingleZone(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMultiZone(t *testing.T) {
|
func TestMultiZone(t *testing.T) {
|
||||||
pvInfo := fakelisters.PersistentVolumeInfo{
|
pvLister := fakelisters.PersistentVolumeLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
||||||
},
|
},
|
||||||
@ -179,7 +179,7 @@ func TestMultiZone(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pvcInfo := fakelisters.PersistentVolumeClaimInfo{
|
pvcLister := fakelisters.PersistentVolumeClaimLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
||||||
@ -241,7 +241,7 @@ func TestMultiZone(t *testing.T) {
|
|||||||
node := &schedulernodeinfo.NodeInfo{}
|
node := &schedulernodeinfo.NodeInfo{}
|
||||||
node.SetNode(test.Node)
|
node.SetNode(test.Node)
|
||||||
p := &VolumeZone{
|
p := &VolumeZone{
|
||||||
predicate: predicates.NewVolumeZonePredicate(pvInfo, pvcInfo, nil),
|
predicate: predicates.NewVolumeZonePredicate(pvLister, pvcLister, nil),
|
||||||
}
|
}
|
||||||
gotStatus := p.Filter(context.Background(), nil, test.Pod, node)
|
gotStatus := p.Filter(context.Background(), nil, test.Pod, node)
|
||||||
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
||||||
@ -260,7 +260,7 @@ func TestWithBinding(t *testing.T) {
|
|||||||
classImmediate = "Class_Immediate"
|
classImmediate = "Class_Immediate"
|
||||||
)
|
)
|
||||||
|
|
||||||
classInfo := fakelisters.StorageClassInfo{
|
scLister := fakelisters.StorageClassLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: classImmediate},
|
ObjectMeta: metav1.ObjectMeta{Name: classImmediate},
|
||||||
},
|
},
|
||||||
@ -270,13 +270,13 @@ func TestWithBinding(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pvInfo := fakelisters.PersistentVolumeInfo{
|
pvLister := fakelisters.PersistentVolumeLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
ObjectMeta: metav1.ObjectMeta{Name: "Vol_1", Labels: map[string]string{v1.LabelZoneFailureDomain: "us-west1-a"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pvcInfo := fakelisters.PersistentVolumeClaimInfo{
|
pvcLister := fakelisters.PersistentVolumeClaimLister{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
ObjectMeta: metav1.ObjectMeta{Name: "PVC_1", Namespace: "default"},
|
||||||
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
Spec: v1.PersistentVolumeClaimSpec{VolumeName: "Vol_1"},
|
||||||
@ -346,7 +346,7 @@ func TestWithBinding(t *testing.T) {
|
|||||||
node := &schedulernodeinfo.NodeInfo{}
|
node := &schedulernodeinfo.NodeInfo{}
|
||||||
node.SetNode(test.Node)
|
node.SetNode(test.Node)
|
||||||
p := &VolumeZone{
|
p := &VolumeZone{
|
||||||
predicate: predicates.NewVolumeZonePredicate(pvInfo, pvcInfo, classInfo),
|
predicate: predicates.NewVolumeZonePredicate(pvLister, pvcLister, scLister),
|
||||||
}
|
}
|
||||||
gotStatus := p.Filter(context.Background(), nil, test.Pod, node)
|
gotStatus := p.Filter(context.Background(), nil, test.Pod, node)
|
||||||
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
if !reflect.DeepEqual(gotStatus, test.wantStatus) {
|
||||||
|
@ -202,24 +202,6 @@ func (f StatefulSetLister) StatefulSets(namespace string) appslisters.StatefulSe
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PersistentVolumeClaimLister implements PersistentVolumeClaimLister on []*v1.PersistentVolumeClaim for test purposes.
|
|
||||||
type PersistentVolumeClaimLister []*v1.PersistentVolumeClaim
|
|
||||||
|
|
||||||
var _ corelisters.PersistentVolumeClaimLister = PersistentVolumeClaimLister{}
|
|
||||||
|
|
||||||
// List lists all PersistentVolumeClaims in the indexer.
|
|
||||||
func (f PersistentVolumeClaimLister) List(selector labels.Selector) (ret []*v1.PersistentVolumeClaim, err error) {
|
|
||||||
return nil, fmt.Errorf("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
// PersistentVolumeClaims returns a fake PersistentVolumeClaimLister object.
|
|
||||||
func (f PersistentVolumeClaimLister) PersistentVolumeClaims(namespace string) corelisters.PersistentVolumeClaimNamespaceLister {
|
|
||||||
return &persistentVolumeClaimNamespaceLister{
|
|
||||||
pvcs: f,
|
|
||||||
namespace: namespace,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// persistentVolumeClaimNamespaceLister is implementation of PersistentVolumeClaimNamespaceLister returned by List() above.
|
// persistentVolumeClaimNamespaceLister is implementation of PersistentVolumeClaimNamespaceLister returned by List() above.
|
||||||
type persistentVolumeClaimNamespaceLister struct {
|
type persistentVolumeClaimNamespaceLister struct {
|
||||||
pvcs []*v1.PersistentVolumeClaim
|
pvcs []*v1.PersistentVolumeClaim
|
||||||
@ -239,28 +221,18 @@ func (f persistentVolumeClaimNamespaceLister) List(selector labels.Selector) (re
|
|||||||
return nil, fmt.Errorf("not implemented")
|
return nil, fmt.Errorf("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
// PersistentVolumeClaimInfo declares a []v1.PersistentVolumeClaim type for testing.
|
// PersistentVolumeClaimLister declares a []v1.PersistentVolumeClaim type for testing.
|
||||||
type PersistentVolumeClaimInfo []v1.PersistentVolumeClaim
|
type PersistentVolumeClaimLister []v1.PersistentVolumeClaim
|
||||||
|
|
||||||
var _ corelisters.PersistentVolumeClaimLister = PersistentVolumeClaimInfo{}
|
var _ corelisters.PersistentVolumeClaimLister = PersistentVolumeClaimLister{}
|
||||||
|
|
||||||
// GetPersistentVolumeClaimInfo gets PVC matching the namespace and PVC ID.
|
|
||||||
func (pvcs PersistentVolumeClaimInfo) GetPersistentVolumeClaimInfo(namespace string, pvcID string) (*v1.PersistentVolumeClaim, error) {
|
|
||||||
for _, pvc := range pvcs {
|
|
||||||
if pvc.Name == pvcID && pvc.Namespace == namespace {
|
|
||||||
return &pvc, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("Unable to find persistent volume claim: %s/%s", namespace, pvcID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// List gets PVC matching the namespace and PVC ID.
|
// List gets PVC matching the namespace and PVC ID.
|
||||||
func (pvcs PersistentVolumeClaimInfo) List(selector labels.Selector) (ret []*v1.PersistentVolumeClaim, err error) {
|
func (pvcs PersistentVolumeClaimLister) List(selector labels.Selector) (ret []*v1.PersistentVolumeClaim, err error) {
|
||||||
return nil, fmt.Errorf("not implemented")
|
return nil, fmt.Errorf("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
// PersistentVolumeClaims returns a fake PersistentVolumeClaimLister object.
|
// PersistentVolumeClaims returns a fake PersistentVolumeClaimLister object.
|
||||||
func (pvcs PersistentVolumeClaimInfo) PersistentVolumeClaims(namespace string) corelisters.PersistentVolumeClaimNamespaceLister {
|
func (pvcs PersistentVolumeClaimLister) PersistentVolumeClaims(namespace string) corelisters.PersistentVolumeClaimNamespaceLister {
|
||||||
ps := make([]*v1.PersistentVolumeClaim, len(pvcs))
|
ps := make([]*v1.PersistentVolumeClaim, len(pvcs))
|
||||||
for i := range pvcs {
|
for i := range pvcs {
|
||||||
ps[i] = &pvcs[i]
|
ps[i] = &pvcs[i]
|
||||||
@ -284,45 +256,29 @@ func (nodes NodeLister) GetNodeInfo(nodeName string) (*v1.Node, error) {
|
|||||||
return nil, fmt.Errorf("Unable to find node: %s", nodeName)
|
return nil, fmt.Errorf("Unable to find node: %s", nodeName)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ v1beta1storagelisters.CSINodeLister = CSINodeInfo{}
|
var _ v1beta1storagelisters.CSINodeLister = CSINodeLister{}
|
||||||
|
|
||||||
// CSINodeInfo declares a storagev1beta1.CSINode type for testing.
|
// CSINodeLister declares a storagev1beta1.CSINode type for testing.
|
||||||
type CSINodeInfo storagev1beta1.CSINode
|
type CSINodeLister storagev1beta1.CSINode
|
||||||
|
|
||||||
// GetCSINodeInfo returns a fake CSINode object.
|
|
||||||
func (n CSINodeInfo) GetCSINodeInfo(name string) (*storagev1beta1.CSINode, error) {
|
|
||||||
csiNode := storagev1beta1.CSINode(n)
|
|
||||||
return &csiNode, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get returns a fake CSINode object.
|
// Get returns a fake CSINode object.
|
||||||
func (n CSINodeInfo) Get(name string) (*storagev1beta1.CSINode, error) {
|
func (n CSINodeLister) Get(name string) (*storagev1beta1.CSINode, error) {
|
||||||
csiNode := storagev1beta1.CSINode(n)
|
csiNode := storagev1beta1.CSINode(n)
|
||||||
return &csiNode, nil
|
return &csiNode, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// List lists all CSINodes in the indexer.
|
// List lists all CSINodes in the indexer.
|
||||||
func (n CSINodeInfo) List(selector labels.Selector) (ret []*storagev1beta1.CSINode, err error) {
|
func (n CSINodeLister) List(selector labels.Selector) (ret []*storagev1beta1.CSINode, err error) {
|
||||||
return nil, fmt.Errorf("not implemented")
|
return nil, fmt.Errorf("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
// PersistentVolumeInfo declares a []v1.PersistentVolume type for testing.
|
// PersistentVolumeLister declares a []v1.PersistentVolume type for testing.
|
||||||
type PersistentVolumeInfo []v1.PersistentVolume
|
type PersistentVolumeLister []v1.PersistentVolume
|
||||||
|
|
||||||
var _ corelisters.PersistentVolumeLister = PersistentVolumeInfo{}
|
var _ corelisters.PersistentVolumeLister = PersistentVolumeLister{}
|
||||||
|
|
||||||
// GetPersistentVolumeInfo returns a fake PV object in the fake PVs by PV ID.
|
|
||||||
func (pvs PersistentVolumeInfo) GetPersistentVolumeInfo(pvID string) (*v1.PersistentVolume, error) {
|
|
||||||
for _, pv := range pvs {
|
|
||||||
if pv.Name == pvID {
|
|
||||||
return &pv, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("Unable to find persistent volume: %s", pvID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get returns a fake PV object in the fake PVs by PV ID.
|
// Get returns a fake PV object in the fake PVs by PV ID.
|
||||||
func (pvs PersistentVolumeInfo) Get(pvID string) (*v1.PersistentVolume, error) {
|
func (pvs PersistentVolumeLister) Get(pvID string) (*v1.PersistentVolume, error) {
|
||||||
for _, pv := range pvs {
|
for _, pv := range pvs {
|
||||||
if pv.Name == pvID {
|
if pv.Name == pvID {
|
||||||
return &pv, nil
|
return &pv, nil
|
||||||
@ -332,27 +288,17 @@ func (pvs PersistentVolumeInfo) Get(pvID string) (*v1.PersistentVolume, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List lists all PersistentVolumes in the indexer.
|
// List lists all PersistentVolumes in the indexer.
|
||||||
func (pvs PersistentVolumeInfo) List(selector labels.Selector) ([]*v1.PersistentVolume, error) {
|
func (pvs PersistentVolumeLister) List(selector labels.Selector) ([]*v1.PersistentVolume, error) {
|
||||||
return nil, fmt.Errorf("not implemented")
|
return nil, fmt.Errorf("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
// StorageClassInfo declares a []storagev1.StorageClass type for testing.
|
// StorageClassLister declares a []storagev1.StorageClass type for testing.
|
||||||
type StorageClassInfo []storagev1.StorageClass
|
type StorageClassLister []storagev1.StorageClass
|
||||||
|
|
||||||
var _ storagelisters.StorageClassLister = StorageClassInfo{}
|
var _ storagelisters.StorageClassLister = StorageClassLister{}
|
||||||
|
|
||||||
// GetStorageClassInfo returns a fake storage class object in the fake storage classes by name.
|
|
||||||
func (classes StorageClassInfo) GetStorageClassInfo(name string) (*storagev1.StorageClass, error) {
|
|
||||||
for _, sc := range classes {
|
|
||||||
if sc.Name == name {
|
|
||||||
return &sc, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("Unable to find storage class: %s", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get returns a fake storage class object in the fake storage classes by name.
|
// Get returns a fake storage class object in the fake storage classes by name.
|
||||||
func (classes StorageClassInfo) Get(name string) (*storagev1.StorageClass, error) {
|
func (classes StorageClassLister) Get(name string) (*storagev1.StorageClass, error) {
|
||||||
for _, sc := range classes {
|
for _, sc := range classes {
|
||||||
if sc.Name == name {
|
if sc.Name == name {
|
||||||
return &sc, nil
|
return &sc, nil
|
||||||
@ -362,6 +308,6 @@ func (classes StorageClassInfo) Get(name string) (*storagev1.StorageClass, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List lists all StorageClass in the indexer.
|
// List lists all StorageClass in the indexer.
|
||||||
func (classes StorageClassInfo) List(selector labels.Selector) ([]*storagev1.StorageClass, error) {
|
func (classes StorageClassLister) List(selector labels.Selector) ([]*storagev1.StorageClass, error) {
|
||||||
return nil, fmt.Errorf("not implemented")
|
return nil, fmt.Errorf("not implemented")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user