Skip to content

Commit

Permalink
feature(sct): add support for using dns names in cluster
Browse files Browse the repository at this point in the history
We want to test if Scylla works with dns names instead of IP addresses.

Adding proper methods and conditions in various places according to test
configuration.
  • Loading branch information
soyacz authored and fruch committed Sep 18, 2023
1 parent 9c2209f commit 7b27bad
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
16 changes: 15 additions & 1 deletion sdcm/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def __init__(self, name, parent_cluster, ssh_login_info=None, base_logdir=None,

self.remoter: Optional[RemoteCmdRunnerBase] = None

self._use_dns_names: bool = parent_cluster.params.get('use_dns_names') or False
self._spot_monitoring_thread = None
self._journal_thread = None
self._docker_log_process = None
Expand Down Expand Up @@ -803,6 +804,14 @@ def public_ip_address(self) -> Optional[str]:
self._public_ip_address_cached = self._get_public_ip_address()
return self._public_ip_address_cached

@property
def public_dns_name(self) -> str:
return self.name

@property
def private_dns_name(self) -> str:
return self.name

def _get_public_ip_address(self) -> Optional[str]:
public_ips, _ = self._refresh_instance_state()
if public_ips:
Expand Down Expand Up @@ -894,6 +903,8 @@ def scylla_listen_address(self) -> str:
Use it for localhost connections (e.g., cqlsh)
"""
if self._use_dns_names:
return self.private_dns_name
return self.ip_address

@property
Expand Down Expand Up @@ -3951,7 +3962,10 @@ def set_seeds(self, wait_for_timeout=300, first_only=False):

@property
def seed_nodes_ips(self):
seed_nodes_ips = [node.ip_address for node in self.nodes if node.is_seed]
if self.params.get('use_dns_names'):
seed_nodes_ips = [node.private_dns_name for node in self.nodes if node.is_seed]
else:
seed_nodes_ips = [node.ip_address for node in self.nodes if node.is_seed]
assert seed_nodes_ips, "We should have at least one selected seed by now"
return seed_nodes_ips

Expand Down
12 changes: 12 additions & 0 deletions sdcm/cluster_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,18 @@ def external_address(self):
else:
return self._instance.private_ip_address

@cached_property
def public_dns_name(self) -> str:
result = self.remoter.run(
'curl http://169.254.169.254/latest/meta-data/public-hostname', verbose=False)
return result.stdout.strip()

@cached_property
def private_dns_name(self) -> str:
result = self.remoter.run(
'curl http://169.254.169.254/latest/meta-data/local-hostname', verbose=False)
return result.stdout.strip()

def _get_public_ip_address(self) -> Optional[str]:
return self._instance.public_ip_address

Expand Down
6 changes: 6 additions & 0 deletions sdcm/provision/scylla_yaml/node_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def seed_provider(self) -> Optional[List[SeedProvider]]:

@property
def listen_address(self) -> Optional[str]:
if self.params.get('use_dns_names'):
return self.node.private_dns_name
if self._is_ip_ssh_connections_ipv6:
return self._ipv6_ip_address
if self.params.get('extra_network_interface'):
Expand All @@ -65,6 +67,8 @@ def listen_address(self) -> Optional[str]:

@property
def rpc_address(self) -> Optional[str]:
if self.params.get('use_dns_names'):
return self.node.private_dns_name
if self._is_ip_ssh_connections_ipv6:
return self._ipv6_ip_address
if self.params.get('extra_network_interface'):
Expand All @@ -74,6 +78,8 @@ def rpc_address(self) -> Optional[str]:

@property
def broadcast_rpc_address(self) -> Optional[str]:
if self.params.get('use_dns_names'):
return self.node.private_dns_name
if self._is_ip_ssh_connections_ipv6:
return self._ipv6_ip_address
if self.params.get('extra_network_interface'):
Expand Down
3 changes: 3 additions & 0 deletions sdcm/sct_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,9 @@ class SCTConfiguration(dict):
help="""Forces GossipingPropertyFileSnitch (regardless `endpoint_snitch`) to simulate racks.
Provide number of racks to simulate."""),

dict(name="use_dns_names", env="SCT_USE_DNS_NAMES", type=boolean,
help="""Use dns names instead of ip addresses for nodes in cluster"""),

]

required_params = ['cluster_backend', 'test_duration', 'n_db_nodes', 'n_loaders', 'use_preinstalled_scylla',
Expand Down
9 changes: 6 additions & 3 deletions test-cases/longevity/longevity-mini-test-1h.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_duration: 180
stress_cmd: ["cassandra-stress write cl=QUORUM duration=90m -schema 'replication(strategy=NetworkTopologyStrategy,replication_factor=3)' -mode cql3 native -rate threads=50 -pop seq=1..10000000 -log interval=5"]
test_duration: 1000
stress_cmd: ["cassandra-stress write cl=QUORUM duration=900m -schema 'replication(strategy=NetworkTopologyStrategy,replication_factor=3)' -mode cql3 native -rate threads=2 -pop seq=1..10000000 -log interval=5"]

n_db_nodes: 4
n_loaders: 1
Expand All @@ -9,8 +9,11 @@ instance_type_db: 'i4i.large'

nemesis_class_name: 'SisyphusMonkey'
nemesis_interval: 1
nemesis_multiply_factor: 1
use_dns_names: true


user_prefix: 'longevity-mini-test'
space_node_threshold: 6442

append_scylla_args: '--memory 4G --blocked-reactor-notify-ms 25 --abort-on-lsa-bad-alloc 1 --abort-on-seastar-bad-alloc --abort-on-internal-error 1 --abort-on-ebadf 1 --enable-sstable-key-validation 1'
append_scylla_args: ' --blocked-reactor-notify-ms 25 --abort-on-lsa-bad-alloc 1 --abort-on-seastar-bad-alloc --abort-on-internal-error 1 --abort-on-ebadf 1 --enable-sstable-key-validation 1'

0 comments on commit 7b27bad

Please sign in to comment.