Skip to content
Permalink
Browse files
simplify/harden GPFS test
Patch by brandonwilliams, reviewed by edimitrova for CASSANDRA-13196
  • Loading branch information
driftx committed Mar 26, 2021
1 parent a4186ad commit f9c3d78b7845b7dd87f49fedd7287281041aac76
Showing 1 changed file with 16 additions and 50 deletions.
@@ -3,6 +3,7 @@
import time
import pytest
import logging
import re

from cassandra import ConsistencyLevel
from dtest import Tester
@@ -37,27 +38,9 @@ def test_prefer_local_reconnect_on_listen_address(self):
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 @@ def test_prefer_local_reconnect_on_listen_address(self):
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 @@ def test_prefer_local_reconnect_on_listen_address(self):
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

0 comments on commit f9c3d78

Please sign in to comment.