-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7007096
commit 76b7e8c
Showing
5 changed files
with
90 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/test/java/com/snowflake/kafka/connector/internal/TestSnowflakeConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.snowflake.kafka.connector.internal; | ||
|
||
import static com.snowflake.kafka.connector.internal.TestUtils.getConfFromFileName; | ||
|
||
import com.snowflake.client.jdbc.SnowflakeDriver; | ||
import com.snowflake.kafka.connector.Utils; | ||
import java.sql.Connection; | ||
import java.util.Properties; | ||
|
||
/** Connection to test environment generated from a profile file stored locally. */ | ||
public class TestSnowflakeConnection { | ||
|
||
/** Given a profile file path name, generate a connection by constructing a snowflake driver. */ | ||
public static Connection getConnection() throws Exception { | ||
SnowflakeURL url = | ||
new SnowflakeURL(getConfFromFileName(TestUtils.PROFILE_PATH).get(Utils.SF_URL)); | ||
|
||
Properties properties = | ||
InternalUtils.createProperties(getConfFromFileName(TestUtils.PROFILE_PATH), url); | ||
|
||
return new SnowflakeDriver().connect(url.getJdbcUrl(), properties); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/test/java/com/snowflake/kafka/connector/streaming/iceberg/BaseIcebergIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.snowflake.kafka.connector.streaming.iceberg; | ||
|
||
import static com.snowflake.kafka.connector.internal.TestUtils.executeQueryWithParameter; | ||
|
||
import com.snowflake.kafka.connector.internal.SnowflakeConnectionService; | ||
import com.snowflake.kafka.connector.internal.TestUtils; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
|
||
public class BaseIcebergIT { | ||
|
||
protected static SnowflakeConnectionService conn; | ||
|
||
@BeforeAll | ||
public static void setup() { | ||
conn = TestUtils.getConnectionServiceForStreaming(); | ||
} | ||
|
||
@AfterAll | ||
public static void teardown() { | ||
conn.close(); | ||
} | ||
|
||
protected static void createIcebergTable(String tableName) throws Exception { | ||
String query = | ||
"create or replace iceberg table identifier(?) (record_metadata object())" | ||
+ "external_volume = 'test_exvol'" | ||
+ "catalog = 'SNOWFLAKE'" | ||
+ "base_location = 'it'"; | ||
executeQueryWithParameter(query, tableName); | ||
} | ||
|
||
protected static void dropIcebergTable(String tableName) { | ||
String query = "drop iceberg table if exists identifier(?)"; | ||
executeQueryWithParameter(query, tableName); | ||
} | ||
|
||
protected static void enableSchemaEvolution(String tableName) throws Exception { | ||
String query = "alter iceberg table identifier(?) set enable_schema_evolution = true"; | ||
executeQueryWithParameter(query, tableName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters