Skip to content

Commit 6a85915

Browse files
author
chengyitian
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents 7a25281 + 1a5701c commit 6a85915

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

test/com/xxdb/MultithreadedTableWriterTest.java

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.xxdb.multithreadedtablewriter.Callback;
77
import com.xxdb.multithreadedtablewriter.MultithreadedTableWriter;
88
import com.xxdb.route.AutoFitTableAppender;
9+
import com.xxdb.route.AutoFitTableUpsert;
910
import junit.framework.Assert;
1011
import org.junit.After;
1112
import org.junit.Before;
@@ -314,7 +315,20 @@ public void test_MultithreadedTableWriter_compress_morethan_cols() throws Except
314315
assertEquals(ex.getMessage(),"The number of elements in parameter compressMethods does not match the column size 3");
315316
}
316317
conn.run("undef(`t1,SHARED)");
317-
318+
}
319+
@Test(timeout = 120000)
320+
public void test_MultithreadedTableWriter_colType_not_match() throws Exception {
321+
StringBuilder sb = new StringBuilder();
322+
sb.append("t = table(1000:0, `date`idDFSDF121212中文`values_中文,[TIMESTAMP,INT,INT]);share t as t1;");
323+
conn.run(sb.toString());
324+
mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456",
325+
"", "t1", false, false, null, 10,2,5, "date");
326+
ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( System.currentTimeMillis(), "A", "A");
327+
assertEquals("code=A1 info=Invalid object error when create scalar for column 'idDFSDF121212中文': Failed to insert data. Cannot convert String to DT_INT.",pErrorInfo.toString());
328+
mutithreadTableWriter_.waitForThreadCompletion();
329+
BasicTable bt = (BasicTable) conn.run("select * from t1;");
330+
assertEquals(0, bt.rows());
331+
conn.run("undef(`t1,SHARED)");
318332
}
319333

320334
@Test(timeout = 120000)
@@ -6640,7 +6654,6 @@ public void writeCompletion(Table callbackTable) {
66406654
//Assert.assertEquals(true,mtw.getStatus().unsentRows==0);
66416655
mtw.waitForThreadCompletion();
66426656
try{conn1.run("startDataNode([\""+HOST+":"+PORT+"\"])");
6643-
66446657
}
66456658
catch(IOException ex) {
66466659
System.out.println(ex.getMessage());
@@ -7061,7 +7074,7 @@ public void test_MultithreadedTableWriter_batchSize_greater_than_Number_of_inse
70617074
}
70627075
}
70637076
//mtw.waitForThreadCompletion();
7064-
conn.run("sleep(2000)");
7077+
conn.run("sleep(5000)");
70657078
System.out.println("callback rows");
70667079

70677080

@@ -7671,6 +7684,7 @@ public void test_MultithreadedTableWriter_allDataType_array_null() throws Except
76717684
conn.close();
76727685
}
76737686

7687+
76747688
// @Test(timeout = 120000)
76757689
// public void test_insert_haStreamTable() throws Exception {
76767690
// conn.run("haTableName='ha_stream'; " +
@@ -7689,5 +7703,33 @@ public void test_MultithreadedTableWriter_allDataType_array_null() throws Except
76897703
// assertEquals(10000,ex.rows());
76907704
// mutithreadTableWriter_.waitForThreadCompletion();
76917705
// }
7706+
7707+
// @Test(timeout = 120000)
7708+
// public void test_mtw_enableHighAvailability_true() throws Exception {
7709+
// DBConnection conn1 = new DBConnection();
7710+
// conn1.connect(HOST,8802,"admin","123456");
7711+
// conn1.run("share table(10:0,`id`price`val,[INT,DOUBLE,INT]) as table1;\n");
7712+
//
7713+
// DBConnection conn2 = new DBConnection();
7714+
// conn2.connect(HOST,8803,"admin","123456");
7715+
// conn2.run("share table(10:0,`id`price`val,[INT,DOUBLE,INT]) as table1;\n");
7716+
//
7717+
// //System.out.println("节点断掉");
7718+
// //Thread.sleep(10000);
7719+
// MultithreadedTableWriter mtw1 = new MultithreadedTableWriter(HOST, PORT, "admin", "123456", "", "table1",
7720+
// false, true, ipports, 1000, 0.001f, 10, "id");
7721+
// //检查线程连接情况
7722+
// for(int i = 0;i <10000;i++) {
7723+
// int tmp =5;
7724+
// mtw1.insert(tmp, (double) tmp, 1);
7725+
// Thread.sleep(100);
7726+
// }
7727+
// mtw1.waitForThreadCompletion();
7728+
// //BasicInt writedData1 = (BasicInt) conn1.run("(exec count(*) from table1 where val = 1)[0]");
7729+
// BasicInt writedData2 = (BasicInt) conn2.run("(exec count(*) from table1 where val = 1)[0]");
7730+
// //System.out.println(writedData1);
7731+
// System.out.println(writedData2);
7732+
// }
7733+
76927734
}
76937735

0 commit comments

Comments
 (0)