add test-cases

This commit is contained in:
moriya 2024-09-21 14:06:52 +09:00
parent 7b8985dc03
commit d5e9199229

View File

@ -864,7 +864,7 @@ func TestCoreResourceEnqueue(t *testing.T) {
enableSchedulingQueueHint: []bool{true}, enableSchedulingQueueHint: []bool{true},
}, },
{ {
name: "Pod rejected with node by the VolumeZone plugin is requeued when the PVC is added", name: "Pod rejected with node by the VolumeZone plugin is requeued when the PVC bound to the pod is added",
initialNodes: []*v1.Node{st.MakeNode().Name("fake-node").Label("node", "fake-node").Label(v1.LabelTopologyZone, "us-west1-a").Obj()}, initialNodes: []*v1.Node{st.MakeNode().Name("fake-node").Label("node", "fake-node").Label(v1.LabelTopologyZone, "us-west1-a").Obj()},
initialPVs: []*v1.PersistentVolume{ initialPVs: []*v1.PersistentVolume{
st.MakePersistentVolume(). st.MakePersistentVolume().
@ -914,7 +914,7 @@ func TestCoreResourceEnqueue(t *testing.T) {
enableSchedulingQueueHint: []bool{true}, enableSchedulingQueueHint: []bool{true},
}, },
{ {
name: "Pod rejected with node by the VolumeZone plugin is requeued when the PVC is updated", name: "Pod rejected with node by the VolumeZone plugin is requeued when the PVC bound to the pod is updated",
initialNodes: []*v1.Node{st.MakeNode().Name("fake-node").Label("node", "fake-node").Label(v1.LabelTopologyZone, "us-west1-a").Obj()}, initialNodes: []*v1.Node{st.MakeNode().Name("fake-node").Label("node", "fake-node").Label(v1.LabelTopologyZone, "us-west1-a").Obj()},
initialPVs: []*v1.PersistentVolume{ initialPVs: []*v1.PersistentVolume{
st.MakePersistentVolume(). st.MakePersistentVolume().
@ -1018,7 +1018,7 @@ func TestCoreResourceEnqueue(t *testing.T) {
enableSchedulingQueueHint: []bool{true}, enableSchedulingQueueHint: []bool{true},
}, },
{ {
name: "Pod rejected with node by the VolumeZone plugin is not requeued when the unrelated label of PV is updated", name: "Pod rejected with node by the VolumeZone plugin is not requeued when the unrelated PVC is added",
initialNodes: []*v1.Node{st.MakeNode().Name("fake-node").Label("node", "fake-node").Label(v1.LabelTopologyZone, "us-west1-a").Obj()}, initialNodes: []*v1.Node{st.MakeNode().Name("fake-node").Label("node", "fake-node").Label(v1.LabelTopologyZone, "us-west1-a").Obj()},
initialPVs: []*v1.PersistentVolume{ initialPVs: []*v1.PersistentVolume{
st.MakePersistentVolume(). st.MakePersistentVolume().
@ -1058,13 +1058,14 @@ func TestCoreResourceEnqueue(t *testing.T) {
st.MakePod().Name("pod2").Container("image").PVC("pvc2").Obj(), st.MakePod().Name("pod2").Container("image").PVC("pvc2").Obj(),
}, },
triggerFn: func(testCtx *testutils.TestContext) error { triggerFn: func(testCtx *testutils.TestContext) error {
pv2 := st.MakePersistentVolume().Name("pv2").Labels(map[string]string{v1.LabelTopologyZone: "us-east1"}). pvc3 := st.MakePersistentVolumeClaim().
AccessModes([]v1.PersistentVolumeAccessMode{v1.ReadOnlyMany}). Name("pvc3").
Capacity(v1.ResourceList{v1.ResourceStorage: resource.MustParse("1Mi")}). Annotation(volume.AnnBindCompleted, "true").
HostPathVolumeSource(&v1.HostPathVolumeSource{Path: "/tmp", Type: &volType}). AccessModes([]v1.PersistentVolumeAccessMode{v1.ReadWriteOncePod}).
Resources(v1.VolumeResourceRequirements{Requests: v1.ResourceList{v1.ResourceStorage: resource.MustParse("1Mi")}}).
Obj() Obj()
if _, err := testCtx.ClientSet.CoreV1().PersistentVolumes().Update(testCtx.Ctx, pv2, metav1.UpdateOptions{}); err != nil { if _, err := testCtx.ClientSet.CoreV1().PersistentVolumeClaims(testCtx.NS.Name).Create(testCtx.Ctx, pvc3, metav1.CreateOptions{}); err != nil {
return fmt.Errorf("failed to update pv2: %w", err) return fmt.Errorf("failed to create pvc3: %w", err)
} }
return nil return nil
}, },