@@ -4846,6 +4846,24 @@ func TestIntegration_SoftDelete(t *testing.T) {
4846
4846
t .Fatalf ("effective time of soft delete policy should not be in the past, got: %v, test start: %v" , got .EffectiveTime , testStart .UTC ())
4847
4847
}
4848
4848
4849
+ // Update the soft delete policy of the bucket.
4850
+ policy .RetentionDuration = time .Hour * 24 * 9
4851
+ // Retry to account for metadata propagation delay.
4852
+ if err := retry (ctx , func () error {
4853
+ attrs , err = b .Update (ctx , BucketAttrsToUpdate {SoftDeletePolicy : policy })
4854
+ if err != nil {
4855
+ return fmt .Errorf ("b.Update: %v" , err )
4856
+ }
4857
+ return nil
4858
+ }, func () error {
4859
+ if got , expect := attrs .SoftDeletePolicy .RetentionDuration , policy .RetentionDuration ; got != expect {
4860
+ return fmt .Errorf ("mismatching retention duration; got: %+v, expected: %+v" , got , expect )
4861
+ }
4862
+ return nil
4863
+ }); err != nil {
4864
+ t .Error (err )
4865
+ }
4866
+
4849
4867
// Create a second bucket with an empty soft delete policy to verify
4850
4868
// that this leads to no retention.
4851
4869
b2 := client .Bucket (prefix + uidSpace .New ())
@@ -4862,23 +4880,7 @@ func TestIntegration_SoftDelete(t *testing.T) {
4862
4880
t .Fatalf ("mismatching retention duration; got: %+v, expected: %+v" , got , expect )
4863
4881
}
4864
4882
4865
- // Update the soft delete policy of the original bucket.
4866
- policy .RetentionDuration = time .Hour * 24 * 9
4867
-
4868
- retry (ctx , func () error {
4869
- attrs , err = b .Update (ctx , BucketAttrsToUpdate {SoftDeletePolicy : policy })
4870
- if err != nil {
4871
- return fmt .Errorf ("b.Update: %v" , err )
4872
- }
4873
- return nil
4874
- }, func () error {
4875
- if got , expect := attrs .SoftDeletePolicy .RetentionDuration , policy .RetentionDuration ; got != expect {
4876
- return fmt .Errorf ("mismatching retention duration; got: %+v, expected: %+v" , got , expect )
4877
- }
4878
- return nil
4879
- })
4880
-
4881
- // Create 2 objects and delete one of them.
4883
+ // Create 2 objects in the original bucket and delete one of them.
4882
4884
deletedObject := b .Object ("soft-delete" + uidSpaceObjects .New ())
4883
4885
liveObject := b .Object ("not-soft-delete" + uidSpaceObjects .New ())
4884
4886
@@ -4937,8 +4939,14 @@ func TestIntegration_SoftDelete(t *testing.T) {
4937
4939
if oAttrs .SoftDeleteTime .Before (testStart ) {
4938
4940
t .Fatalf ("SoftDeleteTime of soft deleted object should not be in the past, got: %v, test start: %v" , oAttrs .SoftDeleteTime , testStart .UTC ())
4939
4941
}
4940
- if got , expected := oAttrs .HardDeleteTime , oAttrs .SoftDeleteTime .Add (policy .RetentionDuration ); ! expected .Equal (got ) {
4941
- t .Fatalf ("HardDeleteTime of soft deleted object should be equal to SoftDeleteTime+RetentionDuration, got: %v, expected: %v" , got , expected )
4942
+
4943
+ if err := retry (ctx , func () error {
4944
+ if got , expected := oAttrs .HardDeleteTime , oAttrs .SoftDeleteTime .Add (policy .RetentionDuration ); ! expected .Equal (got ) {
4945
+ return fmt .Errorf ("HardDeleteTime of soft deleted object should be equal to SoftDeleteTime+RetentionDuration, got: %v, expected: %v" , got , expected )
4946
+ }
4947
+ return nil
4948
+ }, func () error { return nil }); err != nil {
4949
+ t .Fatal (err )
4942
4950
}
4943
4951
4944
4952
// Restore a soft deleted object.
0 commit comments