Skip to content

Commit

Permalink
NO-SNOW: fix test failures during releasing (#663)
Browse files Browse the repository at this point in the history
We're hitting test failures during snapshot release and the reason is because there's no profile.json file, this PR adds a test mode in SnowflakeStreamingIngestClientFactory so that we can continue use dummyHost name for unit testing.

2024-01-09 23:17:26 testClientFactorySuccess(net.snowflake.ingest.streaming.internal.SnowflakeStreamingIngestClientTest) Time elapsed: 180.565 sec <<< ERROR!
2024-01-09 23:17:26 net.snowflake.ingest.utils.SFException: Unable to connect to streaming ingest internal stage.
2024-01-09 23:17:26 at net.snowflake.ingest.streaming.internal.SnowflakeStreamingIngestClientTest.testClientFactorySuccess(SnowflakeStreamingIngestClientTest.java:266)
2024-01-09 23:17:26 Caused by: net.snowflake.client.jdbc.internal.apache.http.conn.ConnectTimeoutException: Connect to snowflake.qa1.int.snowflakecomputing.com:443 [snowflake.qa1.int.snowflakecomputing.com/10.180.20.15, snowflake.qa1.int.snowflakecomputing.com/10.180.20.17, snowflake.qa1.int.snowflakecomputing.com/10.180.20.16] failed: connect timed out
2024-01-09 23:17:26 at net.snowflake.ingest.streaming.internal.SnowflakeStreamingIngestClientTest.testClientFactorySuccess(SnowflakeStreamingIngestClientTest.java:266)
2024-01-09 23:17:26 Caused by: java.net.SocketTimeoutException: connect timed out
2024-01-09 23:17:26 at net.snowflake.ingest.streaming.internal.SnowflakeStreamingIngestClientTest.testClientFactorySuccess(SnowflakeStreamingIngestClientTest.java:266)
2024-01-09 23:17:26
2024-01-09 23:17:26 testConstructorParameters(net.snowflake.ingest.streaming.internal.SnowflakeStreamingIngestClientTest) Time elapsed: 180.392 sec <<< ERROR!
  • Loading branch information
sfc-gh-tzhang authored Jan 15, 2024
1 parent c57a9fd commit d24f8e1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public static class Builder {
// Allows client to override some default parameter values
private Map<String, Object> parameterOverrides;

// Indicates whether it's under test mode
private boolean isTestMode;

private Builder(String name) {
this.name = name;
}
Expand All @@ -42,6 +45,11 @@ public Builder setParameterOverrides(Map<String, Object> parameterOverrides) {
return this;
}

public Builder setIsTestMode(boolean isTestMode) {
this.isTestMode = isTestMode;
return this;
}

public SnowflakeStreamingIngestClient build() {
Utils.assertStringNotNullOrEmpty("client name", this.name);
Utils.assertNotNull("connection properties", this.prop);
Expand All @@ -50,7 +58,7 @@ public SnowflakeStreamingIngestClient build() {
SnowflakeURL accountURL = new SnowflakeURL(prop.getProperty(Constants.ACCOUNT_URL));

return new SnowflakeStreamingIngestClientInternal<>(
this.name, accountURL, prop, this.parameterOverrides);
this.name, accountURL, prop, this.parameterOverrides, this.isTestMode);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,15 @@ public class SnowflakeStreamingIngestClientInternal<T> implements SnowflakeStrea
* @param accountURL Snowflake account url
* @param prop connection properties
* @param parameterOverrides map of parameters to override for this client
* @param isTestMode indicates whether it's under test mode
*/
public SnowflakeStreamingIngestClientInternal(
String name,
SnowflakeURL accountURL,
Properties prop,
Map<String, Object> parameterOverrides) {
this(name, accountURL, prop, null, false, null, parameterOverrides);
Map<String, Object> parameterOverrides,
boolean isTestMode) {
this(name, accountURL, prop, null, isTestMode, null, parameterOverrides);
}

/*** Constructor for TEST ONLY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public void testConstructorParameters() throws Exception {
SnowflakeStreamingIngestClientFactory.builder("client")
.setProperties(prop)
.setParameterOverrides(parameterMap)
.setIsTestMode(true)
.build();

Assert.assertEquals("client", client.getName());
Expand Down Expand Up @@ -263,7 +264,10 @@ public void testClientFactorySuccess() throws Exception {
prop.put(ROLE, TestUtils.getRole());

SnowflakeStreamingIngestClient client =
SnowflakeStreamingIngestClientFactory.builder("client").setProperties(prop).build();
SnowflakeStreamingIngestClientFactory.builder("client")
.setProperties(prop)
.setIsTestMode(true)
.build();

Assert.assertEquals("client", client.getName());
Assert.assertFalse(client.isClosed());
Expand Down

0 comments on commit d24f8e1

Please sign in to comment.