@@ -32,9 +32,11 @@ import (
32
32
"github.com/golang/mock/gomock"
33
33
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
34
34
"k8s.io/apimachinery/pkg/runtime"
35
+ utilfeature "k8s.io/component-base/featuregate/testing"
35
36
"sigs.k8s.io/controller-runtime/pkg/client/fake"
36
37
37
38
infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
39
+ "sigs.k8s.io/cluster-api-provider-aws/v2/feature"
38
40
iamv1 "sigs.k8s.io/cluster-api-provider-aws/v2/iam/api/v1beta1"
39
41
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/scope"
40
42
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/s3"
@@ -49,8 +51,6 @@ const (
49
51
)
50
52
51
53
func TestReconcileBucket (t * testing.T ) {
52
- t .Parallel ()
53
-
54
54
t .Run ("does_nothing_when_bucket_management_is_disabled" , func (t * testing.T ) {
55
55
t .Parallel ()
56
56
@@ -62,7 +62,7 @@ func TestReconcileBucket(t *testing.T) {
62
62
})
63
63
64
64
t .Run ("creates_bucket_with_configured_name" , func (t * testing.T ) {
65
- t . Parallel ()
65
+ defer utilfeature . SetFeatureGateDuringTest ( t , feature . Gates , feature . MachinePool , true ) ()
66
66
67
67
expectedBucketName := "baz"
68
68
@@ -107,7 +107,7 @@ func TestReconcileBucket(t *testing.T) {
107
107
})
108
108
109
109
t .Run ("hashes_default_bucket_name_if_name_exceeds_maximum_length" , func (t * testing.T ) {
110
- t . Parallel ()
110
+ defer utilfeature . SetFeatureGateDuringTest ( t , feature . Gates , feature . MachinePool , true ) ()
111
111
112
112
mockCtrl := gomock .NewController (t )
113
113
s3Mock := mock_s3iface .NewMockS3API (mockCtrl )
@@ -163,7 +163,7 @@ func TestReconcileBucket(t *testing.T) {
163
163
})
164
164
165
165
t .Run ("creates_bucket_with_policy_allowing_controlplane_and_worker_nodes_to_read_their_secrets" , func (t * testing.T ) {
166
- t . Parallel ()
166
+ defer utilfeature . SetFeatureGateDuringTest ( t , feature . Gates , feature . MachinePool , true ) ()
167
167
168
168
bucketName := "bar"
169
169
@@ -216,7 +216,7 @@ func TestReconcileBucket(t *testing.T) {
216
216
})
217
217
218
218
t .Run ("is_idempotent" , func (t * testing.T ) {
219
- t . Parallel ()
219
+ defer utilfeature . SetFeatureGateDuringTest ( t , feature . Gates , feature . MachinePool , true ) ()
220
220
221
221
svc , s3Mock := testService (t , & infrav1.S3Bucket {})
222
222
@@ -235,7 +235,7 @@ func TestReconcileBucket(t *testing.T) {
235
235
})
236
236
237
237
t .Run ("ignores_when_bucket_already_exists_but_its_owned_by_the_same_account" , func (t * testing.T ) {
238
- t . Parallel ()
238
+ defer utilfeature . SetFeatureGateDuringTest ( t , feature . Gates , feature . MachinePool , true ) ()
239
239
240
240
svc , s3Mock := testService (t , & infrav1.S3Bucket {})
241
241
@@ -318,7 +318,7 @@ func TestDeleteBucket(t *testing.T) {
318
318
const bucketName = "foo"
319
319
320
320
t .Run ("does_nothing_when_bucket_management_is_disabled" , func (t * testing.T ) {
321
- t . Parallel ()
321
+ defer utilfeature . SetFeatureGateDuringTest ( t , feature . Gates , feature . MachinePool , true ) ()
322
322
323
323
svc , _ := testService (t , nil )
324
324
@@ -328,7 +328,7 @@ func TestDeleteBucket(t *testing.T) {
328
328
})
329
329
330
330
t .Run ("deletes_bucket_with_configured_name" , func (t * testing.T ) {
331
- t . Parallel ()
331
+ defer utilfeature . SetFeatureGateDuringTest ( t , feature . Gates , feature . MachinePool , true ) ()
332
332
333
333
svc , s3Mock := testService (t , & infrav1.S3Bucket {
334
334
Name : bucketName ,
@@ -347,9 +347,8 @@ func TestDeleteBucket(t *testing.T) {
347
347
})
348
348
349
349
t .Run ("returns_error_when_bucket_removal_returns" , func (t * testing.T ) {
350
- t .Parallel ()
351
350
t .Run ("unexpected_error" , func (t * testing.T ) {
352
- t . Parallel ()
351
+ defer utilfeature . SetFeatureGateDuringTest ( t , feature . Gates , feature . MachinePool , true ) ()
353
352
354
353
svc , s3Mock := testService (t , & infrav1.S3Bucket {})
355
354
@@ -362,7 +361,7 @@ func TestDeleteBucket(t *testing.T) {
362
361
})
363
362
364
363
t .Run ("unexpected_AWS_error" , func (t * testing.T ) {
365
- t . Parallel ()
364
+ defer utilfeature . SetFeatureGateDuringTest ( t , feature . Gates , feature . MachinePool , true ) ()
366
365
367
366
svc , s3Mock := testService (t , & infrav1.S3Bucket {})
368
367
@@ -376,7 +375,7 @@ func TestDeleteBucket(t *testing.T) {
376
375
})
377
376
378
377
t .Run ("ignores_when_bucket_has_already_been_removed" , func (t * testing.T ) {
379
- t . Parallel ()
378
+ defer utilfeature . SetFeatureGateDuringTest ( t , feature . Gates , feature . MachinePool , true ) ()
380
379
381
380
svc , s3Mock := testService (t , & infrav1.S3Bucket {})
382
381
@@ -389,7 +388,7 @@ func TestDeleteBucket(t *testing.T) {
389
388
})
390
389
391
390
t .Run ("skips_bucket_removal_when_bucket_is_not_empty" , func (t * testing.T ) {
392
- t . Parallel ()
391
+ defer utilfeature . SetFeatureGateDuringTest ( t , feature . Gates , feature . MachinePool , true ) ()
393
392
394
393
svc , s3Mock := testService (t , & infrav1.S3Bucket {})
395
394
0 commit comments