suztomo commented on a change in pull request #14527:
URL: https://github.com/apache/beam/pull/14527#discussion_r613669141
##########
File path:
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImplTest.java
##########
@@ -1056,11 +1082,25 @@ public void testCreateTableRetry() throws IOException {
Table ret =
services.tryCreateTable(
testTable, new RetryBoundedBackOff(3, BackOff.ZERO_BACKOFF),
Sleeper.DEFAULT);
- assertEquals(testTable, ret);
+ // This assertion fails
+ // expected:<GenericData{classInfo=[clustering, creationTime, description,
+ // encryptionConfiguration, etag, expirationTime,
externalDataConfiguration, friendlyName, id,
+ // kind, labels, lastModifiedTime, location, materializedView, model,
numBytes,
+ // numLongTermBytes, numPhysicalBytes, numRows, rangePartitioning,
requirePartitionFilter,
+ // schema, selfLink, snapshotDefinition, streamingBuffer, tableReference,
timePartitioning,
+ // type, view], {tableReference=GenericData{classInfo=[datasetId,
projectId, tableId],
+ // {datasetId=dataset, projectId=project, tableId=table}}}}> but
+ //
was:<{"error":{"code":403,"errors":[{"domain":"global","reason":"rateLimitExceeded"}],"message":"rateLimitExceeded"}}>
+ // assertEquals(testTable, ret);
verify(response, times(2)).getStatusCode();
- verify(response, times(2)).getContent();
- verify(response, times(2)).getContentType();
- verifyNotNull(ret.getTableReference());
+ verify(response, times(1)).getContent();
+ verify(response, times(1)).getContentType();
+
+ // This was null
+ // verifyNotNull(ret.getTableReference());
+
+ // Google-http-client 1.39.1 does not read the content of response with
error status code. How
+ // can we ensure our library shows proper error messages to users?
expectedLogs.verifyInfo(
"Quota limit reached when creating table project:dataset.table, "
Review comment:
Before this PR, it created `GoogleJsonResponseException`. Here is the
stacktrace.
<img width="1332" alt="Screen Shot 2021-04-14 at 20 33 35"
src="https://user-images.githubusercontent.com/28604/114797265-c86dea80-9d60-11eb-8f9a-6993d085b0f3.png">
`ApiErrorExtractor` was reading the GoogleJsonResponseException that holds
the content:
```
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"reason" : "rateLimitExceeded"
} ],
"message" : "rateLimitExceeded"
}
```
AbstractGoogleClientRequest.interceptResponse was calling
`newExceptionOnError(response)`:
```
public void interceptResponse(HttpResponse response) throws
IOException {
if (responseInterceptor != null) {
responseInterceptor.interceptResponse(response);
}
if (!response.isSuccessStatusCode() &&
httpRequest.getThrowExceptionOnExecuteError()) {
throw newExceptionOnError(response);
}
}
```
In tryCreateTable
([code](https://github.com/apache/beam/blob/4b7b74673b647c8d964b4877a8d66d47096acce4/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImpl.java#L626)),
`extractor.rateLimited(e)` determines the cause of the problem.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]