Created
August 4, 2022 15:04
-
-
Save fruch/b3623f68bf8dba65c44133ba1288f418 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import time | |
from dtest_class import Tester | |
logger = logging.getLogger(__name__) | |
def retry_till_success(fun, *args, **kwargs): | |
timeout = kwargs.pop('timeout', 60) | |
bypassed_exception = kwargs.pop('bypassed_exception', Exception) | |
deadline = time.time() + timeout | |
while True: | |
try: | |
return fun(*args, **kwargs) | |
except bypassed_exception: | |
if time.time() > deadline: | |
raise | |
else: | |
# brief pause before next attempt | |
time.sleep(0.005) | |
class TestBootstrap(Tester): | |
def test_reproducer_for_982(self): | |
""" reproducer scylladb/scylla-operator#982 """ | |
logger.info("populating cluster with three nodes") | |
cluster = self.cluster | |
cluster.populate(3) | |
logger.info("starting cluster") | |
cluster.start(wait_for_binary_proto=True, wait_other_notice=True) | |
logger.info("stopping node3") | |
node1, node2, node3 = cluster.nodelist() | |
node3.stop(gently=True) | |
# same the losing the disk | |
# node3.clear() | |
logger.info("replace node3 address") | |
ip_prefix = cluster.get_ipprefix() | |
ip3 = f'{ip_prefix}33' | |
node3.set_configuration_options(values={'listen_address': ip3, 'rpc_address': ip3, 'api_address': ip3}) | |
node3.network_interfaces = {k: (ip3, v[1]) for k, v in node3.network_interfaces.items()} | |
logger.info("decommission node3") | |
node3.start(wait_for_binary_proto=False, wait_other_notice=False) | |
retry_till_success(node3.decommission, timeout=120) | |
logger.info("add node4") | |
node4 = cluster.new_node(4) | |
node4.start(wait_for_binary_proto=True) | |
logger.info("done") | |
''' | |
from subprocess import run | |
node1_ip_address, node1_port = get_node(1).network_interfaces['binary'] | |
def remove_iptables(): | |
run(('sudo iptables -t filter -D INPUT -p tcp --dport {node1_port} ' | |
'--destination {node1_ip_address}/32 -j REJECT --reject-with icmp-port-unreachable' | |
).format(node1_ip_address=node1_ip_address, node1_port=node1_port).split(' ') | |
) | |
self.addCleanup(remove_iptables) | |
for i in range(3): | |
run(('sudo iptables -t filter -A INPUT -p tcp --dport {node1_port} ' | |
'--destination {node1_ip_address}/32 -j REJECT --reject-with icmp-port-unreachable' | |
).format(node1_ip_address=node1_ip_address, node1_port=node1_port).split(' ') | |
) | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment