def scylla_yaml(self) -> dict: scylla_yaml = ScyllaYaml( ) if self.scylla_yaml_raw is None else self.scylla_yaml_raw scylla_yaml.cluster_name = self.cluster_name if self.bootstrap is not None: scylla_yaml.auto_bootstrap = self.bootstrap return scylla_yaml.dict(exclude_defaults=True, exclude_none=True, exclude_unset=True)
def test_update_with_dict_object(): yaml1 = ScyllaYaml( cluster_name='cluster1', redis_keyspace_replication_strategy='NetworkTopologyStrategy') test_config_file = Path( __file__).parent / 'test_data' / 'scylla_yaml_update.yaml' with open(test_config_file, "r") as test_file: test_config_file_yaml = yaml.load(test_file) append_scylla_args_dict = yaml.load( test_config_file_yaml["append_scylla_yaml"]) yaml1.update(append_scylla_args_dict) assert yaml1.enable_sstables_mc_format == append_scylla_args_dict[ "enable_sstables_mc_format"] assert yaml1.enable_sstables_md_format == append_scylla_args_dict[ "enable_sstables_md_format"]
def _run_test(self, builder_params: dict, expected_as_dict: dict = None): instance = self.builder_class(**builder_params) resulted_as_dict = instance.dict(exclude_defaults=True, exclude_unset=True) if expected_as_dict: assert resulted_as_dict == expected_as_dict ScyllaYaml(**resulted_as_dict)
def test_copy(): original = ScyllaYaml( redis_keyspace_replication_strategy='SimpleStrategy', client_encryption_options=ClientEncryptionOptions( enabled=True, certificate='/tmp/123.crt', keyfile='/tmp/123.key', truststore='/tmp/trust.pem', ), server_encryption_options=ServerEncryptionOptions( internode_encryption='all', certificate='/tmp/123.crt', keyfile='/tmp/123.key', truststore='/tmp/trust.pem', )) copy_instance = original.copy() assert copy_instance == original assert copy_instance.dict(exclude_unset=True, exclude_defaults=True) == original.dict( exclude_unset=True, exclude_defaults=True) copy_instance.client_encryption_options.enabled = False assert copy_instance.client_encryption_options.enabled is False assert original.client_encryption_options.enabled is True assert copy_instance != original assert copy_instance.dict( exclude_unset=True, exclude_defaults=True) != original.dict( exclude_unset=True, exclude_defaults=True) copy_instance = original.copy() copy_instance.client_encryption_options = None assert copy_instance != original assert copy_instance.dict( exclude_unset=True, exclude_defaults=True) != original.dict( exclude_unset=True, exclude_defaults=True)
def test_update_with_scylla_yaml_object(): yaml1 = ScyllaYaml( cluster_name='cluster1', redis_keyspace_replication_strategy='NetworkTopologyStrategy') yaml2 = ScyllaYaml( redis_keyspace_replication_strategy='SimpleStrategy', client_encryption_options=ClientEncryptionOptions( enabled=True, certificate='/tmp/123.crt', keyfile='/tmp/123.key', truststore='/tmp/trust.pem', ), server_encryption_options=ServerEncryptionOptions( internode_encryption='all', certificate='/tmp/123.crt', keyfile='/tmp/123.key', truststore='/tmp/trust.pem', )) yaml3 = ScyllaYaml(client_encryption_options=ClientEncryptionOptions()) yaml1.update(yaml2, yaml3) assert yaml1 == ScyllaYaml( cluster_name='cluster1', # redis_keyspace_replication_strategy property is not getting changed because of the problem with update() # which does not allow to make distinction between default value and value that equals to default redis_keyspace_replication_strategy='NetworkTopologyStrategy', server_encryption_options=ServerEncryptionOptions( internode_encryption='all', certificate='/tmp/123.crt', keyfile='/tmp/123.key', truststore='/tmp/trust.pem'), client_encryption_options=ClientEncryptionOptions())
def __init__(self, node_num: int, parent_cluster, base_logdir: str): self._private_ip_address = '1.1.1.' + str(node_num) self._public_ip_address = '2.2.2.' + str(node_num) self._ipv6_ip_address = 'aaaa:db8:aaaa:aaaa:aaaa:aaaa:aaaa:aaa' + str(node_num) self._scylla_yaml = ScyllaYaml() super().__init__( base_logdir=base_logdir, parent_cluster=parent_cluster, name='node-' + str(node_num), ssh_login_info=dict(key_file='~/.ssh/scylla-test'), )
def scylla_machine_image_json(self) -> str: """Specifies configuration file accepted by scylla-machine-image service""" if (self.params.get("data_volume_disk_num") or 0) > 0: data_device = 'attached' else: data_device = 'instance_store' scylla_yaml = ScyllaYaml() scylla_yaml.cluster_name = f"{self.params.get('user_prefix') or DEFAULT_USER_PREFIX}-{self.test_config.test_id()[:8]}" smi_payload = { "start_scylla_on_first_boot": False, "data_device": data_device, "raid_level": self.params.get("raid_level") or 0, "scylla_yaml": scylla_yaml.dict(exclude_defaults=True, exclude_none=True, exclude_unset=True) } return json.dumps(smi_payload)