Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-tzhang committed Mar 21, 2024
1 parent 1242deb commit 90af5e6
Showing 1 changed file with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package net.snowflake.ingest.streaming.internal;

import static net.snowflake.ingest.utils.Constants.BLOB_NO_HEADER;
import static net.snowflake.ingest.utils.Constants.COMPRESS_BLOB_TWICE;
import static net.snowflake.ingest.utils.Constants.DROP_CHANNEL_ENDPOINT;
import static net.snowflake.ingest.utils.Constants.REGISTER_BLOB_ENDPOINT;
import static net.snowflake.ingest.utils.Constants.*;
import static net.snowflake.ingest.utils.ParameterProvider.BDEC_PARQUET_COMPRESSION_ALGORITHM;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
Expand Down Expand Up @@ -33,11 +30,7 @@
import java.util.stream.IntStream;
import net.snowflake.ingest.TestUtils;
import net.snowflake.ingest.connection.RequestBuilder;
import net.snowflake.ingest.streaming.InsertValidationResponse;
import net.snowflake.ingest.streaming.OffsetTokenVerificationFunction;
import net.snowflake.ingest.streaming.OpenChannelRequest;
import net.snowflake.ingest.streaming.SnowflakeStreamingIngestChannel;
import net.snowflake.ingest.streaming.SnowflakeStreamingIngestClientFactory;
import net.snowflake.ingest.streaming.*;
import net.snowflake.ingest.utils.Constants;
import net.snowflake.ingest.utils.ErrorCode;
import net.snowflake.ingest.utils.HttpUtil;
Expand Down Expand Up @@ -142,7 +135,9 @@ public void beforeAll() throws Exception {

@After
public void afterAll() throws Exception {
client.close();
if (client != null) {
client.close();
}
jdbcConnection.createStatement().execute(String.format("drop database %s", testDb));
}

Expand Down Expand Up @@ -1399,6 +1394,22 @@ public void testTableColumnEvolution() throws Exception {
ingestByColIndexAndVerifyTable(tableName, channelNum, Arrays.asList(2, 3, 5, 6), rowNum);
}

@Test
public void testLeakedHTTPConnectionFix() throws Exception {
prop = TestUtils.getProperties(Constants.BdecVersion.THREE, true);
prop.setProperty(BDEC_PARQUET_COMPRESSION_ALGORITHM, compressionAlgorithm);
prop.setProperty(USER, "badUser");

for (int i = 0; i < 20; i++) {
try (SnowflakeStreamingIngestClient client =
SnowflakeStreamingIngestClientFactory.builder("MY_CLIENT").setProperties(prop).build()) {
} catch (Exception ignored) {

}
Thread.sleep(5000);
}
}

/**
* Ingests rows into a table and verifies them by querying the table.
*
Expand Down

0 comments on commit 90af5e6

Please sign in to comment.