Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.11 6220108e6 -> d8fb9349d
  refs/heads/trunk afd68abe6 -> 09c837f75


Replace string comparison with regex/number checks in MessagingService test

Patch by Alex Petrov; reviewed by Michael Kjellman for CASSANDRA-13216.

Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/d8fb9349
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/d8fb9349
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/d8fb9349

Branch: refs/heads/cassandra-3.11
Commit: d8fb9349df818659c54d57b2d2c95ebbd0405d49
Parents: 6220108
Author: Alex Petrov <[email protected]>
Authored: Wed Mar 29 14:30:16 2017 +0200
Committer: Alex Petrov <[email protected]>
Committed: Tue Jun 13 11:22:32 2017 +0200

----------------------------------------------------------------------
 CHANGES.txt                                       |  1 +
 .../cassandra/net/MessagingServiceTest.java       | 18 ++++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/d8fb9349/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index f285ff0..1058c9c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.11.0
+ * Replace string comparison with regex/number checks in MessagingService test 
(CASSANDRA-13216)
  * Fix formatting of duration columns in CQLSH (CASSANDRA-13549)
  * Fix the problem with duplicated rows when using paging with SASI 
(CASSANDRA-13302)
  * Allow CONTAINS statements filtering on the partition key and it’s parts 
(CASSANDRA-13275)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d8fb9349/test/unit/org/apache/cassandra/net/MessagingServiceTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/net/MessagingServiceTest.java 
b/test/unit/org/apache/cassandra/net/MessagingServiceTest.java
index c1dcfc5..e7d90c4 100644
--- a/test/unit/org/apache/cassandra/net/MessagingServiceTest.java
+++ b/test/unit/org/apache/cassandra/net/MessagingServiceTest.java
@@ -32,6 +32,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
+import java.util.regex.*;
+import java.util.regex.Matcher;
 
 import com.google.common.collect.Iterables;
 import com.codahale.metrics.Timer;
@@ -83,7 +85,13 @@ public class MessagingServiceTest
 
         List<String> logs = messagingService.getDroppedMessagesLogs();
         assertEquals(1, logs.size());
-        assertEquals("READ messages were dropped in last 5000 ms: 2500 
internal and 2500 cross node. Mean internal dropped latency: 2730 ms and Mean 
cross-node dropped latency: 2731 ms", logs.get(0));
+        Pattern regexp = Pattern.compile("READ messages were dropped in last 
5000 ms: (\\d+) internal and (\\d+) cross node. Mean internal dropped latency: 
(\\d+) ms and Mean cross-node dropped latency: (\\d+) ms");
+        Matcher matcher = regexp.matcher(logs.get(0));
+        assertTrue(matcher.find());
+        assertEquals(2500, Integer.parseInt(matcher.group(1)));
+        assertEquals(2500, Integer.parseInt(matcher.group(2)));
+        assertTrue(Integer.parseInt(matcher.group(3)) > 0);
+        assertTrue(Integer.parseInt(matcher.group(4)) > 0);
         assertEquals(5000, (int) 
messagingService.getDroppedMessages().get(verb.toString()));
 
         logs = messagingService.getDroppedMessagesLogs();
@@ -93,7 +101,13 @@ public class MessagingServiceTest
             messagingService.incrementDroppedMessages(verb, i, i % 2 == 0);
 
         logs = messagingService.getDroppedMessagesLogs();
-        assertEquals("READ messages were dropped in last 5000 ms: 1250 
internal and 1250 cross node. Mean internal dropped latency: 2277 ms and Mean 
cross-node dropped latency: 2278 ms", logs.get(0));
+        assertEquals(1, logs.size());
+        matcher = regexp.matcher(logs.get(0));
+        assertTrue(matcher.find());
+        assertEquals(1250, Integer.parseInt(matcher.group(1)));
+        assertEquals(1250, Integer.parseInt(matcher.group(2)));
+        assertTrue(Integer.parseInt(matcher.group(3)) > 0);
+        assertTrue(Integer.parseInt(matcher.group(4)) > 0);
         assertEquals(7500, (int) 
messagingService.getDroppedMessages().get(verb.toString()));
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to