simplify/harden GPFS test

Patch by brandonwilliams, reviewed by edimitrova for CASSANDRA-13196
diff --git a/snitch_test.py b/snitch_test.py
index ec66ed0..6fc75cb 100644
--- a/snitch_test.py
+++ b/snitch_test.py
@@ -3,6 +3,7 @@
 import time
 import pytest
 import logging
+import re
 
 from cassandra import ConsistencyLevel
 from dtest import Tester
@@ -37,27 +38,9 @@
         NODE1_LISTEN_ADDRESS = '127.0.0.1'
         NODE1_BROADCAST_ADDRESS = '127.0.0.3'
 
-        NODE1_LISTEN_FMT_ADDRESS = '/127.0.0.1'
-        NODE1_BROADCAST_FMT_ADDRESS = '/127.0.0.3'
-
-        NODE1_40_LISTEN_ADDRESS = '127.0.0.1:7000'
-        NODE1_40_BROADCAST_ADDRESS = '127.0.0.3:7000'
-
-        NODE1_40_LISTEN_FMT_ADDRESS = '/127.0.0.1:7000'
-        NODE1_40_BROADCAST_FMT_ADDRESS = '/127.0.0.3:7000'
-
         NODE2_LISTEN_ADDRESS = '127.0.0.2'
         NODE2_BROADCAST_ADDRESS = '127.0.0.4'
 
-        NODE2_LISTEN_FMT_ADDRESS = '/127.0.0.2'
-        NODE2_BROADCAST_FMT_ADDRESS = '/127.0.0.4'
-
-        NODE2_40_LISTEN_ADDRESS = '127.0.0.2:7000'
-        NODE2_40_BROADCAST_ADDRESS = '127.0.0.4:7000'
-
-        NODE2_40_LISTEN_FMT_ADDRESS = '/127.0.0.2:7000'
-        NODE2_40_BROADCAST_FMT_ADDRESS = '/127.0.0.4:7000'
-
         STORAGE_PORT = 7000
 
         cluster = self.cluster
@@ -80,12 +63,6 @@
                 snitch_file.write("prefer_local=true" + os.linesep)
 
         node1.start(wait_for_binary_proto=True)
-        if running40:
-            node1.watch_log_for("Listening on address: \({}:{}\)".format(NODE1_40_LISTEN_FMT_ADDRESS[:-5], STORAGE_PORT), timeout=60)
-            node1.watch_log_for("Listening on address: \({}:{}\)".format(NODE1_40_BROADCAST_FMT_ADDRESS[:-5], STORAGE_PORT), timeout=60)
-        else:
-            node1.watch_log_for("Starting Messaging Service on {}:{}".format(NODE1_LISTEN_FMT_ADDRESS, STORAGE_PORT), timeout=60)
-            node1.watch_log_for("Starting Messaging Service on {}:{}".format(NODE1_BROADCAST_FMT_ADDRESS, STORAGE_PORT), timeout=60)
 
         self._test_connect(NODE1_LISTEN_ADDRESS, STORAGE_PORT)
         self._test_connect(NODE1_BROADCAST_ADDRESS, STORAGE_PORT)
@@ -98,55 +75,44 @@
         original_rows = list(session.execute("SELECT * FROM {}".format(stress_table)))
 
         node2.start(wait_for_binary_proto=True, wait_other_notice=False)
-        if running40:
-            node2.watch_log_for("Listening on address: \({}:{}\)".format(NODE2_40_LISTEN_FMT_ADDRESS[:-5], STORAGE_PORT), timeout=60)
-            node2.watch_log_for("Listening on address: \({}:{}\)".format(NODE2_40_BROADCAST_FMT_ADDRESS[:-5], STORAGE_PORT), timeout=60)
-        else:
-            node2.watch_log_for("Starting Messaging Service on {}:{}".format(NODE2_LISTEN_FMT_ADDRESS, STORAGE_PORT), timeout=60)
-            node2.watch_log_for("Starting Messaging Service on {}:{}".format(NODE2_BROADCAST_FMT_ADDRESS, STORAGE_PORT), timeout=60)
 
         self._test_connect(NODE2_LISTEN_ADDRESS, STORAGE_PORT)
         self._test_connect(NODE2_BROADCAST_ADDRESS, STORAGE_PORT)
 
