Skip to content

Commit 7fb95a4

Browse files
author
chengyitian
committed
Merge remote-tracking branch 'origin/release130' into release130
2 parents 8e094b9 + 62043a8 commit 7fb95a4

File tree

5 files changed

+166
-94
lines changed

5 files changed

+166
-94
lines changed

test/com/xxdb/ConnectionPoolTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,7 @@ public void test_pool_execute_timeout_5000() throws Exception {
19611961
connectionPool.waitForThreadCompletion();
19621962
connectionPool.shutdown();
19631963
}
1964-
@Test
1964+
//@Test
19651965
public void test_pool_execute_timeout_negative() throws Exception {
19661966
ExclusiveDBConnectionPool connectionPool = new ExclusiveDBConnectionPool(HOST, PORT,
19671967
"admin", "123456", 3, false, true,

test/com/xxdb/DBConnectionTest.java

Lines changed: 90 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2829,7 +2829,7 @@ public void run() {
28292829
thread.start();
28302830
}
28312831

2832-
@Test
2832+
// @Test
28332833
public void test_DBconnection_reconnect_false(){
28342834
DBConnection conn_re = new DBConnection();
28352835
try {
@@ -2841,7 +2841,7 @@ public void test_DBconnection_reconnect_false(){
28412841
}
28422842
}
28432843

2844-
@Test
2844+
//@Test
28452845
public void test_DBconnection_reconnect_true() throws InterruptedException {
28462846
DBConnection conn_re = new DBConnection();
28472847
class reconnect extends TimerTask {
@@ -2860,8 +2860,8 @@ public void run() {
28602860
}
28612861
Timer timer = new Timer("Timer");
28622862
TimerTask rec = new reconnect();
2863-
timer.scheduleAtFixedRate(rec, 0L, 1000L);
2864-
Thread.sleep(5000L);
2863+
timer.scheduleAtFixedRate(rec, 0L, 500L);
2864+
Thread.sleep(500L);
28652865
timer.cancel();
28662866
}
28672867

@@ -3698,7 +3698,7 @@ public void TestConnectWithoutUserid() throws IOException, InterruptedException
36983698
assertEquals(true, conn.isConnected());
36993699
}
37003700
@Test
3701-
public void TestConnectEnableHighAvailability_false() throws IOException, InterruptedException {
3701+
public void Test_connect_EnableHighAvailability_false() throws IOException, InterruptedException {
37023702
DBConnection conn = new DBConnection();
37033703
conn.connect(HOST,CONTROLLER_PORT,"admin","123456",null,false);
37043704
DBConnection conn1 = new DBConnection();
@@ -3708,7 +3708,9 @@ public void TestConnectEnableHighAvailability_false() throws IOException, Interr
37083708
try{
37093709
conn.run("stopDataNode(\""+nodeAlias+"\")");
37103710
}catch(Exception ex)
3711-
{}
3711+
{
3712+
System.out.println(ex);
3713+
}
37123714
//DBConnection conn1 = new DBConnection();
37133715
conn1.connect(HOST,PORT,"admin","123456",null,false);
37143716
Thread.sleep(500);
@@ -3718,21 +3720,24 @@ public void TestConnectEnableHighAvailability_false() throws IOException, Interr
37183720
}catch(Exception ex)
37193721
{
37203722
e = ex.getMessage();
3723+
System.out.println(ex);
37213724
}
37223725
assertNotNull(e);
37233726
Thread.sleep(1000);
37243727
try{
37253728
conn.run("startDataNode(\""+nodeAlias+"\")");
37263729
}catch(Exception ex)
3727-
{}
3730+
{
3731+
System.out.println(ex);
3732+
}
37283733
Thread.sleep(1000);
37293734
conn1.connect(HOST,PORT,"admin","123456",null,false);
37303735
conn1.run("a=1;\n a");
37313736
assertEquals(true, conn1.isConnected());
37323737
conn1.close();
37333738
}
37343739
@Test
3735-
public void TestConnectEnableHighAvailability_true() throws IOException, InterruptedException {
3740+
public void Test_connect_EnableHighAvailability_true() throws IOException, InterruptedException {
37363741
DBConnection conn = new DBConnection();
37373742
conn.connect(HOST,CONTROLLER_PORT,"admin","123456",null,false);
37383743
DBConnection conn1 = new DBConnection();
@@ -3742,30 +3747,34 @@ public void TestConnectEnableHighAvailability_true() throws IOException, Interru
37423747
try{
37433748
conn.run("stopDataNode(\""+nodeAlias+"\")");
37443749
}catch(Exception ex)
3745-
{}
3750+
{
3751+
System.out.println(ex);
3752+
}
37463753
Thread.sleep(1000);
37473754
conn1.run("a=1;\n a");
37483755
//The connection switches to a different node to execute the code
37493756
try{
37503757
conn.run("startDataNode(\""+nodeAlias+"\")");
37513758
}catch(Exception ex)
3752-
{}
3759+
{
3760+
System.out.println(ex);
3761+
}
37533762
Thread.sleep(1000);
37543763
assertEquals(true, conn1.isConnected());
37553764
}
3756-
///@Test AJ-287
3765+
//@Test //AJ-287
37573766
public void Test_getConnection_highAvailability_false() throws SQLException, ClassNotFoundException, IOException {
37583767
String script = "def restart(n)\n" +
37593768
"{\n" +
37603769
"try{\n" +
37613770
"stopDataNode(\""+HOST+":"+PORT+"\");\n" +
37623771
"}catch(ex)\n"+
3763-
"{}\n"+
3772+
"{print(ex)}\n"+
37643773
"sleep(n);\n"+
37653774
"try{\n" +
37663775
"stopDataNode(\""+HOST+":"+PORT+"\");\n" +
37673776
"}catch(ex)\n"+
3768-
"{}\n"+
3777+
"{print(ex)}\n"+
37693778
"}\n" +
37703779
"submitJob(\"restart\",\"restart\",restart,1000);";
37713780
conn = new DBConnection(false, false, false);
@@ -3778,24 +3787,76 @@ public void Test_getConnection_highAvailability_false() throws SQLException, Cla
37783787
}
37793788

37803789
@Test
3781-
public void TestConnectEnableHighAvailability_true_1() throws IOException, InterruptedException {
3790+
public void Test_connect_EnableHighAvailability_true_1() throws IOException, InterruptedException {
37823791
DBConnection conn1 = new DBConnection();
37833792
conn1.connect(HOST,PORT,"admin","123456",null,true);
3784-
// BasicString nodeAliasTmp = (BasicString)conn1.run("getNodeAlias()");
3785-
// String nodeAlias = nodeAliasTmp.getString();
3786-
// try{
3787-
// conn.run("stopDataNode(\""+nodeAlias+"\")");
3788-
// }catch(Exception ex)
3789-
// {}
3790-
// Thread.sleep(1000);
3791-
// conn1.run("a=1;\n a");
3792-
// //The connection switches to a different node to execute the code
3793-
// try{
3794-
// conn.run("startDataNode(\""+nodeAlias+"\")");
3795-
// }catch(Exception ex)
3796-
// {}
3797-
// Thread.sleep(1000);
3798-
// assertEquals(true, conn1.isConnected());
3793+
BasicString nodeAliasTmp = (BasicString)conn1.run("getNodeAlias()");
3794+
String nodeAlias = nodeAliasTmp.getString();
3795+
try{
3796+
conn.run("stopDataNode(\""+nodeAlias+"\")");
3797+
}catch(Exception ex)
3798+
{
3799+
System.out.println(ex);
3800+
}
3801+
Thread.sleep(1000);
3802+
conn1.run("a=1;\n a");
3803+
//The connection switches to a different node to execute the code
3804+
try{
3805+
conn.run("startDataNode(\""+nodeAlias+"\")");
3806+
}catch(Exception ex)
3807+
{
3808+
System.out.println(ex);
3809+
}
3810+
Thread.sleep(1000);
3811+
assertEquals(true, conn1.isConnected());
3812+
}
3813+
@Test
3814+
public void Test_reConnect__true() throws IOException, InterruptedException {
3815+
DBConnection conn1 = new DBConnection();
3816+
conn1.connect(HOST,PORT,"admin","123456",null,false,null,true);
3817+
BasicString nodeAliasTmp = (BasicString)conn1.run("getNodeAlias()");
3818+
String nodeAlias = nodeAliasTmp.getString();
3819+
try{
3820+
conn.run("stopDataNode(\""+nodeAlias+"\")");
3821+
}catch(Exception ex)
3822+
{
3823+
System.out.println(ex);
3824+
}
3825+
Thread.sleep(1000);
3826+
conn1.run("a=1;\n a");
3827+
//The connection switches to a different node to execute the code
3828+
try{
3829+
conn.run("startDataNode(\""+nodeAlias+"\")");
3830+
}catch(Exception ex)
3831+
{
3832+
System.out.println(ex);
3833+
}
3834+
Thread.sleep(1000);
3835+
assertEquals(true, conn1.isConnected());
3836+
}
3837+
@Test //reConnect is not valid
3838+
public void Test_reConnect__false() throws IOException, InterruptedException {
3839+
DBConnection conn1 = new DBConnection();
3840+
conn1.connect(HOST,PORT,"admin","123456",null,false,null,false);
3841+
BasicString nodeAliasTmp = (BasicString)conn1.run("getNodeAlias()");
3842+
String nodeAlias = nodeAliasTmp.getString();
3843+
try{
3844+
conn.run("stopDataNode(\""+nodeAlias+"\")");
3845+
}catch(Exception ex)
3846+
{
3847+
System.out.println(ex);
3848+
}
3849+
Thread.sleep(1000);
3850+
conn1.run("a=1;\n a");
3851+
//The connection switches to a different node to execute the code
3852+
try{
3853+
conn.run("startDataNode(\""+nodeAlias+"\")");
3854+
}catch(Exception ex)
3855+
{
3856+
System.out.println(ex);
3857+
}
3858+
Thread.sleep(1000);
3859+
assertEquals(true, conn1.isConnected());
37993860
}
38003861
//@Test
38013862
public void test_string_length()throws Exception{

test/com/xxdb/LoadBalanceTest.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,10 @@ public void Test_getConnection_enableHighAvailability_true_site_not_null_all_not
455455
System.out.println(count2);
456456
System.out.println(count3);
457457
System.out.println(count4);
458-
org.junit.Assert.assertEquals(true, count1>80);
459-
org.junit.Assert.assertEquals(true, count2>80);
460-
org.junit.Assert.assertEquals(true, count3>80);
461-
org.junit.Assert.assertEquals(true, count4>80);
458+
org.junit.Assert.assertEquals(true, count1>70);
459+
org.junit.Assert.assertEquals(true, count2>70);
460+
org.junit.Assert.assertEquals(true, count3>70);
461+
org.junit.Assert.assertEquals(true, count4>70);
462462

463463
}
464464

@@ -526,22 +526,22 @@ public void Test_getConnection_enableHighAvailability_true_6() throws SQLExcepti
526526
}
527527

528528
//@Test(timeout = 120000)
529-
// public void Test_getConnection_enableHighAvailability_true_7() throws SQLException, ClassNotFoundException, IOException {
530-
// String JDBC_DRIVER = "com.dolphindb.jdbc.Driver";
531-
// int count1 = 0;
532-
// int count2 = 0;
533-
// int count3 = 0;
534-
// int count4 = 0;
535-
// List<DBConnection> list = new ArrayList<>();
536-
// for (int i = 0; i < 460; i++) {
537-
// DBConnection connection = new DBConnection();
538-
// connection.connect("192.168.1.167", 18921, "admin", "123456",true);
539-
// list.add(connection);
540-
//
541-
// }
542-
//DBConnection connection1 = new DBConnection();
543-
//connection1.connect("192.168.1.167", 18921, "admin", "123456",true);
544-
545-
//connection1.run("sleep(1000000)");
546-
// }
529+
public void Test_getConnection_enableHighAvailability_true_7() throws SQLException, ClassNotFoundException, IOException {
530+
String JDBC_DRIVER = "com.dolphindb.jdbc.Driver";
531+
int count1 = 0;
532+
int count2 = 0;
533+
int count3 = 0;
534+
int count4 = 0;
535+
List<DBConnection> list = new ArrayList<>();
536+
for (int i = 0; i < 460; i++) {
537+
DBConnection connection = new DBConnection();
538+
connection.connect("192.168.1.167", 8902, "admin", "123456",false);
539+
list.add(connection);
540+
541+
}
542+
DBConnection connection1 = new DBConnection();
543+
connection1.connect("192.168.1.167", 8902, "admin", "123456",false);
544+
545+
connection1.run("sleep(1000000)");
546+
}
547547
}

0 commit comments

Comments
 (0)