Skip to content

Commit b72fe9d

Browse files
fix(speech): increment retry setting values and test timeout values in IT (#9188)
* fix(speech): increment retry setting values and test timeout values in IT * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: add settings to client builder * chore: mvn format * chore: use approach suggested in - * chore: use reasonable timeout * chore: use 10 min timeout * fix: import `SpeechSettings` --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 2d25129 commit b72fe9d

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

java-speech/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Java idiomatic client for [Cloud Speech][product-docs].
1414

1515
If you are using Maven, add this to your pom.xml file:
1616

17-
<!--- {x-version-update-start:google-cloud-speech:released} -->
1817

1918
```xml
2019
<dependency>
@@ -35,7 +34,6 @@ If you are using SBT, add this to your dependencies:
3534
```Scala
3635
libraryDependencies += "com.google.cloud" % "google-cloud-speech" % "4.7.0"
3736
```
38-
<!--- {x-version-update-end} -->
3937

4038
## Authentication
4139

java-speech/google-cloud-speech/src/test/java/com/google/cloud/speech/v1/it/ITSpeechTest.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@
1616

1717
package com.google.cloud.speech.v1.it;
1818

19+
import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
20+
import com.google.api.gax.retrying.RetrySettings;
21+
import com.google.api.gax.retrying.TimedRetryAlgorithm;
1922
import com.google.api.gax.rpc.ApiStreamObserver;
2023
import com.google.cloud.speech.v1.LongRunningRecognizeResponse;
2124
import com.google.cloud.speech.v1.RecognitionAudio;
2225
import com.google.cloud.speech.v1.RecognitionConfig;
2326
import com.google.cloud.speech.v1.RecognizeResponse;
2427
import com.google.cloud.speech.v1.SpeechClient;
28+
import com.google.cloud.speech.v1.SpeechSettings;
2529
import com.google.cloud.speech.v1.StreamingRecognitionConfig;
2630
import com.google.cloud.speech.v1.StreamingRecognizeRequest;
2731
import com.google.cloud.speech.v1.StreamingRecognizeResponse;
@@ -34,15 +38,32 @@
3438
import org.junit.Rule;
3539
import org.junit.Test;
3640
import org.junit.rules.Timeout;
41+
import org.threeten.bp.Duration;
3742

3843
public class ITSpeechTest {
3944
private static SpeechClient speechClient;
4045

41-
@Rule public Timeout globalTimeout = Timeout.seconds(300);
46+
@Rule public Timeout globalTimeout = Timeout.seconds(1000);
4247

4348
@BeforeClass
4449
public static void setupClass() throws Exception {
45-
speechClient = SpeechClient.create();
50+
TimedRetryAlgorithm timedRetryAlgorithm =
51+
OperationTimedPollAlgorithm.create(
52+
// These values are copied from com.google.cloud.speech.v1.stub.SpeechStubSettings...
53+
RetrySettings.newBuilder()
54+
.setInitialRetryDelay(Duration.ofMillis(500L))
55+
.setRetryDelayMultiplier(1.5)
56+
.setMaxRetryDelay(Duration.ofMillis(5000L))
57+
.setInitialRpcTimeout(Duration.ZERO)
58+
.setRpcTimeoutMultiplier(1.0)
59+
.setMaxRpcTimeout(Duration.ZERO)
60+
.setTotalTimeout(Duration.ofMinutes(10))
61+
.build());
62+
SpeechSettings.Builder settingsBuilder = SpeechSettings.newBuilder();
63+
settingsBuilder
64+
.longRunningRecognizeOperationSettings()
65+
.setPollingAlgorithm(timedRetryAlgorithm);
66+
speechClient = SpeechClient.create(settingsBuilder.build());
4667
}
4768

4869
@AfterClass

0 commit comments

Comments
 (0)