18
18
19
19
import static com .google .cloud .storage .conformance .retry .CtxFunctions .ResourceSetup .defaultSetup ;
20
20
import static com .google .cloud .storage .conformance .retry .CtxFunctions .ResourceSetup .serviceAccount ;
21
+ import static com .google .common .base .Predicates .and ;
21
22
import static com .google .common .base .Predicates .not ;
22
23
import static com .google .common .truth .Truth .assertThat ;
23
24
import static org .junit .Assert .assertTrue ;
66
67
import com .google .cloud .storage .conformance .retry .RpcMethodMappings .Mappings .ObjectAcl ;
67
68
import com .google .cloud .storage .conformance .retry .RpcMethodMappings .Mappings .Objects ;
68
69
import com .google .cloud .storage .conformance .retry .RpcMethodMappings .Mappings .ServiceAccount ;
70
+ import com .google .common .base .Predicate ;
69
71
import com .google .common .collect .ImmutableList ;
70
72
import com .google .common .collect .ImmutableMap ;
71
73
import com .google .common .collect .ListMultimap ;
108
110
final class RpcMethodMappings {
109
111
private static final Logger LOGGER = Logger .getLogger (RpcMethodMappings .class .getName ());
110
112
113
+ private static final Predicate <TestRetryConformance > groupIsDownload =
114
+ methodGroupIs ("storage.objects.download" );
115
+ private static final Predicate <TestRetryConformance > groupIsResumableUpload =
116
+ methodGroupIs ("storage.resumable.upload" );
117
+
111
118
static final int _2MiB = 2 * 1024 * 1024 ;
112
119
final Multimap <RpcMethod , RpcMethodMapping > funcMap ;
113
120
@@ -1079,7 +1086,8 @@ private static void delete(ArrayList<RpcMethodMapping> a) {
1079
1086
private static void get (ArrayList <RpcMethodMapping > a ) {
1080
1087
a .add (
1081
1088
RpcMethodMapping .newBuilder (39 , objects .get )
1082
- .withApplicable (not (TestRetryConformance ::isPreconditionsProvided ))
1089
+ .withApplicable (
1090
+ and (not (TestRetryConformance ::isPreconditionsProvided ), not (groupIsDownload )))
1083
1091
.withSetup (defaultSetup .andThen (Local .blobInfoWithoutGeneration ))
1084
1092
.withTest (
1085
1093
(ctx , c ) ->
@@ -1088,13 +1096,15 @@ private static void get(ArrayList<RpcMethodMapping> a) {
1088
1096
.build ());
1089
1097
a .add (
1090
1098
RpcMethodMapping .newBuilder (239 , objects .get )
1091
- .withApplicable (TestRetryConformance ::isPreconditionsProvided )
1099
+ .withApplicable (
1100
+ and (TestRetryConformance ::isPreconditionsProvided , not (groupIsDownload )))
1092
1101
.withTest (
1093
1102
(ctx , c ) ->
1094
1103
ctx .peek (state -> ctx .getStorage ().get (state .getBlob ().getBlobId ())))
1095
1104
.build ());
1096
1105
a .add (
1097
1106
RpcMethodMapping .newBuilder (40 , objects .get )
1107
+ .withApplicable (not (groupIsDownload ))
1098
1108
.withTest (
1099
1109
(ctx , c ) ->
1100
1110
ctx .map (
@@ -1108,6 +1118,7 @@ private static void get(ArrayList<RpcMethodMapping> a) {
1108
1118
.build ());
1109
1119
a .add (
1110
1120
RpcMethodMapping .newBuilder (41 , objects .get )
1121
+ .withApplicable (not (groupIsDownload ))
1111
1122
.withTest (
1112
1123
(ctx , c ) ->
1113
1124
ctx .map (
@@ -1196,7 +1207,8 @@ private static void get(ArrayList<RpcMethodMapping> a) {
1196
1207
.build ());
1197
1208
a .add (
1198
1209
RpcMethodMapping .newBuilder (60 , objects .get )
1199
- .withApplicable (not (TestRetryConformance ::isPreconditionsProvided ))
1210
+ .withApplicable (
1211
+ and (not (TestRetryConformance ::isPreconditionsProvided ), not (groupIsDownload )))
1200
1212
.withTest ((ctx , c ) -> ctx .peek (state -> assertTrue (state .getBlob ().exists ())))
1201
1213
.build ());
1202
1214
a .add (
@@ -1297,10 +1309,12 @@ private static void get(ArrayList<RpcMethodMapping> a) {
1297
1309
.build ());
1298
1310
a .add (
1299
1311
RpcMethodMapping .newBuilder (75 , objects .get )
1312
+ .withApplicable (not (groupIsDownload ))
1300
1313
.withTest ((ctx , c ) -> ctx .peek (state -> state .getBlob ().reload ()))
1301
1314
.build ());
1302
1315
a .add (
1303
1316
RpcMethodMapping .newBuilder (76 , objects .get )
1317
+ .withApplicable (not (groupIsDownload ))
1304
1318
.withTest (
1305
1319
(ctx , c ) ->
1306
1320
ctx .peek (
@@ -1311,7 +1325,8 @@ private static void get(ArrayList<RpcMethodMapping> a) {
1311
1325
.build ());
1312
1326
a .add (
1313
1327
RpcMethodMapping .newBuilder (107 , objects .get )
1314
- .withApplicable (not (TestRetryConformance ::isPreconditionsProvided ))
1328
+ .withApplicable (
1329
+ and (not (TestRetryConformance ::isPreconditionsProvided ), not (groupIsDownload )))
1315
1330
.withTest (
1316
1331
(ctx , c ) ->
1317
1332
ctx .map (state -> state .with (state .getBucket ().get (c .getObjectName ()))))
@@ -1321,7 +1336,8 @@ private static void get(ArrayList<RpcMethodMapping> a) {
1321
1336
private static void insert (ArrayList <RpcMethodMapping > a ) {
1322
1337
a .add (
1323
1338
RpcMethodMapping .newBuilder (46 , objects .insert )
1324
- .withApplicable (TestRetryConformance ::isPreconditionsProvided )
1339
+ .withApplicable (
1340
+ and (TestRetryConformance ::isPreconditionsProvided , not (groupIsResumableUpload )))
1325
1341
.withSetup (defaultSetup .andThen (Local .blobInfoWithGenerationZero ))
1326
1342
.withTest (
1327
1343
(ctx , c ) ->
@@ -1336,7 +1352,8 @@ private static void insert(ArrayList<RpcMethodMapping> a) {
1336
1352
.build ());
1337
1353
a .add (
1338
1354
RpcMethodMapping .newBuilder (47 , objects .insert )
1339
- .withApplicable (TestRetryConformance ::isPreconditionsProvided )
1355
+ .withApplicable (
1356
+ and (TestRetryConformance ::isPreconditionsProvided , not (groupIsResumableUpload )))
1340
1357
.withSetup (defaultSetup .andThen (Local .blobInfoWithGenerationZero ))
1341
1358
.withTest (
1342
1359
(ctx , c ) ->
@@ -1932,4 +1949,8 @@ private static void get(ArrayList<RpcMethodMapping> a) {
1932
1949
private static void put (ArrayList <RpcMethodMapping > a ) {}
1933
1950
}
1934
1951
}
1952
+
1953
+ private static Predicate <TestRetryConformance > methodGroupIs (String s ) {
1954
+ return (c ) -> s .equals (c .getMethod ().getGroup ());
1955
+ }
1935
1956
}
0 commit comments