@@ -45,7 +45,7 @@ public class RemoteBigQueryHelper {
4545 private static final String MODEL_NAME_PREFIX = "model_" ;
4646 private static final String ROUTINE_NAME_PREFIX = "routine_" ;
4747 private final BigQueryOptions options ;
48- private static final int connectTimeout = 60000 ;
48+ private static final int CONNECT_TIMEOUT_IN_MS = 60000 ;
4949
5050 private RemoteBigQueryHelper (BigQueryOptions options ) {
5151 this .options = options ;
@@ -96,8 +96,8 @@ public static RemoteBigQueryHelper create(String projectId, InputStream keyStrea
9696 HttpTransportOptions transportOptions = BigQueryOptions .getDefaultHttpTransportOptions ();
9797 transportOptions =
9898 transportOptions .toBuilder ()
99- .setConnectTimeout (connectTimeout )
100- .setReadTimeout (connectTimeout )
99+ .setConnectTimeout (CONNECT_TIMEOUT_IN_MS )
100+ .setReadTimeout (CONNECT_TIMEOUT_IN_MS )
101101 .build ();
102102 BigQueryOptions bigqueryOptions =
103103 BigQueryOptions .newBuilder ()
@@ -133,8 +133,8 @@ public static RemoteBigQueryHelper create(BigQueryOptions.Builder bigqueryOption
133133 HttpTransportOptions transportOptions = BigQueryOptions .getDefaultHttpTransportOptions ();
134134 transportOptions =
135135 transportOptions .toBuilder ()
136- .setConnectTimeout (connectTimeout )
137- .setReadTimeout (connectTimeout )
136+ .setConnectTimeout (CONNECT_TIMEOUT_IN_MS )
137+ .setReadTimeout (CONNECT_TIMEOUT_IN_MS )
138138 .build ();
139139 BigQueryOptions .Builder builder =
140140 bigqueryOptionsBuilder
@@ -143,21 +143,25 @@ public static RemoteBigQueryHelper create(BigQueryOptions.Builder bigqueryOption
143143 return new RemoteBigQueryHelper (builder .build ());
144144 }
145145
146+ // Opt to keep these settings a small as possible to minimize the total test time.
147+ // These values can be adjusted per test case, but these serve as default values.
146148 private static RetrySettings retrySettings () {
147- double retryDelayMultiplier = 1.0 ;
149+ double multiplier = 1.5 ;
148150 int maxAttempts = 10 ;
149- long initialRetryDelay = 250L ;
150- long maxRetryDelay = 30000L ;
151- long totalTimeOut = 120000L ;
151+ long initialRetryDelayMs = 100L ; // 0.1s initial retry delay
152+ long maxRetryDelayMs = 1000L ; // 1s max retry delay between retry
153+ long initialRpcTimeoutMs = 1000L ; // 1s initial rpc duration
154+ long maxRpcTimeoutMs = 2000L ; // 2s max rpc duration
155+ long totalTimeOut = 3000L ; // 3s total timeout
152156 return RetrySettings .newBuilder ()
153157 .setMaxAttempts (maxAttempts )
154- .setMaxRetryDelayDuration (Duration .ofMillis (maxRetryDelay ))
155158 .setTotalTimeoutDuration (Duration .ofMillis (totalTimeOut ))
156- .setInitialRetryDelayDuration (Duration .ofMillis (initialRetryDelay ))
157- .setRetryDelayMultiplier (retryDelayMultiplier )
158- .setInitialRpcTimeoutDuration (Duration .ofMillis (totalTimeOut ))
159- .setRpcTimeoutMultiplier (retryDelayMultiplier )
160- .setMaxRpcTimeoutDuration (Duration .ofMillis (totalTimeOut ))
159+ .setInitialRetryDelayDuration (Duration .ofMillis (initialRetryDelayMs ))
160+ .setMaxRetryDelayDuration (Duration .ofMillis (maxRetryDelayMs ))
161+ .setRetryDelayMultiplier (multiplier )
162+ .setInitialRpcTimeoutDuration (Duration .ofMillis (initialRpcTimeoutMs ))
163+ .setMaxRpcTimeoutDuration (Duration .ofMillis (maxRpcTimeoutMs ))
164+ .setRpcTimeoutMultiplier (multiplier )
161165 .build ();
162166 }
163167
0 commit comments