HDFS-13289. RBF: TestConnectionManager#testCleanup() test case need correction. Contributed by Dibyendu Karmakar.
This commit is contained in:
parent
acfd764fcc
commit
dc8e343201
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test functionalities of {@link ConnectionManager}, which manages a pool
|
* Test functionalities of {@link ConnectionManager}, which manages a pool
|
||||||
@ -94,14 +95,20 @@ public void testCleanup() throws Exception {
|
|||||||
// Make sure the number of connections doesn't go below minSize
|
// Make sure the number of connections doesn't go below minSize
|
||||||
ConnectionPool pool3 = new ConnectionPool(
|
ConnectionPool pool3 = new ConnectionPool(
|
||||||
conf, TEST_NN_ADDRESS, TEST_USER3, 2, 10);
|
conf, TEST_NN_ADDRESS, TEST_USER3, 2, 10);
|
||||||
addConnectionsToPool(pool3, 10, 0);
|
addConnectionsToPool(pool3, 8, 0);
|
||||||
poolMap.put(new ConnectionPoolId(TEST_USER2, TEST_NN_ADDRESS), pool3);
|
poolMap.put(new ConnectionPoolId(TEST_USER3, TEST_NN_ADDRESS), pool3);
|
||||||
connManager.cleanup(pool3);
|
checkPoolConnections(TEST_USER3, 10, 0);
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
connManager.cleanup(pool3);
|
||||||
|
}
|
||||||
checkPoolConnections(TEST_USER3, 2, 0);
|
checkPoolConnections(TEST_USER3, 2, 0);
|
||||||
// With active connections added to pool, make sure it honors the
|
// With active connections added to pool, make sure it honors the
|
||||||
// MIN_ACTIVE_RATIO again
|
// MIN_ACTIVE_RATIO again
|
||||||
addConnectionsToPool(pool3, 10, 2);
|
addConnectionsToPool(pool3, 8, 2);
|
||||||
connManager.cleanup(pool3);
|
checkPoolConnections(TEST_USER3, 10, 2);
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
connManager.cleanup(pool3);
|
||||||
|
}
|
||||||
checkPoolConnections(TEST_USER3, 4, 2);
|
checkPoolConnections(TEST_USER3, 4, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,13 +152,18 @@ private void addConnectionsToPool(ConnectionPool pool, int numTotalConn,
|
|||||||
|
|
||||||
private void checkPoolConnections(UserGroupInformation ugi,
|
private void checkPoolConnections(UserGroupInformation ugi,
|
||||||
int numOfConns, int numOfActiveConns) {
|
int numOfConns, int numOfActiveConns) {
|
||||||
|
boolean connPoolFoundForUser = false;
|
||||||
for (Map.Entry<ConnectionPoolId, ConnectionPool> e :
|
for (Map.Entry<ConnectionPoolId, ConnectionPool> e :
|
||||||
connManager.getPools().entrySet()) {
|
connManager.getPools().entrySet()) {
|
||||||
if (e.getKey().getUgi() == ugi) {
|
if (e.getKey().getUgi() == ugi) {
|
||||||
assertEquals(numOfConns, e.getValue().getNumConnections());
|
assertEquals(numOfConns, e.getValue().getNumConnections());
|
||||||
assertEquals(numOfActiveConns, e.getValue().getNumActiveConnections());
|
assertEquals(numOfActiveConns, e.getValue().getNumActiveConnections());
|
||||||
|
connPoolFoundForUser = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!connPoolFoundForUser) {
|
||||||
|
fail("Connection pool not found for user " + ugi.getUserName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user