Skip to content

Commit dd32477

Browse files
authored
Merge pull request #350 from youngsofun/fix
ci: fix conflict in table
2 parents 0f892e9 + bc76dce commit dd32477

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

databend-jdbc/src/test/java/com/databend/jdbc/TestBasicDriver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public void testDefaultSelectNullValue() throws SQLException {
186186
try (Connection connection = Utils.createConnection();
187187
Statement statement = connection.createStatement()
188188
) {
189-
statement.execute("create table test_basic_driver.table_with_null(a int,b varchar default null, c varchar, d varchar)");
189+
statement.execute("create or replace table test_basic_driver.table_with_null(a int,b varchar default null, c varchar, d varchar)");
190190
statement.execute("insert into test_basic_driver.table_with_null(a,b,c,d) values(1,null,'null','NULL')");
191191
statement.execute("SELECT a,b,c,d from test_basic_driver.table_with_null");
192192
ResultSet r = statement.getResultSet();
@@ -241,8 +241,8 @@ public void testBasicWithProperties() throws SQLException {
241241
@Test(groups = {"IT"})
242242
public void testPrepareStatementQuery() throws SQLException {
243243
String sql = "SELECT number from numbers(100) where number = ? or number = ?";
244-
Connection conn = Utils.createConnection("test_basic_driver");
245-
try (PreparedStatement statement = conn.prepareStatement(sql)) {
244+
try (Connection conn = Utils.createConnection("test_basic_driver");
245+
PreparedStatement statement = conn.prepareStatement(sql)) {
246246
statement.setInt(1, 1);
247247
statement.setInt(2, 2);
248248
ResultSet r = statement.executeQuery();

databend-jdbc/src/test/java/com/databend/jdbc/TestFileTransfer.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import okhttp3.OkHttpClient;
88
import org.testng.Assert;
99
import org.testng.annotations.BeforeTest;
10+
import org.testng.annotations.DataProvider;
1011
import org.testng.annotations.Test;
1112

1213
import java.io.*;
@@ -16,6 +17,7 @@
1617
import java.sql.ResultSet;
1718
import java.sql.SQLException;
1819
import java.sql.Statement;
20+
import java.util.UUID;
1921
import java.util.logging.Level;
2022
import java.util.logging.Logger;
2123

@@ -53,7 +55,7 @@ private String generateRandomCSV(int lines) throws IOException {
5355
return "";
5456
}
5557
String tmpDir = System.getProperty("java.io.tmpdir");
56-
String csvPath = tmpDir + "/test.csv";
58+
String csvPath = tmpDir + "/" + UUID.randomUUID();
5759
try (FileWriter writer = new FileWriter(csvPath)) {
5860
for (int i = 0; i < lines; i++) {
5961
int num = (int) (Math.random() * 1000);
@@ -114,6 +116,7 @@ public void testFileTransfer()
114116
databendConnection.uploadStream(stageName, "jdbc/test/", fileInputStream, "test.csv", f.length(), false);
115117
downloaded = databendConnection.downloadStream(stageName, "jdbc/test/test.csv", false);
116118
byte[] arr = streamToByteArray(downloaded);
119+
System.out.println("download size = " + arr.length);
117120
Assert.assertEquals(arr.length, f.length());
118121
} finally {
119122
if (downloaded != null) {
@@ -124,14 +127,14 @@ public void testFileTransfer()
124127

125128
@Test(groups = {"IT"})
126129
public void testFileTransferThroughAPI() throws SQLException, IOException {
127-
String filePath = generateRandomCSV(100000);
130+
String filePath = generateRandomCSV(10000);
128131
File f = new File(filePath);
129132
try (InputStream fileInputStream = Files.newInputStream(f.toPath());
130133
Connection connection = Utils.createConnectionWithPresignedUrlDisable()) {
131134
Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.ALL);
132135

133136

134-
String stageName = "test_stage";
137+
String stageName = "test_stage_np";
135138
DatabendConnection databendConnection = connection.unwrap(DatabendConnection.class);
136139
PresignContext.createStageIfNotExists(databendConnection, stageName);
137140
databendConnection.uploadStream(stageName, "jdbc/test/", fileInputStream, "test.csv", f.length(), false);
@@ -165,17 +168,16 @@ public void testCopyInto() throws IOException, SQLException {
165168
}
166169
}
167170

168-
@Test(groups = {"IT"})
169-
public void testLoadStreamToTableWithStage() throws SQLException, IOException {
170-
testLoadStreamToTableInner("stage");
171-
}
172-
173-
@Test(groups = {"IT"})
174-
public void testLoadStreamToTableWithStreaming() throws SQLException, IOException {
175-
testLoadStreamToTableInner("streaming");
171+
@DataProvider(name = "streamingLoad")
172+
private Object[][] provideTestData() {
173+
return new Object[][] {
174+
{"streaming"},
175+
{"stage"}
176+
};
176177
}
177178

178-
public void testLoadStreamToTableInner(String method) throws IOException, SQLException {
179+
@Test(groups = "IT", dataProvider = "streamingLoad")
180+
public void testLoadStreamToTable(String method) throws IOException, SQLException {
179181
if (!Compatibility.driverCapability.streamingLoad) {
180182
System.out.println("Skip testLoadStreamToTableInner: driver version too low");
181183
return;
@@ -190,8 +192,9 @@ public void testLoadStreamToTableInner(String method) throws IOException, SQLExc
190192
try (FileInputStream fileInputStream = new FileInputStream(f);
191193
Connection connection = Utils.createConnectionWithPresignedUrlDisable();
192194
Statement statement = connection.createStatement()) {
193-
statement.execute("create or replace database test_load");
194-
statement.execute("use test_load");
195+
String dbName = "test_load_stream_" + method;
196+
statement.execute(String.format("create or replace database %s", dbName));
197+
statement.execute(String.format("use %s", dbName));
195198
statement.execute("create or replace table test_load(i int, a Variant, b string)");
196199
DatabendConnection databendConnection = connection.unwrap(DatabendConnection.class);
197200
String sql = "insert into test_load from @_databend_load file_format=(type=csv)";

databend-jdbc/src/test/java/com/databend/jdbc/TestPrepareStatement.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ public class TestPrepareStatement {
2525
private static final ThreadLocal<String> METHOD_NAME = new ThreadLocal<>();
2626
private static final ThreadLocal<String> DB_NAME = new ThreadLocal<>();
2727

28-
@BeforeMethod
28+
@BeforeMethod(groups = "IT")
2929
public void captureMethod(Method method) {
3030
METHOD_NAME.set(method.getName());
3131
String dbName = "TestPrepareStatement_" + METHOD_NAME.get();
3232
DB_NAME.set(dbName.toLowerCase());
33+
System.out.println("【DEBUG】DB_NAME = " + METHOD_NAME.get());
3334
}
3435

3536
Connection getConn() throws SQLException {
@@ -110,7 +111,7 @@ public void TestBatchInsertWithNULL() throws SQLException {
110111
}
111112

112113
@Test(groups = "UNIT")
113-
public void TestConvertSQLWithBatchValues() throws SQLException {
114+
public void TestConvertSQLWithBatchValues() {
114115
List<String[]> batchValues = new ArrayList<>();
115116
// Add string arrays to batchValues
116117
String[] values1 = { "1" };

tests/compatibility/testng.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<suite name="DatabendJdbcTests" verbose="10">
1+
<suite name="DatabendJdbcTests" verbose="10" parallel="methods">
22
<test name="AllTests">
33
<groups>
44
<run>

0 commit comments

Comments
 (0)