diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-26 11:43:28 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-26 11:43:28 +0100 |
commit | 4688a99d38d22e346282d993bc558d5b37676487 (patch) | |
tree | edc1449bbff3f8260fde43107ab2781da46f4250 /container-search/src/test/java/com/yahoo | |
parent | 6b2223c7e5897929a0570434d66ff08f554b6317 (diff) |
Need a delayed close for the connections no longer needed.
Diffstat (limited to 'container-search/src/test/java/com/yahoo')
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java index ff37352b39c..7c1e7372507 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java @@ -73,8 +73,14 @@ public class RpcSearchInvokerTest { assertEquals(maxHits, request.getHits()); } - void verifyConnections(RpcResourcePool rpcResourcePool, int numGroups, int nodesPerGroup) { - rpcResourcePool.updateNodes(createNodesConfig(numGroups,nodesPerGroup)); + void verifyConnections(RpcResourcePool rpcResourcePool, int numGroups, int nodesPerGroup, int expectNeedCloseCount) { + var toClose = rpcResourcePool.updateNodes(createNodesConfig(numGroups,nodesPerGroup)); + assertEquals(expectNeedCloseCount, toClose.size()); + toClose.forEach(item -> { + try { + item.close(); + } catch (Exception e) {} + }); for (int nodeId = 0; nodeId < numGroups*nodesPerGroup; nodeId++) { assertTrue(rpcResourcePool.getConnection(nodeId) instanceof RpcClient.RpcNodeConnection); } @@ -84,9 +90,9 @@ public class RpcSearchInvokerTest { @Test void testUpdateOfRpcResourcePool() { RpcResourcePool rpcResourcePool = new RpcResourcePool(createDispatchConfig(), createNodesConfig(0, 0)); - verifyConnections(rpcResourcePool, 3,3); - verifyConnections(rpcResourcePool, 4,4); - verifyConnections(rpcResourcePool, 2,2); + verifyConnections(rpcResourcePool, 3,3, 0); + verifyConnections(rpcResourcePool, 4,4, 6); + verifyConnections(rpcResourcePool, 2,2, 14); } private Client parameterCollectorClient(AtomicReference<CompressionType> compressionTypeHolder, AtomicReference<byte[]> payloadHolder, |