@@ -4,13 +4,14 @@ import (
4
4
"context"
5
5
"errors"
6
6
"fmt"
7
+ "testing"
8
+ "time"
9
+
7
10
"github.com/kubernetes-csi/external-resizer/pkg/util"
8
11
"google.golang.org/grpc/codes"
9
12
"google.golang.org/grpc/status"
10
13
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11
14
"k8s.io/client-go/tools/cache"
12
- "testing"
13
- "time"
14
15
15
16
"github.com/kubernetes-csi/external-resizer/pkg/features"
16
17
@@ -27,7 +28,7 @@ import (
27
28
)
28
29
29
30
func 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*/ )
31
32
basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
32
33
firstTimePV := basePV .DeepCopy ()
33
34
firstTimePV .Spec .VolumeAttributesClassName = nil
@@ -44,7 +45,7 @@ func TestController(t *testing.T) {
44
45
}{
45
46
{
46
47
name : "Modify called" ,
47
- pvc : createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ ),
48
+ pvc : createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus*/ ),
48
49
pv : basePV ,
49
50
vacExists : true ,
50
51
callCSIModify : true ,
@@ -104,14 +105,14 @@ func TestModifyPVC(t *testing.T) {
104
105
}{
105
106
{
106
107
name : "Modify succeeded" ,
107
- pvc : createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ ),
108
+ pvc : createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus*/ ),
108
109
pv : basePV ,
109
110
modifyFailure : false ,
110
111
expectFailure : false ,
111
112
},
112
113
{
113
114
name : "Modify failed" ,
114
- pvc : createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ ),
115
+ pvc : createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus*/ ),
115
116
pv : basePV ,
116
117
modifyFailure : true ,
117
118
expectFailure : true ,
@@ -145,16 +146,16 @@ func TestModifyPVC(t *testing.T) {
145
146
}
146
147
147
148
func 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*/ )
149
150
basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
150
151
151
152
otherDriverPV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
152
153
otherDriverPV .Spec .PersistentVolumeSource .CSI .Driver = "some-other-driver"
153
154
154
- unboundPVC := createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ )
155
+ unboundPVC := createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus*/ )
155
156
unboundPVC .Status .Phase = v1 .ClaimPending
156
157
157
- pvcWithUncreatedPV := createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ )
158
+ pvcWithUncreatedPV := createTestPVC (pvcName , targetVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus*/ )
158
159
pvcWithUncreatedPV .Spec .VolumeName = ""
159
160
160
161
nonCSIPVC := & v1.PersistentVolumeClaim {
@@ -196,7 +197,7 @@ func TestSyncPVC(t *testing.T) {
196
197
},
197
198
{
198
199
name : "Should NOT modify if PVC has empty Spec.VACName" ,
199
- pvc : createTestPVC (pvcName , "" /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ ),
200
+ pvc : createTestPVC (pvcName , "" /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus*/ ),
200
201
pv : basePV ,
201
202
callCSIModify : false ,
202
203
},
@@ -247,7 +248,7 @@ func TestSyncPVC(t *testing.T) {
247
248
248
249
// TestInfeasibleRetry tests that sidecar doesn't spam plugin upon infeasible error code (e.g. invalid VAC parameter)
249
250
func 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*/ )
251
252
basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
252
253
253
254
tests := []struct {
0 commit comments