Skip to content

Commit 579e06c

Browse files
committed
AJ-675:add test case about loadBalance
1 parent 90aa8c3 commit 579e06c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/com/xxdb/LoadBalanceTest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ public void Test_getConnection_enableHighAvailability_true_enableLoadBalance_fal
415415
DBConnection connection = new DBConnection();
416416
connection.connect(HOST, PORT, "admin", "123456",null,true,null,false,false);
417417
list.add(connection);
418+
// BasicInt re = (BasicInt)connection.run("getNodePort()");
419+
// System.out.println("current node is:"+re);
420+
// System.out.println("stop current node");
418421
}
419422
DBConnection connection1 = new DBConnection();
420423
connection1.connect(HOST, PORT, "admin", "123456",false);
@@ -579,6 +582,45 @@ public void Test_DBConnectionPool_enableHighAvailability_true_loadBalance_false_
579582
}
580583
}
581584
}
585+
//@Test//The current node is unavailable
586+
public void Test_DBConnectionPool_enableHighAvailability_true_loadBalance_false_2() throws SQLException, ClassNotFoundException, IOException, InterruptedException {
587+
DBConnection controller_conn = new DBConnection();
588+
controller_conn.connect(controller_host, controller_port, "admin", "123456");
589+
class MyThread extends Thread {
590+
@Override
591+
public void run() {
592+
try {
593+
DBConnectionPool pool1 = new ExclusiveDBConnectionPool(HOST,PORT,"admin","123456",100,false,true,null,null, false, false, false);
594+
Thread.sleep(1000);
595+
} catch (IOException e) {
596+
throw new RuntimeException(e);
597+
} catch (InterruptedException e) {
598+
throw new RuntimeException(e);
599+
}
600+
}
601+
}
602+
class MyThread1 extends Thread {
603+
@Override
604+
public void run() {
605+
try {
606+
controller_conn.run("try{stopDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
607+
Thread.sleep(1000);
608+
} catch (Exception e) {
609+
// 捕获异常并打印错误信息
610+
System.err.println("Error executing task: " + e.getMessage());
611+
}
612+
}
613+
}
614+
MyThread thread = new MyThread();
615+
MyThread1 thread1 = new MyThread1();
616+
thread.start();
617+
Thread.sleep(15);
618+
System.err.println("thread1开始运行 ");
619+
thread1.start();
620+
thread.join();
621+
thread1.join();
622+
controller_conn.run("try{stopDataNode('"+HOST+":"+PORT+"')}catch(ex){}");
623+
}
582624
@Test
583625
public void Test_DBConnectionPool_enableHighAvailability_true_loadBalance_true_highAvailabilitySites_null() throws SQLException, ClassNotFoundException, IOException {
584626
DBConnectionPool pool1 = new ExclusiveDBConnectionPool(HOST,PORT,"admin","123456",100,true,true,null,null, false, false, false);

0 commit comments

Comments
 (0)