Skip to content

Commit

Permalink
fix(speech): increment retry setting values and test timeout values i…
Browse files Browse the repository at this point in the history
…n 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>
  • Loading branch information
diegomarquezp and gcf-owl-bot[bot] committed Mar 4, 2023
1 parent 2d25129 commit b72fe9d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 0 additions & 2 deletions java-speech/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Java idiomatic client for [Cloud Speech][product-docs].

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

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

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

## Authentication

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@

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

import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.retrying.TimedRetryAlgorithm;
import com.google.api.gax.rpc.ApiStreamObserver;
import com.google.cloud.speech.v1.LongRunningRecognizeResponse;
import com.google.cloud.speech.v1.RecognitionAudio;
import com.google.cloud.speech.v1.RecognitionConfig;
import com.google.cloud.speech.v1.RecognizeResponse;
import com.google.cloud.speech.v1.SpeechClient;
import com.google.cloud.speech.v1.SpeechSettings;
import com.google.cloud.speech.v1.StreamingRecognitionConfig;
import com.google.cloud.speech.v1.StreamingRecognizeRequest;
import com.google.cloud.speech.v1.StreamingRecognizeResponse;
Expand All @@ -34,15 +38,32 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
import org.threeten.bp.Duration;

public class ITSpeechTest {
private static SpeechClient speechClient;

@Rule public Timeout globalTimeout = Timeout.seconds(300);
@Rule public Timeout globalTimeout = Timeout.seconds(1000);

@BeforeClass
public static void setupClass() throws Exception {
speechClient = SpeechClient.create();
TimedRetryAlgorithm timedRetryAlgorithm =
OperationTimedPollAlgorithm.create(
// These values are copied from com.google.cloud.speech.v1.stub.SpeechStubSettings...
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(500L))
.setRetryDelayMultiplier(1.5)
.setMaxRetryDelay(Duration.ofMillis(5000L))
.setInitialRpcTimeout(Duration.ZERO)
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ZERO)
.setTotalTimeout(Duration.ofMinutes(10))
.build());
SpeechSettings.Builder settingsBuilder = SpeechSettings.newBuilder();
settingsBuilder
.longRunningRecognizeOperationSettings()
.setPollingAlgorithm(timedRetryAlgorithm);
speechClient = SpeechClient.create(settingsBuilder.build());
}

@AfterClass
Expand Down

0 comments on commit b72fe9d

Please sign in to comment.