kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 904bfb785bf5497cee135db770867bb6e78e002fb78c469d7e1929124d7f43df |
|---|---|
| Author | Joaquin Casares <joaquin@datastax.com> · 2014-07-18 15:29 -05:00 |
| Committer | Joaquin Casares <joaquin@datastax.com> · 2014-07-18 15:29 -05:00 |
| Parents | cdd9bb755010 |
1 file changed
modified driver-core/src/test/java/com/datastax/driver/core/SessionTest.java +13 −0
| @@ -131,6 +131,13 @@ | ||
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | + /** | |
| 135 | + * Check for session memory leaks by creating and closing 10,000 connections. | |
| 136 | + * Each time a session is created and closed we check the number of sessions the | |
| 137 | + * cluster.manager is holding onto as well as the number of open connections. | |
| 138 | + * | |
| 139 | + * @throws Exception | |
| 140 | + */ | |
| 134 | 141 | @Test(groups = "long") |
| 135 | 142 | public void sessionMemoryLeakTest() throws Exception { |
| 136 | 143 | // Checking for JAVA-342 |
| @@ -157,9 +164,11 @@ | ||
| 157 | 164 | |
| 158 | 165 | try { |
| 159 | 166 | for (int i = 0; i < 10000; ++i) { |
| 167 | + // ensure 0 sessions with a single control connection | |
| 160 | 168 | assertEquals(cluster.manager.sessions.size(), 0); |
| 161 | 169 | assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 1); |
| 162 | 170 | |
| 171 | + // ensure a new session gets registered and control connections are established | |
| 163 | 172 | session = cluster.connect(); |
| 164 | 173 | assertEquals(cluster.manager.sessions.size(), 1); |
| 165 | 174 | assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 3); |
| @@ -206,6 +215,8 @@ | ||
| 206 | 215 | assertEquals(cluster.manager.sessions.size(), 0); |
| 207 | 216 | assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 1); |
| 208 | 217 | |
| 218 | + // ensure a new session gets registered and control connections are established | |
| 219 | + // an additional 2 control connections should be seen for node2 | |
| 209 | 220 | thisSession = cluster.connect(); |
| 210 | 221 | assertEquals(cluster.manager.sessions.size(), 1); |
| 211 | 222 | assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 5); |
| @@ -216,7 +227,9 @@ | ||
| 216 | 227 | assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 1); |
| 217 | 228 | |
| 218 | 229 | } finally { |
| 230 | + // ensure we decommission node2 for the rest of the tests | |
| 219 | 231 | cassandraCluster.decommissionNode(2); |
| 232 | + | |
| 220 | 233 | assertEquals(cluster.manager.sessions.size(), 0); |
| 221 | 234 | assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 1); |
| 222 | 235 |