@@ -4,13 +4,14 @@ import (
44 "context"
55 "errors"
66 "fmt"
7+ "testing"
8+ "time"
9+
710 "github.com/kubernetes-csi/external-resizer/pkg/util"
811 "google.golang.org/grpc/codes"
912 "google.golang.org/grpc/status"
1013 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1114 "k8s.io/client-go/tools/cache"
12- "testing"
13- "time"
1415
1516 "github.com/kubernetes-csi/external-resizer/pkg/features"
1617
@@ -27,7 +28,7 @@ import (
2728)
2829
2930func TestController (t * testing.T ) {
30- basePVC := createTestPVC (pvcName , testVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ )
31+ basePVC := createTestPVC (pvcName , & testVac /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ )
3132 basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
3233 firstTimePV := basePV .DeepCopy ()
3334 firstTimePV .Spec .VolumeAttributesClassName = nil
@@ -44,7 +45,7 @@ func TestController(t *testing.T) {
4445 }{
4546 {
4647 name : "Modify called" ,
47- pvc : createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ ),
48+ pvc : createTestPVC (pvcName , & targetVac /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ ),
4849 pv : basePV ,
4950 vacExists : true ,
5051 callCSIModify : true ,
@@ -104,14 +105,14 @@ func TestModifyPVC(t *testing.T) {
104105 }{
105106 {
106107 name : "Modify succeeded" ,
107- pvc : createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ ),
108+ pvc : createTestPVC (pvcName , & targetVac /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ ),
108109 pv : basePV ,
109110 modifyFailure : false ,
110111 expectFailure : false ,
111112 },
112113 {
113114 name : "Modify failed" ,
114- pvc : createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ ),
115+ pvc : createTestPVC (pvcName , & targetVac /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ ),
115116 pv : basePV ,
116117 modifyFailure : true ,
117118 expectFailure : true ,
@@ -145,16 +146,16 @@ func TestModifyPVC(t *testing.T) {
145146}
146147
147148func TestSyncPVC (t * testing.T ) {
148- basePVC := createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ )
149+ basePVC := createTestPVC (pvcName , & targetVac /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ )
149150 basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
150151
151152 otherDriverPV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
152153 otherDriverPV .Spec .PersistentVolumeSource .CSI .Driver = "some-other-driver"
153154
154- unboundPVC := createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ )
155+ unboundPVC := createTestPVC (pvcName , & targetVac /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ )
155156 unboundPVC .Status .Phase = v1 .ClaimPending
156157
157- pvcWithUncreatedPV := createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ )
158+ pvcWithUncreatedPV := createTestPVC (pvcName , & targetVac /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ )
158159 pvcWithUncreatedPV .Spec .VolumeName = ""
159160
160161 nonCSIPVC := & v1.PersistentVolumeClaim {
@@ -196,7 +197,7 @@ func TestSyncPVC(t *testing.T) {
196197 },
197198 {
198199 name : "Should NOT modify if PVC has empty Spec.VACName" ,
199- pvc : createTestPVC (pvcName , "" /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ ),
200+ pvc : createTestPVC (pvcName , & emptyString /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ ),
200201 pv : basePV ,
201202 callCSIModify : false ,
202203 },
@@ -247,7 +248,7 @@ func TestSyncPVC(t *testing.T) {
247248
248249// TestInfeasibleRetry tests that sidecar doesn't spam plugin upon infeasible error code (e.g. invalid VAC parameter)
249250func TestInfeasibleRetry (t * testing.T ) {
250- basePVC := createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ )
251+ basePVC := createTestPVC (pvcName , & targetVac /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ )
251252 basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
252253
253254 tests := []struct {
0 commit comments