@@ -9,10 +9,12 @@ import (
9
9
"github.com/kubernetes-csi/external-resizer/pkg/features"
10
10
"github.com/kubernetes-csi/external-resizer/pkg/resizer"
11
11
"github.com/kubernetes-csi/external-resizer/pkg/testutil"
12
+ "github.com/kubernetes-csi/external-resizer/pkg/util"
12
13
"google.golang.org/grpc/codes"
13
14
"google.golang.org/grpc/status"
14
15
v1 "k8s.io/api/core/v1"
15
16
"k8s.io/apimachinery/pkg/api/resource"
17
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16
18
"k8s.io/apimachinery/pkg/runtime"
17
19
"k8s.io/apimachinery/pkg/util/sets"
18
20
utilfeature "k8s.io/apiserver/pkg/util/feature"
@@ -29,21 +31,24 @@ func TestExpandAndRecover(t *testing.T) {
29
31
pv * v1.PersistentVolume
30
32
disableNodeExpansion bool
31
33
disableControllerExpansion bool
34
+
32
35
// expectations of test
33
- expectedResizeStatus v1.ClaimResourceStatus
34
- expectedAllocatedSize resource.Quantity
35
- pvcWithFinalErrors sets.Set [string ]
36
- expansionError error
37
- expectResizeCall bool
38
- expectedConditions []v1.PersistentVolumeClaimConditionType
36
+ expectedResizeStatus v1.ClaimResourceStatus
37
+ expectedAllocatedSize resource.Quantity
38
+ expectNodeExpansionNotRequiredAnnotation bool
39
+ pvcWithFinalErrors sets.Set [string ]
40
+ expansionError error
41
+ expectResizeCall bool
42
+ expectedConditions []v1.PersistentVolumeClaimConditionType
39
43
}{
40
44
{
41
- name : "pvc.spec.size > pv.spec.size, resize_status=node_expansion_inprogress" ,
42
- pvc : testutil .GetTestPVC ("test-vol0" , "2G" , "1G" , "" , "" ),
43
- pv : createPV (1 , "claim01" , defaultNS , "test-uid" , & fsVolumeMode ),
44
- expectedResizeStatus : v1 .PersistentVolumeClaimNodeResizePending ,
45
- expectedAllocatedSize : resource .MustParse ("2G" ),
46
- expectResizeCall : true ,
45
+ name : "pvc.spec.size > pv.spec.size, resize_status=node_expansion_inprogress" ,
46
+ pvc : testutil .GetTestPVC ("test-vol0" , "2G" , "1G" , "" , "" ),
47
+ pv : createPV (1 , "claim01" , defaultNS , "test-uid" , & fsVolumeMode ),
48
+ expectedResizeStatus : v1 .PersistentVolumeClaimNodeResizePending ,
49
+ expectNodeExpansionNotRequiredAnnotation : false ,
50
+ expectedAllocatedSize : resource .MustParse ("2G" ),
51
+ expectResizeCall : true ,
47
52
},
48
53
{
49
54
name : "pvc.spec.size = pv.spec.size, resize_status=no_expansion_inprogress" ,
@@ -116,13 +121,14 @@ func TestExpandAndRecover(t *testing.T) {
116
121
expectResizeCall : false ,
117
122
},
118
123
{
119
- name : "pvc.spec.size > pv.spec.size, disable_node_expansion=true, resize_status=no_expansion_inprogress" ,
120
- pvc : testutil .GetTestPVC ("test-vol0" , "2G" , "1G" , "" , "" ),
121
- pv : createPV (1 , "claim01" , defaultNS , "test-uid" , & fsVolumeMode ),
122
- disableNodeExpansion : true ,
123
- expectedResizeStatus : "" ,
124
- expectedAllocatedSize : resource .MustParse ("2G" ),
125
- expectResizeCall : true ,
124
+ name : "pvc.spec.size > pv.spec.size, disable_node_expansion=true, resize_status=no_expansion_inprogress" ,
125
+ pvc : testutil .GetTestPVC ("test-vol0" , "2G" , "1G" , "" , "" ),
126
+ pv : createPV (1 , "claim01" , defaultNS , "test-uid" , & fsVolumeMode ),
127
+ disableNodeExpansion : true ,
128
+ expectedResizeStatus : "" ,
129
+ expectNodeExpansionNotRequiredAnnotation : true ,
130
+ expectedAllocatedSize : resource .MustParse ("2G" ),
131
+ expectResizeCall : true ,
126
132
},
127
133
{
128
134
name : "pv.spec.size >= pvc.spec.size, resize_status=node_expansion_failed" ,
@@ -193,6 +199,10 @@ func TestExpandAndRecover(t *testing.T) {
193
199
t .Fatalf ("expected resize status to be %s, got %s" , test .expectedResizeStatus , actualResizeStatus )
194
200
}
195
201
202
+ if test .expectNodeExpansionNotRequiredAnnotation != metav1 .HasAnnotation (pvc .ObjectMeta , util .NodeExpansionNotRequired ) {
203
+ t .Fatalf ("expected node expansion not required annotation to be %t, got %t" , test .expectNodeExpansionNotRequiredAnnotation , metav1 .HasAnnotation (pvc .ObjectMeta , util .NodeExpansionNotRequired ))
204
+ }
205
+
196
206
actualAllocatedSize := pvc .Status .AllocatedResources .Storage ()
197
207
198
208
if test .expectedAllocatedSize .Cmp (* actualAllocatedSize ) != 0 {
0 commit comments