@@ -55,9 +55,8 @@ public class AdvancedShardAwarenessIT {
5555 Level originalLevelReconnection ;
5656 private final Pattern shardMismatchPattern =
5757 Pattern .compile (".*r configuration of shard aware port.*" );
58- private final Pattern reconnectionPattern =
58+ private final Pattern generalReconnectionPattern =
5959 Pattern .compile (".*Scheduling next reconnection in.*" );
60- Set <Pattern > forbiddenOccurences = ImmutableSet .of (shardMismatchPattern , reconnectionPattern );
6160
6261 @ DataProvider
6362 public static Object [][] reuseAddressOption () {
@@ -92,10 +91,26 @@ public void stopCapturingLogs() {
9291 @ Test
9392 @ UseDataProvider ("reuseAddressOption" )
9493 public void should_initialize_all_channels (boolean reuseAddress ) {
94+ String node1 = CCM_RULE .getCcmBridge ().getNodeIpAddress (1 );
95+ String node2 = CCM_RULE .getCcmBridge ().getNodeIpAddress (2 );
96+ Pattern reconnectionPattern1 =
97+ Pattern .compile (".*" + Pattern .quote (node1 ) + ".*Scheduling next reconnection in.*" );
98+ Pattern reconnectionPattern2 =
99+ Pattern .compile (".*" + Pattern .quote (node2 ) + ".*Scheduling next reconnection in.*" );
100+ Set <Pattern > forbiddenOccurences =
101+ ImmutableSet .of (shardMismatchPattern , reconnectionPattern1 , reconnectionPattern2 );
95102 Map <Pattern , Integer > expectedOccurences =
96103 ImmutableMap .of (
97- Pattern .compile (".*\\ .2:19042.*Reconnection attempt complete, 6/6 channels.*" ), 1 ,
98- Pattern .compile (".*\\ .1:19042.*Reconnection attempt complete, 6/6 channels.*" ), 1 );
104+ Pattern .compile (
105+ ".*"
106+ + Pattern .quote (node1 )
107+ + ":19042.*Reconnection attempt complete, 6/6 channels.*" ),
108+ 1 ,
109+ Pattern .compile (
110+ ".*"
111+ + Pattern .quote (node2 )
112+ + ":19042.*Reconnection attempt complete, 6/6 channels.*" ),
113+ 1 );
99114 DriverConfigLoader loader =
100115 SessionUtils .configLoaderBuilder ()
101116 .withBoolean (DefaultDriverOption .SOCKET_REUSE_ADDRESS , reuseAddress )
@@ -164,7 +179,7 @@ public void should_struggle_to_fill_pools() {
164179 CqlSession session4 = CompletableFutures .getUninterruptibly (stage4 ); ) {
165180 Uninterruptibles .sleepUninterruptibly (20 , TimeUnit .SECONDS );
166181 assertNoLogMatches (shardMismatchPattern , appender .list );
167- assertMatchesAtLeast (reconnectionPattern , 8 , appender .list );
182+ assertMatchesAtLeast (generalReconnectionPattern , 8 , appender .list );
168183 }
169184 }
170185
@@ -193,16 +208,29 @@ public void should_not_struggle_to_fill_pools() {
193208 CqlSession session4 = CompletableFutures .getUninterruptibly (stage4 ); ) {
194209 Uninterruptibles .sleepUninterruptibly (8 , TimeUnit .SECONDS );
195210 int tolerance = 2 ; // Sometimes socket ends up already in use
211+ String node1 = CCM_RULE .getCcmBridge ().getNodeIpAddress (1 );
212+ String node2 = CCM_RULE .getCcmBridge ().getNodeIpAddress (2 );
213+ Pattern reconnectionPattern1 =
214+ Pattern .compile (".*" + Pattern .quote (node1 ) + ".*Scheduling next reconnection in.*" );
215+ Pattern reconnectionPattern2 =
216+ Pattern .compile (".*" + Pattern .quote (node2 ) + ".*Scheduling next reconnection in.*" );
196217 Map <Pattern , Integer > expectedOccurences =
197218 ImmutableMap .of (
198- Pattern .compile (".*\\ .2:19042.*Reconnection attempt complete, 66/66 channels.*" ),
219+ Pattern .compile (
220+ ".*"
221+ + Pattern .quote (node1 )
222+ + ":19042.*Reconnection attempt complete, 66/66 channels.*" ),
199223 1 * sessions ,
200- Pattern .compile (".*\\ .1:19042.*Reconnection attempt complete, 66/66 channels.*" ),
224+ Pattern .compile (
225+ ".*"
226+ + Pattern .quote (node2 )
227+ + ":19042.*Reconnection attempt complete, 66/66 channels.*" ),
201228 1 * sessions );
202229 expectedOccurences .forEach (
203230 (pattern , times ) -> assertMatchesAtLeast (pattern , times , appender .list ));
204231 assertNoLogMatches (shardMismatchPattern , appender .list );
205- assertMatchesAtMost (reconnectionPattern , tolerance , appender .list );
232+ assertMatchesAtMost (reconnectionPattern1 , tolerance , appender .list );
233+ assertMatchesAtMost (reconnectionPattern2 , tolerance , appender .list );
206234 }
207235 }
208236
0 commit comments