Skip to content

Commit

Permalink
SNOW-1739611: Verify timeouts are correctly set on http client
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dprzybysz committed Dec 12, 2024
1 parent d379857 commit b59a02f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/java/net/snowflake/client/core/HttpUtilLatestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.net.SocketTimeoutException;
import java.time.Duration;
import net.snowflake.client.category.TestTags;
import org.apache.http.client.methods.Configurable;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.hamcrest.CoreMatchers;
Expand Down Expand Up @@ -38,8 +39,18 @@ public void shouldOverrideConnectionAndSocketTimeouts() {
HttpUtil.setConnectionTimeout(100);
HttpUtil.setSocketTimeout(200);

assertEquals(Duration.ofMillis(100), HttpUtil.getConnectionTimeout());
assertEquals(Duration.ofMillis(200), HttpUtil.getSocketTimeout());

CloseableHttpClient httpClient =
HttpUtil.getHttpClient(new HttpClientSettingsKey(OCSPMode.INSECURE));

assertEquals(Duration.ofMillis(100), HttpUtil.getConnectionTimeout());
assertEquals(Duration.ofMillis(200), HttpUtil.getSocketTimeout());

assertEquals(100, ((Configurable) httpClient).getConfig().getConnectTimeout());
assertEquals(200, ((Configurable) httpClient).getConfig().getSocketTimeout());

try {
httpClient.execute(new HttpGet(HANG_WEBSERVER_ADDRESS));
fail("Request should fail with exception");
Expand Down

0 comments on commit b59a02f

Please sign in to comment.