@@ -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,8 +28,8 @@ import (
27
28
)
28
29
29
30
func TestController (t * testing.T ) {
30
- basePVC := createTestPVC (pvcName , testVac /*vacName*/ , testVac /*curVacName*/ , testVac /*targetVacName*/ )
31
- basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
31
+ basePVC := createTestPVC (pvcName , & testVac /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ )
32
+ basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , & testVac )
32
33
firstTimePV := basePV .DeepCopy ()
33
34
firstTimePV .Spec .VolumeAttributesClassName = nil
34
35
firstTimePVC := basePVC .DeepCopy ()
@@ -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 ,
@@ -93,7 +94,7 @@ func TestController(t *testing.T) {
93
94
}
94
95
95
96
func TestModifyPVC (t * testing.T ) {
96
- basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
97
+ basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , & testVac )
97
98
98
99
tests := []struct {
99
100
name string
@@ -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
- basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
149
+ basePVC := createTestPVC (pvcName , & targetVac /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ )
150
+ basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , & testVac )
150
151
151
- otherDriverPV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
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 , & emptyString /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ ),
200
201
pv : basePV ,
201
202
callCSIModify : false ,
202
203
},
@@ -247,8 +248,8 @@ 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
- basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , testVac )
251
+ basePVC := createTestPVC (pvcName , & targetVac /*vacName*/ , & testVac /*curVacName*/ , testVac /*targetVacName*/ , "" /*modifyVolumeStatus */ )
252
+ basePV := createTestPV (1 , pvcName , pvcNamespace , "foobaz" /*pvcUID*/ , & fsVolumeMode , & testVac )
252
253
253
254
tests := []struct {
254
255
name string
0 commit comments