|
34 | 34 | import com.google.api.gax.rpc.ApiCallContext; |
35 | 35 | import com.google.api.gax.rpc.ApiClientHeaderProvider; |
36 | 36 | import com.google.api.gax.rpc.HeaderProvider; |
| 37 | +import com.google.api.gax.rpc.StatusCode.Code; |
37 | 38 | import com.google.api.gax.rpc.TransportChannelProvider; |
38 | 39 | import com.google.auth.Credentials; |
39 | 40 | import com.google.auth.oauth2.AccessToken; |
@@ -1059,6 +1060,53 @@ public boolean isEnableLocationApi() { |
1059 | 1060 | } |
1060 | 1061 | } |
1061 | 1062 |
|
| 1063 | + @Test |
| 1064 | + public void testReadRetryableCodesIncludeResourceExhaustedWhenLocationApiEnabled() { |
| 1065 | + try { |
| 1066 | + SpannerOptions.useEnvironment( |
| 1067 | + new SpannerOptions.SpannerEnvironment() { |
| 1068 | + @Override |
| 1069 | + public boolean isEnableLocationApi() { |
| 1070 | + return true; |
| 1071 | + } |
| 1072 | + }); |
| 1073 | + GapicSpannerRpc rpc = new GapicSpannerRpc(createSpannerOptions(), true); |
| 1074 | + try { |
| 1075 | + assertThat(rpc.getReadRetryableCodes()).contains(Code.RESOURCE_EXHAUSTED); |
| 1076 | + } finally { |
| 1077 | + rpc.shutdown(); |
| 1078 | + } |
| 1079 | + } finally { |
| 1080 | + SpannerOptions.useDefaultEnvironment(); |
| 1081 | + } |
| 1082 | + } |
| 1083 | + |
| 1084 | + @Test |
| 1085 | + public void testReadRetryableCodesDoNotAddResourceExhaustedWhenLocationApiDisabled() { |
| 1086 | + try { |
| 1087 | + SpannerOptions.useEnvironment( |
| 1088 | + new SpannerOptions.SpannerEnvironment() { |
| 1089 | + @Override |
| 1090 | + public boolean isEnableLocationApi() { |
| 1091 | + return false; |
| 1092 | + } |
| 1093 | + }); |
| 1094 | + GapicSpannerRpc rpc = new GapicSpannerRpc(createSpannerOptions(), true); |
| 1095 | + try { |
| 1096 | + assertThat(rpc.getReadRetryableCodes()) |
| 1097 | + .isEqualTo( |
| 1098 | + createSpannerOptions() |
| 1099 | + .getSpannerStubSettings() |
| 1100 | + .streamingReadSettings() |
| 1101 | + .getRetryableCodes()); |
| 1102 | + } finally { |
| 1103 | + rpc.shutdown(); |
| 1104 | + } |
| 1105 | + } finally { |
| 1106 | + SpannerOptions.useDefaultEnvironment(); |
| 1107 | + } |
| 1108 | + } |
| 1109 | + |
1062 | 1110 | @Test |
1063 | 1111 | public void testGrpcGcpExtensionPreservesChannelConfigurator() throws Exception { |
1064 | 1112 | InstantiatingGrpcChannelProvider.Builder channelProviderBuilder = |
|
0 commit comments