From d24f8e147c2a7156d4caf35eeb262d6fbef98d0c Mon Sep 17 00:00:00 2001 From: Toby Zhang Date: Mon, 15 Jan 2024 12:59:42 -0800 Subject: [PATCH] NO-SNOW: fix test failures during releasing (#663) 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! --- .../SnowflakeStreamingIngestClientFactory.java | 10 +++++++++- .../SnowflakeStreamingIngestClientInternal.java | 6 ++++-- .../internal/SnowflakeStreamingIngestClientTest.java | 6 +++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/snowflake/ingest/streaming/SnowflakeStreamingIngestClientFactory.java b/src/main/java/net/snowflake/ingest/streaming/SnowflakeStreamingIngestClientFactory.java index 2af794cd2..cd6d78787 100644 --- a/src/main/java/net/snowflake/ingest/streaming/SnowflakeStreamingIngestClientFactory.java +++ b/src/main/java/net/snowflake/ingest/streaming/SnowflakeStreamingIngestClientFactory.java @@ -28,6 +28,9 @@ public static class Builder { // Allows client to override some default parameter values private Map parameterOverrides; + // Indicates whether it's under test mode + private boolean isTestMode; + private Builder(String name) { this.name = name; } @@ -42,6 +45,11 @@ public Builder setParameterOverrides(Map 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); @@ -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); } } } diff --git a/src/main/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientInternal.java b/src/main/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientInternal.java index 55ade4d74..071f5f7c4 100644 --- a/src/main/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientInternal.java +++ b/src/main/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientInternal.java @@ -227,13 +227,15 @@ public class SnowflakeStreamingIngestClientInternal 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 parameterOverrides) { - this(name, accountURL, prop, null, false, null, parameterOverrides); + Map parameterOverrides, + boolean isTestMode) { + this(name, accountURL, prop, null, isTestMode, null, parameterOverrides); } /*** Constructor for TEST ONLY diff --git a/src/test/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientTest.java b/src/test/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientTest.java index cb75b3a52..0eece5f02 100644 --- a/src/test/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientTest.java +++ b/src/test/java/net/snowflake/ingest/streaming/internal/SnowflakeStreamingIngestClientTest.java @@ -158,6 +158,7 @@ public void testConstructorParameters() throws Exception { SnowflakeStreamingIngestClientFactory.builder("client") .setProperties(prop) .setParameterOverrides(parameterMap) + .setIsTestMode(true) .build(); Assert.assertEquals("client", client.getName()); @@ -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());