@@ -22,6 +22,7 @@ import (
22
22
23
23
"k8s.io/api/core/v1"
24
24
storage "k8s.io/api/storage/v1"
25
+ pvtesting "k8s.io/kubernetes/pkg/controller/volume/persistentvolume/testing"
25
26
)
26
27
27
28
// Test single call to syncVolume, expecting recycling to happen.
@@ -91,11 +92,9 @@ func TestDeleteSync(t *testing.T) {
91
92
noclaims ,
92
93
noclaims ,
93
94
noevents , noerrors ,
94
- wrapTestWithInjectedOperation (wrapTestWithReclaimCalls (operationDelete , []error {}, testSyncVolume ), func (ctrl * PersistentVolumeController , reactor * volumeReactor ) {
95
+ wrapTestWithInjectedOperation (wrapTestWithReclaimCalls (operationDelete , []error {}, testSyncVolume ), func (ctrl * PersistentVolumeController , reactor * pvtesting. VolumeReactor ) {
95
96
// Delete the volume before delete operation starts
96
- reactor .lock .Lock ()
97
- delete (reactor .volumes , "volume8-6" )
98
- reactor .lock .Unlock ()
97
+ reactor .DeleteVolume ("volume8-6" )
99
98
}),
100
99
},
101
100
{
@@ -108,16 +107,12 @@ func TestDeleteSync(t *testing.T) {
108
107
noclaims ,
109
108
newClaimArray ("claim8-7" , "uid8-7" , "10Gi" , "volume8-7" , v1 .ClaimBound , nil ),
110
109
noevents , noerrors ,
111
- wrapTestWithInjectedOperation (wrapTestWithReclaimCalls (operationDelete , []error {}, testSyncVolume ), func (ctrl * PersistentVolumeController , reactor * volumeReactor ) {
112
- reactor .lock .Lock ()
113
- defer reactor .lock .Unlock ()
110
+ wrapTestWithInjectedOperation (wrapTestWithReclaimCalls (operationDelete , []error {}, testSyncVolume ), func (ctrl * PersistentVolumeController , reactor * pvtesting.VolumeReactor ) {
114
111
// Bind the volume to resurrected claim (this should never
115
112
// happen)
116
113
claim := newClaim ("claim8-7" , "uid8-7" , "10Gi" , "volume8-7" , v1 .ClaimBound , nil )
117
- reactor .claims [ claim . Name ] = claim
114
+ reactor .AddClaimBoundToVolume ( claim )
118
115
ctrl .claims .Add (claim )
119
- volume := reactor .volumes ["volume8-7" ]
120
- volume .Status .Phase = v1 .VolumeBound
121
116
}),
122
117
},
123
118
{
@@ -141,7 +136,7 @@ func TestDeleteSync(t *testing.T) {
141
136
noclaims ,
142
137
noclaims ,
143
138
noevents , noerrors ,
144
- func (ctrl * PersistentVolumeController , reactor * volumeReactor , test controllerTest ) error {
139
+ func (ctrl * PersistentVolumeController , reactor * pvtesting. VolumeReactor , test controllerTest ) error {
145
140
// Inject external deleter annotation
146
141
test .initialVolumes [0 ].Annotations [annDynamicallyProvisioned ] = "external.io/test"
147
142
test .expectedVolumes [0 ].Annotations [annDynamicallyProvisioned ] = "external.io/test"
@@ -184,7 +179,7 @@ func TestDeleteSync(t *testing.T) {
184
179
newClaimArray ("claim8-12" , "uid8-12" , "10Gi" , "volume8-12-2" , v1 .ClaimBound , nil ),
185
180
newClaimArray ("claim8-12" , "uid8-12" , "10Gi" , "volume8-12-2" , v1 .ClaimBound , nil ),
186
181
noevents , noerrors ,
187
- func (ctrl * PersistentVolumeController , reactor * volumeReactor , test controllerTest ) error {
182
+ func (ctrl * PersistentVolumeController , reactor * pvtesting. VolumeReactor , test controllerTest ) error {
188
183
// Inject external deleter annotation
189
184
test .initialVolumes [0 ].Annotations [annDynamicallyProvisioned ] = "external.io/test"
190
185
test .expectedVolumes [0 ].Annotations [annDynamicallyProvisioned ] = "external.io/test"
0 commit comments