-
Notifications
You must be signed in to change notification settings - Fork 86
feat: Support AbortIncompleteMultipartUpload LifecycleAction #1347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
eb6f253
c38411e
ba1c5f5
17f3897
21542a7
8276600
84b9ccf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,8 +39,11 @@ | |
| import com.google.cloud.storage.BucketInfo.IamConfiguration; | ||
| import com.google.cloud.storage.BucketInfo.IsLiveDeleteRule; | ||
| import com.google.cloud.storage.BucketInfo.LifecycleRule; | ||
| import com.google.cloud.storage.BucketInfo.LifecycleRule.AbortIncompleteMPUAction; | ||
| import com.google.cloud.storage.BucketInfo.LifecycleRule.DeleteLifecycleAction; | ||
| import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleAction; | ||
| import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleCondition; | ||
| import com.google.cloud.storage.BucketInfo.LifecycleRule.SetStorageClassLifecycleAction; | ||
| import com.google.cloud.storage.BucketInfo.NumNewerVersionsDeleteRule; | ||
| import com.google.cloud.storage.BucketInfo.PublicAccessPrevention; | ||
| import com.google.cloud.storage.BucketInfo.RawDeleteRule; | ||
|
|
@@ -331,6 +334,8 @@ public void testLifecycleRules() { | |
| assertEquals( | ||
| LifecycleRule.DeleteLifecycleAction.TYPE, deleteLifecycleRule.getAction().getType()); | ||
| assertEquals(10, deleteLifecycleRule.getCondition().getAge().intValue()); | ||
| assertTrue( | ||
| LifecycleRule.fromPb(deleteLifecycleRule).getAction() instanceof DeleteLifecycleAction); | ||
|
|
||
| Rule setStorageClassLifecycleRule = | ||
| new LifecycleRule( | ||
|
|
@@ -346,6 +351,9 @@ public void testLifecycleRules() { | |
| setStorageClassLifecycleRule.getAction().getStorageClass()); | ||
| assertTrue(setStorageClassLifecycleRule.getCondition().getIsLive()); | ||
| assertEquals(10, setStorageClassLifecycleRule.getCondition().getNumNewerVersions().intValue()); | ||
| assertTrue( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just added these in since I didn't see us testing all the cases of the fromPb switch statement. |
||
| LifecycleRule.fromPb(setStorageClassLifecycleRule).getAction() | ||
| instanceof SetStorageClassLifecycleAction); | ||
|
|
||
| Rule lifecycleRule = | ||
| new LifecycleRule( | ||
|
|
@@ -367,6 +375,19 @@ public void testLifecycleRules() { | |
| assertEquals(StorageClass.COLDLINE.toString(), lifecycleRule.getAction().getStorageClass()); | ||
| assertEquals(30, lifecycleRule.getCondition().getDaysSinceCustomTime().intValue()); | ||
| assertNotNull(lifecycleRule.getCondition().getCustomTimeBefore()); | ||
| assertTrue( | ||
| LifecycleRule.fromPb(lifecycleRule).getAction() instanceof SetStorageClassLifecycleAction); | ||
|
|
||
| Rule abortMpuLifecycleRule = | ||
| new LifecycleRule( | ||
| LifecycleAction.newAbortIncompleteMPUploadAction(), | ||
| LifecycleCondition.newBuilder().setAge(10).build()) | ||
| .toPb(); | ||
| assertEquals(AbortIncompleteMPUAction.TYPE, abortMpuLifecycleRule.getAction().getType()); | ||
| assertEquals(10, abortMpuLifecycleRule.getCondition().getAge().intValue()); | ||
| assertTrue( | ||
| LifecycleRule.fromPb(abortMpuLifecycleRule).getAction() | ||
| instanceof AbortIncompleteMPUAction); | ||
|
|
||
| Rule unsupportedRule = | ||
| new LifecycleRule( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,7 @@ | |
| import com.google.cloud.storage.Bucket; | ||
| import com.google.cloud.storage.BucketInfo; | ||
| import com.google.cloud.storage.BucketInfo.LifecycleRule; | ||
| import com.google.cloud.storage.BucketInfo.LifecycleRule.AbortIncompleteMPUAction; | ||
| import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleAction; | ||
| import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleCondition; | ||
| import com.google.cloud.storage.CopyWriter; | ||
|
|
@@ -547,6 +548,29 @@ public void testGetBucketLifecycleRules() { | |
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetBucketAbortMPULifecycle() { | ||
| String lifecycleTestBucketName = RemoteStorageHelper.generateBucketName(); | ||
| storage.create( | ||
| BucketInfo.newBuilder(lifecycleTestBucketName) | ||
| .setLocation("us") | ||
| .setLifecycleRules( | ||
| ImmutableList.of( | ||
| new LifecycleRule( | ||
| LifecycleAction.newAbortIncompleteMPUploadAction(), | ||
| LifecycleCondition.newBuilder().setAge(1).build()))) | ||
| .build()); | ||
| Bucket remoteBucket = | ||
| storage.get(lifecycleTestBucketName, Storage.BucketGetOption.fields(BucketField.LIFECYCLE)); | ||
| LifecycleRule lifecycleRule = remoteBucket.getLifecycleRules().get(0); | ||
| try { | ||
| assertEquals(AbortIncompleteMPUAction.TYPE, lifecycleRule.getAction().getActionType()); | ||
| assertEquals(1, lifecycleRule.getCondition().getAge().intValue()); | ||
| } finally { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah interesting; didn't think of wrapping asserts with a try {} so you can do clean up afterwards, clever. |
||
| storage.delete(lifecycleTestBucketName); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testClearBucketDefaultKmsKeyName() throws ExecutionException, InterruptedException { | ||
| String bucketName = RemoteStorageHelper.generateBucketName(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.