-        # Intiated -> Initiated typo was fixed in 3.10
-        reconnectFmtString = "Ini?tiated reconnect to an Internal IP {} for the {}"
-        if node1.get_base_cassandra_version() >= 3.10:
-            reconnectFmtString = "Initiated reconnect to an Internal IP {} for the {}"
-        node1.watch_log_for(reconnectFmtString.format(NODE2_40_LISTEN_FMT_ADDRESS if running40 else NODE2_LISTEN_FMT_ADDRESS,
-                                               NODE2_40_BROADCAST_FMT_ADDRESS if running40 else NODE2_BROADCAST_FMT_ADDRESS), filename='debug.log', timeout=60)
-        node2.watch_log_for(reconnectFmtString.format(NODE1_40_LISTEN_FMT_ADDRESS if running40 else NODE1_LISTEN_FMT_ADDRESS,
-                                               NODE1_40_BROADCAST_FMT_ADDRESS if running40 else NODE1_BROADCAST_FMT_ADDRESS), filename='debug.log', timeout=60)
+        # substring for Intiated -> Initiated typo was fixed in 3.10
+        matchn1 = 'tiated reconnect to an Internal IP (\/)?{}(:7000)? for the (\/)?{}(:7000)?'.format(NODE1_LISTEN_ADDRESS, NODE1_BROADCAST_ADDRESS)
+        matchn2 = 'tiated reconnect to an Internal IP (\/)?{}(:7000)? for the (\/)?{}(:7000)?'.format(NODE2_LISTEN_ADDRESS, NODE2_BROADCAST_ADDRESS)
+        node1.watch_log_for(matchn2, filename='debug.log', timeout=60)
+        node2.watch_log_for(matchn1, filename='debug.log', timeout=60)
 
         # read data from node2 just to make sure data and connectivity is OK
         session = self.patient_exclusive_cql_connection(node2)
         new_rows = list(session.execute("SELECT * FROM {}".format(stress_table)))
         assert original_rows == new_rows
 
+        ipstr = "INTERNAL_IP:.+:{}"
+        if cluster.version() >= '4':
+            ipstr = "INTERNAL_ADDRESS_AND_PORT:.+:{}"
+
         out, err, _ = node1.nodetool('gossipinfo')
         assert_stderr_clean(err)
         logger.debug(out)
 
         assert "/{}".format(NODE1_BROADCAST_ADDRESS) in out
-        assert "INTERNAL_IP:{}:{}".format('10' if running40 else '7', NODE1_LISTEN_ADDRESS) in out
         assert "/{}".format(NODE2_BROADCAST_ADDRESS) in out
-        if running40:
-            assert "INTERNAL_ADDRESS_AND_PORT:8:{}".format(NODE1_40_LISTEN_ADDRESS) in out
-            assert "INTERNAL_ADDRESS_AND_PORT:8:{}".format(NODE2_40_LISTEN_ADDRESS) in out
-        else:
-            assert "INTERNAL_IP:{}:{}".format('7', NODE2_LISTEN_ADDRESS) in out
+        
+        assert re.search(ipstr.format(NODE1_LISTEN_ADDRESS), out)
+        assert re.search(ipstr.format(NODE2_LISTEN_ADDRESS), out)
 
         out, err, _ = node2.nodetool('gossipinfo')
         assert_stderr_clean(err)
         logger.debug(out)
 
         assert "/{}".format(NODE1_BROADCAST_ADDRESS) in out
-        assert "INTERNAL_IP:{}:{}".format('10' if running40 else '7', NODE2_LISTEN_ADDRESS) in out
         assert "/{}".format(NODE2_BROADCAST_ADDRESS) in out
-        if running40:
-            assert "INTERNAL_ADDRESS_AND_PORT:8:{}".format(NODE1_40_LISTEN_ADDRESS) in out
-            assert "INTERNAL_ADDRESS_AND_PORT:8:{}".format(NODE2_40_LISTEN_ADDRESS) in out
-        else:
-            assert "INTERNAL_IP:{}:{}".format('7', NODE1_LISTEN_ADDRESS) in out
+        
+        assert re.search(ipstr.format(NODE1_LISTEN_ADDRESS), out)
+        assert re.search(ipstr.format(NODE2_LISTEN_ADDRESS), out)
 
 class TestDynamicEndpointSnitch(Tester):
     @pytest.mark.resource_intensive