Elffuss BraidHub

kikocis/java-driver public

Add test for JAVA-597.
Changeset669727007dc87208ec3d592b8f75b451a36bb6efcdf49388225cb26b855895cb
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2014-12-22 14:33 -05:00
CommitterAndrew Tolbert <andrew.tolbert@datastax.com> · 2014-12-22 14:37 -05:00
Parents091573a39423

Browse the files at this changeset

1 file changed

modified driver-core/src/test/java/com/datastax/driver/core/ControlConnectionTest.java +41 −0
@@ -66,6 +66,47 @@
6666 }
6767 }
6868
69+ /**
70+ * Ensures that if the host that the Control Connection is connected to is removed/decommissioned that the
71+ * Control Connection is reestablished to another host.
72+ *
73+ * @since 2.0.9
74+ * @jira_ticket JAVA-597
75+ * @expected_result Control Connection is reestablished to another host.
76+ * @test_category control_connection
77+ */
78+ @Test(groups = "long")
79+ public void should_reestablish_if_control_node_decommissioned() throws InterruptedException {
80+ CCMBridge ccm = null;
81+ Cluster cluster = null;
82+
83+ try {
84+ ccm = CCMBridge.create("test", 3);
85+
86+ cluster = Cluster.builder()
87+ .addContactPoint(CCMBridge.ipOfNode(1))
88+ .build();
89+ cluster.init();
90+
91+ // Ensure the control connection host is that of the first node.
92+ String controlHost = cluster.manager.controlConnection.connectedHost().getAddress().getHostAddress();
93+ assertThat(controlHost).isEqualTo(CCMBridge.ipOfNode(1));
94+
95+ // Decommission the node.
96+ ccm.decommissionNode(1);
97+
98+ // Ensure that the new control connection is not null and it's host is not equal to the decommissioned node.
99+ Host newHost = cluster.manager.controlConnection.connectedHost();
100+ assertThat(newHost).isNotNull();
101+ assertThat(newHost.getAddress().getHostAddress()).isNotEqualTo(controlHost);
102+ } finally {
103+ if (cluster != null)
104+ cluster.close();
105+ if (ccm != null)
106+ ccm.remove();
107+ }
108+ }
109+
69110 static class QueryPlanCountingPolicy extends DelegatingLoadBalancingPolicy {
70111
71112 final AtomicInteger counter = new AtomicInteger();