Skip to content

Commit da8cd45

Browse files
committed
fix broken case
1 parent 46cff75 commit da8cd45

File tree

4 files changed

+67
-24
lines changed

4 files changed

+67
-24
lines changed

test/com/xxdb/LoadBalanceTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public void test_load_balance_change_nodes() throws IOException, InterruptedExce
103103
String now_host = conn.getHostName();
104104
Integer now_port = conn.getPort();
105105
controller_conn.run("try{stopDataNode('"+now_host+":"+now_port+"')}catch(ex){}");
106+
controller_conn.run("sleep(8000)");
106107
System.out.println("now host is "+conn.getHostName());
107108
System.out.println("now port is "+conn.getPort());
108109
controller_conn.run("try{startDataNode('"+now_host+":"+now_port+"')}catch(ex){}");
@@ -432,14 +433,15 @@ public void Test_getConnection_enableHighAvailability_true_enableLoadBalance_fal
432433
DBConnection controller_conn = new DBConnection();
433434
controller_conn.connect(controller_host, controller_port, "admin", "123456");
434435
controller_conn.run("try{stopDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
436+
controller_conn.run("sleep(8000)");
435437
List<DBConnection> list = new ArrayList<>();
436438
for (int i = 0; i < 100; ++i) {
437439
DBConnection connection = new DBConnection();
438440
connection.connect(HOST, PORT, "admin", "123456",null,true,ipports,false,false);
439441
list.add(connection);
440442
}
441443
controller_conn.run("try{startDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
442-
controller_conn.run("sleep(3000);");
444+
controller_conn.run("sleep(8000);");
443445
DBConnection connection1 = new DBConnection();
444446
connection1.connect(HOST, PORT, "admin", "123456",false);
445447
int port1 = port_list[1];
@@ -478,6 +480,7 @@ public void Test_getConnection_enableHighAvailability_true_enableLoadBalance_tru
478480
DBConnection controller_conn = new DBConnection();
479481
controller_conn.connect(controller_host, controller_port, "admin", "123456");
480482
controller_conn.run("try{stopDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
483+
controller_conn.run("sleep(8000)");
481484
List<DBConnection> list = new ArrayList<>();
482485
for (int i = 0; i < 100; ++i) {
483486
DBConnection connection = new DBConnection();
@@ -515,7 +518,7 @@ public void Test_getConnection_enableHighAvailability_true_enableLoadBalance_fal
515518
DBConnection controller_conn = new DBConnection();
516519
controller_conn.connect(controller_host, controller_port, "admin", "123456");
517520
controller_conn.run("try{stopDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
518-
controller_conn.run("2000");
521+
controller_conn.run("sleep(8000)");
519522
DBConnection connection = new DBConnection();
520523
String[] ipportArray = new String[1];
521524
ipportArray[0] = ipports[2];
@@ -526,7 +529,7 @@ public void Test_getConnection_enableHighAvailability_true_enableLoadBalance_fal
526529
controller_conn.run("try{startDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
527530
controller_conn.run("2000");
528531
controller_conn.run("try{stopDataNode('"+HOST+":"+node1.getInt()+"')}catch(ex){}");
529-
controller_conn.run("2000");
532+
controller_conn.run("sleep(8000)");
530533
BasicInt node2 = (BasicInt)connection.run("getNodePort()");
531534
System.out.println(node2.getString());
532535
Assert.assertEquals(PORT,node2.getInt());
@@ -565,6 +568,7 @@ public void Test_DBConnectionPool_enableHighAvailability_true_loadBalance_false_
565568
DBConnection controller_conn = new DBConnection();
566569
controller_conn.connect(controller_host, controller_port, "admin", "123456");
567570
controller_conn.run("try{stopDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
571+
controller_conn.run("sleep(8000)");
568572
DBConnectionPool pool1 = new ExclusiveDBConnectionPool(HOST,PORT,"admin","123456",100,false,true,ipports,null, false, false, false);
569573

570574
controller_conn.run("try{startDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
@@ -604,7 +608,7 @@ class MyThread1 extends Thread {
604608
public void run() {
605609
try {
606610
controller_conn.run("try{stopDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
607-
Thread.sleep(1000);
611+
Thread.sleep(6000);
608612
} catch (Exception e) {
609613
// 捕获异常并打印错误信息
610614
System.err.println("Error executing task: " + e.getMessage());
@@ -620,6 +624,7 @@ public void run() {
620624
thread.join();
621625
thread1.join();
622626
controller_conn.run("try{stopDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
627+
controller_conn.run("sleep(8000)");
623628
}
624629
@Test
625630
public void Test_DBConnectionPool_enableHighAvailability_true_loadBalance_true_highAvailabilitySites_null() throws SQLException, ClassNotFoundException, IOException {
@@ -659,7 +664,7 @@ public void Test_DBConnectionPool_enableHighAvailability_true_loadBalance_true_1
659664
DBConnection controller_conn = new DBConnection();
660665
controller_conn.connect(controller_host, controller_port, "admin", "123456");
661666
controller_conn.run("try{stopDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
662-
controller_conn.run("sleep(1000)");
667+
controller_conn.run("sleep(8000)");
663668
DBConnectionPool pool1 = new ExclusiveDBConnectionPool(HOST,PORT,"admin","123456",100,true,true,ipports,null, false, false, false);
664669
controller_conn.run("try{startDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
665670
controller_conn.run("sleep(1000)");
@@ -698,7 +703,7 @@ public void Test_DBConnectionPool_enableHighAvailability_true_loadBalance_false_
698703
DBConnection controller_conn = new DBConnection();
699704
controller_conn.connect(controller_host, controller_port, "admin", "123456");
700705
controller_conn.run("try{stopDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
701-
controller_conn.run("2000");
706+
controller_conn.run("sleep(8000)");
702707
String[] ipportArray = new String[1];
703708
ipportArray[0] = ipports[2];
704709
DBConnectionPool pool1 = new ExclusiveDBConnectionPool(HOST,PORT,"admin","123456",100,false,true,ipportArray,null, false, false, false);
@@ -709,7 +714,7 @@ public void Test_DBConnectionPool_enableHighAvailability_true_loadBalance_false_
709714
controller_conn.run("try{startDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
710715
controller_conn.run("2000");
711716
controller_conn.run("try{stopDataNode('"+HOST+":"+ipportArray[0].split(":")[1]+"')}catch(ex){}");
712-
controller_conn.run("5000");
717+
controller_conn.run("8000");
713718
List<DBTask> tasks = new ArrayList<>();
714719
for (int i = 0; i < 100; i++){
715720
BasicDBTask task = new BasicDBTask("getNodePort();");

test/com/xxdb/streaming/reverse/PollingClientReverseTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,7 +2075,7 @@ public void test_PollingClient_subscribe_backupSites_server_disconnect_backupSit
20752075
conn4.connect(HOST,port_list[2],"admin","123456");
20762076
conn4.run(script1);
20772077
conn4.run(script2);
2078-
client.unsubscribe(HOST,port_list[1],"Trades","subTread1");
2078+
//client.unsubscribe(HOST,port_list[1],"Trades","subTread1");
20792079
}
20802080

20812081
@Test(timeout = 180000)
@@ -2223,7 +2223,7 @@ public void test_PollingClient_subscribe_resubTimeout_subOnce_not_set() throws I
22232223
DBConnection controller_conn = new DBConnection();
22242224
controller_conn.connect(controller_host,controller_port,"admin","123456");
22252225
controller_conn.run("try{startDataNode('"+HOST+":"+port_list[1]+"')}catch(ex){}");
2226-
controller_conn.run("sleep(1000)");
2226+
controller_conn.run("sleep(10000)");
22272227
String script1 = "st1 = streamTable(1000000:0,`tag`ts`data,[INT,TIMESTAMP,DOUBLE])\n" +
22282228
"share(st1,`Trades)\t\n"
22292229
+ "setStreamTableFilterColumn(objByName(`Trades),`tag)";
@@ -2257,7 +2257,7 @@ public void test_PollingClient_subscribe_resubTimeout_subOnce_not_set() throws I
22572257
//List<IMessage> messages1 = poller.poll(2000,2000);
22582258
// MessageHandler_handler(messages1);
22592259
controller_conn.run("try{startDataNode('"+HOST+":"+port_list[1]+"')}catch(ex){}");
2260-
Thread.sleep(2000);
2260+
Thread.sleep(10000);
22612261
DBConnection conn3 = new DBConnection();
22622262
conn3.connect(HOST,port_list[1],"admin","123456");
22632263
conn3.run(script1);
@@ -2270,7 +2270,7 @@ public void test_PollingClient_subscribe_resubTimeout_subOnce_not_set() throws I
22702270
List<IMessage> messages2 = poller.poll(3000,3000);
22712271
MessageHandler_handler(messages2);
22722272
controller_conn.run("try{startDataNode('"+HOST+":"+port_list[2]+"')}catch(ex){}");
2273-
Thread.sleep(5000);
2273+
Thread.sleep(10000);
22742274

22752275
BasicTable row_num = (BasicTable)conn.run("select count(*) from Receive");
22762276
System.out.println(row_num.getColumn(0).get(0));

test/com/xxdb/streaming/reverse/ThreadPooledClientReverseTest.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,7 @@ public void Test_ThreadPooledClient_subscribe_backupSites_server_disconnect_back
18851885
conn4.connect(HOST,port_list[2],"admin","123456");
18861886
conn4.run(script1);
18871887
conn4.run(script2);
1888-
client.unsubscribe(HOST,port_list[1],"Trades","subTread1");
1888+
//client.unsubscribe(HOST,port_list[1],"Trades","subTread1");
18891889
}
18901890

18911891
@Test(timeout = 180000)
@@ -2141,4 +2141,42 @@ public void test_subscribe_getOffset() throws Exception{
21412141
}
21422142
client1.unsubscribe(HOST, PORT, "Trades");
21432143
}
2144+
2145+
// public static MessageHandler MessageHandler_handler_null = new MessageHandler() {
2146+
// @Override
2147+
// public void doEvent(IMessage msg) {
2148+
// try {
2149+
// String script = String.format("insert into Receive values(%d,%s,%f)", Integer.parseInt(msg.getEntity(0).getString()), msg.getEntity(1).getString(), Double.valueOf(msg.getEntity(2).toString()));
2150+
// DBConnection conn = new DBConnection();
2151+
// conn.connect(HOST, PORT, "admin", "123456");
2152+
// conn.run(script);
2153+
// System.out.println(msg.getEntity(0).getString());
2154+
// } catch (IOException e) {
2155+
// e.printStackTrace();
2156+
// }
2157+
// }
2158+
// };
2159+
// @Test(timeout = 180000)
2160+
// public void test_subscribe_null() throws Exception{
2161+
// DBConnection conn = new DBConnection();
2162+
// conn.connect(HOST, PORT, "admin", "123456");
2163+
// String script0 = "login(`admin,`123456);" +
2164+
// "try{undef(`quote_commodity_stream, SHARED);}catch(ex){};"+
2165+
// "try{undef(`Receive, SHARED);}catch(ex){};"+
2166+
// "try{dropStreamTable('quote_commodity_stream')}catch(ex){};"+
2167+
// "try{dropStreamTable('Receive')}catch(ex){};";
2168+
// conn.run(script0);
2169+
// String script1 = "quote_commodity_ts = streamTable(100:0, [`time, `sym, `exch_time, `exch, `source, `broker, `tot_notional, `tot_sz, `last_px, `bid_sz1, `bid_px1, `ask_px1, `ask_sz1, `open, `high, `low, `close, `pre_close, `oi, `pre_oi, `settlement_px, `pre_settlement_px, `rec_time, `pub_time, `bid_sz2, `bid_px2, `ask_px2, `ask_sz2, `bid_sz3, `bid_px3, `ask_px3, `ask_sz3, `bid_sz4, `bid_px4, `ask_px4, `ask_sz4, `bid_sz5, `bid_px5, `ask_px5, `ask_sz5, `upper_limit, `lower_limit, `pre_delta, `curr_delta, `trading_date, `settlement_id, `settlement_group_id], [NANOTIMESTAMP, SYMBOL, NANOTIMESTAMP, SYMBOL, SYMBOL, SYMBOL, LONG, LONG, DOUBLE, LONG, DOUBLE, DOUBLE, LONG, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, LONG, LONG, DOUBLE, DOUBLE, NANOTIMESTAMP, NANOTIMESTAMP, LONG, DOUBLE, DOUBLE, LONG, LONG, DOUBLE, DOUBLE, LONG, LONG, DOUBLE, DOUBLE, LONG, LONG, DOUBLE, DOUBLE, LONG, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DATE, LONG, LONG])\n" +
2170+
// "enableTableShareAndPersistence(table=quote_commodity_ts, tableName=`quote_commodity_stream, cacheSize=50000, preCache = 50000,retentionMinutes=1440)";
2171+
// conn.run(script1);
2172+
// String script2 = "st2 = streamTable(1000000:0,`tag`ts`data,[INT,TIMESTAMP,DOUBLE])\n" +
2173+
// "enableTableShareAndPersistence(table=st2, tableName=`Receive, asynWrite=true, compress=true, cacheSize=200000, retentionMinutes=180)\t\n";
2174+
// conn.run(script2);
2175+
// ThreadPooledClient client = new ThreadPooledClient(HOST,PORT,3);
2176+
// System.out.println("client created");
2177+
// client.subscribe(HOST, PORT, "quote_commodity_stream", "subTrades", MessageHandler_handler_null, -1, true);
2178+
// System.out.println("client created");
2179+
// }
2180+
2181+
21442182
}

test/com/xxdb/streaming/reverse/ThreadedClientsubscribeReverseTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,10 @@ public void test_subscribe_tableName_handler_offset_reconnect_success() throws I
490490
MyThread write_data = new MyThread ();
491491
write_data.start();
492492
Thread.sleep(2000);
493-
conn.run("stopPublishTable('"+HOST+"',9055,'Trades')");
493+
conn.run("stopPublishTable('"+HOST+"',9055,'Trades','javaStreamingApi')");
494494
Thread.sleep(2000);
495-
conn.run("stopPublishTable('"+HOST+"',9055,'Trades')");
496-
Thread.sleep(3000);
495+
// conn.run("stopPublishTable('"+HOST+"',9055,'Trades')");
496+
// Thread.sleep(3000);
497497
BasicInt row_num = (BasicInt)conn.run("(exec count(*) from Receive)[0]");
498498
System.out.println(row_num);
499499
Thread.sleep(2000);
@@ -521,8 +521,8 @@ public void test_subscribe_TableName_ActionName_Handler_reconnect() throws IOExc
521521
Thread.sleep(2000);
522522
conn.run("stopPublishTable('"+HOST+"',9055,'Trades',\"subTrades\")");
523523
Thread.sleep(2000);
524-
conn.run("stopPublishTable('"+HOST+"',9055,'Trades',\"subTrades\")");
525-
Thread.sleep(3000);
524+
//conn.run("stopPublishTable('"+HOST+"',9055,'Trades',\"subTrades\")");
525+
//Thread.sleep(3000);
526526
BasicInt row_num = (BasicInt)conn.run("(exec count(*) from Receive)[0]");
527527
System.out.println(row_num);
528528
Thread.sleep(2000);
@@ -550,8 +550,8 @@ public void test_subscribe_tn_an_hd_ofst_reconnect_filter_ae_bs_thFloat_usr_pass
550550
Thread.sleep(2000);
551551
conn.run("stopPublishTable('"+HOST+"',8676,'Trades','subTread1')");
552552
Thread.sleep(2000);
553-
conn.run("stopPublishTable('"+HOST+"',8676,'Trades','subTread1')");
554-
Thread.sleep(3000);
553+
//conn.run("stopPublishTable('"+HOST+"',8676,'Trades','subTread1')");
554+
//Thread.sleep(3000);
555555
BasicInt row_num = (BasicInt)conn.run("(exec count(*) from Receive)[0]");
556556
System.out.println(row_num);
557557
Thread.sleep(2000);
@@ -578,7 +578,7 @@ public void test_subscribe_tn_an_bmhd_ofst_reconnect_filter_ae_bs_th_usr_pass()
578578
Thread.sleep(2000);
579579
conn.run("stopPublishTable('"+HOST+"',8676,'Trades','subTread1')");
580580
Thread.sleep(2000);
581-
conn.run("stopPublishTable('"+HOST+"',8676,'Trades','subTread1')");
581+
//conn.run("stopPublishTable('"+HOST+"',8676,'Trades','subTread1')");
582582
Thread.sleep(3000);
583583
BasicInt row_num = (BasicInt)conn.run("(exec count(*) from Receive)[0]");
584584
System.out.println(row_num);
@@ -607,8 +607,8 @@ public void test_subscribe_tn_an_bmhd_ofst_reconnect_filter_ae_bs_thFloat_usr_pa
607607
Thread.sleep(2000);
608608
conn.run("stopPublishTable('"+HOST+"',8676,'Trades','subTread1')");
609609
Thread.sleep(2000);
610-
conn.run("stopPublishTable('"+HOST+"',8676,'Trades','subTread1')");
611-
Thread.sleep(3000);
610+
//conn.run("stopPublishTable('"+HOST+"',8676,'Trades','subTread1')");
611+
//Thread.sleep(3000);
612612
BasicInt row_num = (BasicInt)conn.run("(exec count(*) from Receive)[0]");
613613
System.out.println(row_num);
614614
Thread.sleep(2000);
@@ -1328,7 +1328,7 @@ public void test_subscribe_reconnect_false() throws IOException, InterruptedExce
13281328
Thread.sleep(5000);
13291329
BasicInt row_num = (BasicInt)conn.run("(exec count(*) from Receive)[0]");
13301330
assertNotEquals(2000,row_num.getInt());
1331-
client.unsubscribe(HOST,PORT,"Trades","subTread2");
1331+
//client.unsubscribe(HOST,PORT,"Trades","subTread2");
13321332
}
13331333

13341334
class Handler6 implements MessageHandler {
@@ -3423,7 +3423,7 @@ public void test_ThreadClient_subscribe_backupSites_server_disconnect_backupSite
34233423
conn4.connect(HOST,port_list[2],"admin","123456");
34243424
conn4.run(script1);
34253425
conn4.run(script2);
3426-
client.unsubscribe(HOST,port_list[1],"Trades","subTread1");
3426+
//client.unsubscribe(HOST,port_list[1],"Trades","subTread1");
34273427
}
34283428

34293429
@Test(timeout = 180000)

0 commit comments

Comments
 (0)