Skip to content

Commit 462272d

Browse files
committed
tests: remove unnecessary withIpPrefix calls
Since cluster is running on it's own ip prefix we can safely run them without specifing particular ip prefix.
1 parent 8191477 commit 462272d

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

integration-tests/src/test/java/com/datastax/oss/driver/core/metadata/ZeroTokenNodesIT.java

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void checkScyllaVersion() {
4444
public void should_not_ignore_zero_token_peer_when_option_is_enabled() {
4545
CqlSession session = null;
4646
CcmBridge.Builder ccmBridgeBuilder = CcmBridge.builder();
47-
try (CcmBridge ccmBridge = ccmBridgeBuilder.withNodes(3).withIpPrefix("127.0.1.").build()) {
47+
try (CcmBridge ccmBridge = ccmBridgeBuilder.withNodes(3).build()) {
4848
ccmBridge.create();
4949
ccmBridge.startWithArgs("--wait-for-binary-proto");
5050
ccmBridge.addWithoutStart(4, "dc1");
@@ -63,8 +63,13 @@ public void should_not_ignore_zero_token_peer_when_option_is_enabled() {
6363
Collection<Node> nodes = session.getMetadata().getNodes().values();
6464
Set<String> toStrings =
6565
nodes.stream().map(Node::getEndPoint).map(EndPoint::toString).collect(Collectors.toSet());
66+
6667
assertThat(toStrings)
67-
.containsOnly("/127.0.1.1:9042", "/127.0.1.2:9042", "/127.0.1.3:9042", "/127.0.1.4:9042");
68+
.containsOnly(
69+
String.format("/%s:9042", ccmBridge.getNodeIpAddress(1)),
70+
String.format("/%s:9042", ccmBridge.getNodeIpAddress(2)),
71+
String.format("/%s:9042", ccmBridge.getNodeIpAddress(3)),
72+
String.format("/%s:9042", ccmBridge.getNodeIpAddress(4)));
6873
} finally {
6974
if (session != null) session.close();
7075
}
@@ -74,7 +79,7 @@ public void should_not_ignore_zero_token_peer_when_option_is_enabled() {
7479
public void should_not_discover_zero_token_DC_when_option_is_disabled() {
7580
CqlSession session = null;
7681
CcmBridge.Builder ccmBridgeBuilder = CcmBridge.builder();
77-
try (CcmBridge ccmBridge = ccmBridgeBuilder.withNodes(2, 2).withIpPrefix("127.0.1.").build()) {
82+
try (CcmBridge ccmBridge = ccmBridgeBuilder.withNodes(2, 2).build()) {
7883
ccmBridge.create();
7984
ccmBridge.updateNodeConfig(3, "join_ring", false);
8085
ccmBridge.updateNodeConfig(4, "join_ring", false);
@@ -97,11 +102,13 @@ public void should_not_discover_zero_token_DC_when_option_is_disabled() {
97102
Objects.requireNonNull(rs.one()).getInetAddress("rpc_address");
98103
landedOn.add(Objects.requireNonNull(broadcastRpcInetAddress).toString());
99104
}
100-
assertThat(landedOn).containsOnly("/127.0.1.1", "/127.0.1.2");
105+
assertThat(landedOn)
106+
.containsOnly("/" + ccmBridge.getNodeIpAddress(1), "/" + ccmBridge.getNodeIpAddress(2));
101107
Collection<Node> nodes = session.getMetadata().getNodes().values();
102108
Set<String> toStrings =
103109
nodes.stream().map(Node::getEndPoint).map(EndPoint::toString).collect(Collectors.toSet());
104-
assertThat(toStrings).containsOnly("/127.0.1.1:9042", "/127.0.1.2:9042");
110+
assertThat(toStrings)
111+
.containsOnly("/" + ccmBridge.getNodeIpAddress(1), "/" + ccmBridge.getNodeIpAddress(2));
105112
} finally {
106113
if (session != null) session.close();
107114
}
@@ -111,7 +118,7 @@ public void should_not_discover_zero_token_DC_when_option_is_disabled() {
111118
public void should_discover_zero_token_DC_when_option_is_enabled() {
112119
CqlSession session = null;
113120
CcmBridge.Builder ccmBridgeBuilder = CcmBridge.builder();
114-
try (CcmBridge ccmBridge = ccmBridgeBuilder.withNodes(2, 2).withIpPrefix("127.0.1.").build()) {
121+
try (CcmBridge ccmBridge = ccmBridgeBuilder.withNodes(2, 2).build()) {
115122
ccmBridge.create();
116123
ccmBridge.updateNodeConfig(3, "join_ring", false);
117124
ccmBridge.updateNodeConfig(4, "join_ring", false);
@@ -136,13 +143,18 @@ public void should_discover_zero_token_DC_when_option_is_enabled() {
136143
landedOn.add(Objects.requireNonNull(broadcastRpcInetAddress).toString());
137144
}
138145
// LBP should still target local datacenter:
139-
assertThat(landedOn).containsOnly("/127.0.1.1", "/127.0.1.2");
146+
assertThat(landedOn)
147+
.containsOnly("/" + ccmBridge.getNodeIpAddress(1), "/" + ccmBridge.getNodeIpAddress(2));
140148
Collection<Node> nodes = session.getMetadata().getNodes().values();
141149
Set<String> toStrings =
142150
nodes.stream().map(Node::getEndPoint).map(EndPoint::toString).collect(Collectors.toSet());
143151
// Metadata should have all nodes:
144152
assertThat(toStrings)
145-
.containsOnly("/127.0.1.1:9042", "/127.0.1.2:9042", "/127.0.1.3:9042", "/127.0.1.4:9042");
153+
.containsOnly(
154+
"/" + ccmBridge.getNodeIpAddress(1),
155+
"/" + ccmBridge.getNodeIpAddress(2),
156+
"/" + ccmBridge.getNodeIpAddress(3),
157+
"/" + ccmBridge.getNodeIpAddress(4));
146158
} finally {
147159
if (session != null) session.close();
148160
}
@@ -152,7 +164,7 @@ public void should_discover_zero_token_DC_when_option_is_enabled() {
152164
public void should_connect_to_zero_token_contact_point() {
153165
CqlSession session = null;
154166
CcmBridge.Builder ccmBridgeBuilder = CcmBridge.builder();
155-
try (CcmBridge ccmBridge = ccmBridgeBuilder.withNodes(2).withIpPrefix("127.0.1.").build()) {
167+
try (CcmBridge ccmBridge = ccmBridgeBuilder.withNodes(2).build()) {
156168
ccmBridge.create();
157169
ccmBridge.startWithArgs("--wait-for-binary-proto");
158170
ccmBridge.addWithoutStart(3, "dc1");
@@ -169,7 +181,11 @@ public void should_connect_to_zero_token_contact_point() {
169181
Collection<Node> nodes = session.getMetadata().getNodes().values();
170182
Set<String> toStrings =
171183
nodes.stream().map(Node::getEndPoint).map(EndPoint::toString).collect(Collectors.toSet());
172-
assertThat(toStrings).containsOnly("/127.0.1.1:9042", "/127.0.1.2:9042", "/127.0.1.3:9042");
184+
assertThat(toStrings)
185+
.containsOnly(
186+
"/" + ccmBridge.getNodeIpAddress(1),
187+
"/" + ccmBridge.getNodeIpAddress(2),
188+
"/" + ccmBridge.getNodeIpAddress(3));
173189
} finally {
174190
if (session != null) session.close();
175191
}
@@ -182,7 +198,7 @@ public void should_connect_to_zero_token_DC() {
182198
// method.
183199
CqlSession session = null;
184200
CcmBridge.Builder ccmBridgeBuilder = CcmBridge.builder();
185-
try (CcmBridge ccmBridge = ccmBridgeBuilder.withNodes(2, 2).withIpPrefix("127.0.1.").build()) {
201+
try (CcmBridge ccmBridge = ccmBridgeBuilder.withNodes(2, 2).build()) {
186202
ccmBridge.create();
187203
ccmBridge.updateNodeConfig(3, "join_ring", false);
188204
ccmBridge.updateNodeConfig(4, "join_ring", false);
@@ -207,12 +223,17 @@ public void should_connect_to_zero_token_DC() {
207223
landedOn.add(Objects.requireNonNull(broadcastRpcInetAddress).toString());
208224
}
209225
// LBP should still target local datacenter:
210-
assertThat(landedOn).containsOnly("/127.0.1.1", "/127.0.1.2");
226+
assertThat(landedOn)
227+
.containsOnly("/" + ccmBridge.getNodeIpAddress(1), "/" + ccmBridge.getNodeIpAddress(2));
211228
Collection<Node> nodes = session.getMetadata().getNodes().values();
212229
Set<String> toStrings =
213230
nodes.stream().map(Node::getEndPoint).map(EndPoint::toString).collect(Collectors.toSet());
214231
// Metadata should have valid ordinary peers plus zero-token contact point:
215-
assertThat(toStrings).containsOnly("/127.0.1.1:9042", "/127.0.1.2:9042", "/127.0.1.3:9042");
232+
assertThat(toStrings)
233+
.containsOnly(
234+
"/" + ccmBridge.getNodeIpAddress(1),
235+
"/" + ccmBridge.getNodeIpAddress(2),
236+
"/" + ccmBridge.getNodeIpAddress(3));
216237
} finally {
217238
if (session != null) session.close();
218239
}

integration-tests/src/test/java/com/datastax/oss/driver/core/resolver/MockResolverIT.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class MockResolverIT {
6363

6464
@Test
6565
public void should_connect_with_mocked_hostname() {
66-
CcmBridge.Builder ccmBridgeBuilder = CcmBridge.builder().withNodes(1).withIpPrefix("127.0.1.");
66+
CcmBridge.Builder ccmBridgeBuilder = CcmBridge.builder().withNodes(1);
6767
try (CcmBridge ccmBridge = ccmBridgeBuilder.build()) {
6868
MultimapHostResolverProvider.removeResolverEntries("test.cluster.fake");
6969
MultimapHostResolverProvider.addResolverEntry(
@@ -258,7 +258,7 @@ public void cannot_reconnect_with_resolved_socket() {
258258
CqlSession session;
259259
Collection<Node> nodes;
260260
Set<Node> filteredNodes;
261-
try (CcmBridge ccmBridge = CcmBridge.builder().withNodes(3).withIpPrefix("127.0.1.").build()) {
261+
try (CcmBridge ccmBridge = CcmBridge.builder().withNodes(3).build()) {
262262
MultimapHostResolverProvider.removeResolverEntries("test.cluster.fake");
263263
MultimapHostResolverProvider.addResolverEntry(
264264
"test.cluster.fake", ccmBridge.getNodeIpAddress(1));
@@ -319,8 +319,7 @@ public void cannot_reconnect_with_resolved_socket() {
319319
LOG.warn(
320320
"Launching another cluster until we lose resolved socket from metadata (run {}).",
321321
counter);
322-
try (CcmBridge ccmBridge =
323-
CcmBridge.builder().withNodes(3).withIpPrefix("127.0." + counter + ".").build()) {
322+
try (CcmBridge ccmBridge = CcmBridge.builder().withNodes(3).build()) {
324323
MultimapHostResolverProvider.removeResolverEntries("test.cluster.fake");
325324
MultimapHostResolverProvider.addResolverEntry(
326325
"test.cluster.fake", ccmBridge.getNodeIpAddress(1));
@@ -374,7 +373,7 @@ public void cannot_reconnect_with_resolved_socket() {
374373
InetSocketAddress address = (InetSocketAddress) iterator.next().getEndPoint().resolve();
375374
assertFalse(address.isUnresolved());
376375
}
377-
try (CcmBridge ccmBridge = CcmBridge.builder().withNodes(3).withIpPrefix("127.1.1.").build()) {
376+
try (CcmBridge ccmBridge = CcmBridge.builder().withNodes(3).build()) {
378377
MultimapHostResolverProvider.removeResolverEntries("test.cluster.fake");
379378
MultimapHostResolverProvider.addResolverEntry(
380379
"test.cluster.fake", ccmBridge.getNodeIpAddress(1));

0 commit comments

Comments
 (0)