Elffuss BraidHub

kikocis/java-driver public

Add comments for recent JAVA-342 tests
Changeset904bfb785bf5497cee135db770867bb6e78e002fb78c469d7e1929124d7f43df
AuthorJoaquin Casares <joaquin@datastax.com> · 2014-07-18 15:29 -05:00
CommitterJoaquin Casares <joaquin@datastax.com> · 2014-07-18 15:29 -05:00
Parentscdd9bb755010

Browse the files at this changeset

1 file changed

modified driver-core/src/test/java/com/datastax/driver/core/SessionTest.java +13 −0
@@ -131,6 +131,13 @@
131131 }
132132 }
133133
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+ */
134141 @Test(groups = "long")
135142 public void sessionMemoryLeakTest() throws Exception {
136143 // Checking for JAVA-342
@@ -157,9 +164,11 @@
157164
158165 try {
159166 for (int i = 0; i < 10000; ++i) {
167+ // ensure 0 sessions with a single control connection
160168 assertEquals(cluster.manager.sessions.size(), 0);
161169 assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 1);
162170
171+ // ensure a new session gets registered and control connections are established
163172 session = cluster.connect();
164173 assertEquals(cluster.manager.sessions.size(), 1);
165174 assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 3);
@@ -206,6 +215,8 @@
206215 assertEquals(cluster.manager.sessions.size(), 0);
207216 assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 1);
208217
218+ // ensure a new session gets registered and control connections are established
219+ // an additional 2 control connections should be seen for node2
209220 thisSession = cluster.connect();
210221 assertEquals(cluster.manager.sessions.size(), 1);
211222 assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 5);
@@ -216,7 +227,9 @@
216227 assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 1);
217228
218229 } finally {
230+ // ensure we decommission node2 for the rest of the tests
219231 cassandraCluster.decommissionNode(2);
232+
220233 assertEquals(cluster.manager.sessions.size(), 0);
221234 assertEquals((int) cluster.getMetrics().getOpenConnections().getValue(), 1);
222235