Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ccmlib/cluster_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def load(path, name):
elif common.isScylla(install_dir):
cluster = ScyllaCluster(path, data['name'], install_dir=install_dir, create_directory=False,
manager=scylla_manager_install_path, cassandra_version=data.get('scylla_version', None))
# Restore scylla_mode if it was saved (for non-relocatable builds)
if 'scylla_mode' in data:
cluster.scylla_mode = data['scylla_mode']
elif common.isDse(install_dir):
cluster = DseCluster(path, data['name'], install_dir=install_dir, create_directory=False)
else:
Expand Down
4 changes: 4 additions & 0 deletions ccmlib/scylla_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ def _update_config(self, install_dir=None):
if self.is_scylla_reloc():
data['scylla_version'] = self.scylla_version

# Save scylla_mode so that nodes added via `ccm add` use the same build mode
if self.scylla_mode:
data['scylla_mode'] = self.scylla_mode

if self._scylla_manager and self._scylla_manager.install_dir:
data['scylla_manager_install_path'] = self._scylla_manager.install_dir

Expand Down
55 changes: 55 additions & 0 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ruamel

from ccmlib.common import scylla_extract_mode, LockFile, parse_settings
from ruamel.yaml import YAML


def test_scylla_extract_mode():
Expand Down Expand Up @@ -188,3 +189,57 @@ def test_merge_configuration_client_encryption_options():
'keyfile': '/path/to/node.key'
}
}


def test_scylla_mode_persistence():
"""Test that scylla_mode is properly saved to and loaded from cluster.conf.

This test verifies the fix for issue #164 where `ccm add` command would forget
which build mode was used during cluster creation (e.g., dev vs release).
"""
with tempfile.TemporaryDirectory() as tmpdir:
# Create a mock cluster.conf file with scylla_mode
cluster_conf = os.path.join(tmpdir, 'cluster.conf')
config_data = {
'name': 'test_cluster',
'nodes': ['node1'],
'seeds': ['node1'],
'partitioner': None,
'install_dir': '/path/to/scylla',
'config_options': {},
'log_level': 'INFO',
'use_vnodes': False,
'id': 0,
'ipprefix': None,
'scylla_mode': 'dev', # This is what we're testing
}

with open(cluster_conf, 'w') as f:
YAML().dump(config_data, f)

# Read back and verify scylla_mode is preserved
with open(cluster_conf, 'r') as f:
loaded_data = YAML().load(f)

assert 'scylla_mode' in loaded_data
assert loaded_data['scylla_mode'] == 'dev'

# Also test with 'debug' mode
config_data['scylla_mode'] = 'debug'
with open(cluster_conf, 'w') as f:
YAML().dump(config_data, f)

with open(cluster_conf, 'r') as f:
loaded_data = YAML().load(f)

assert loaded_data['scylla_mode'] == 'debug'

# Test with 'release' mode
config_data['scylla_mode'] = 'release'
with open(cluster_conf, 'w') as f:
YAML().dump(config_data, f)

with open(cluster_conf, 'r') as f:
loaded_data = YAML().load(f)

assert loaded_data['scylla_mode'] == 'release'
Loading