def setup_cluster(self, fixture_dtest_setup): self.tokens = ['00010', '00020', '00030'] patch_start(self.cluster) self.cluster.set_configuration_options(values={'hinted_handoff_enabled': False, 'num_tokens': 1, 'commitlog_sync_period_in_ms': 500, 'enable_transient_replication': True, 'partitioner' : 'org.apache.cassandra.dht.OrderPreservingPartitioner'}) print("CLUSTER INSTALL DIR: ") print(self.cluster.get_install_dir()) self.cluster.populate(3, tokens=self.tokens, debug=True, install_byteman=True) # self.cluster.populate(3, debug=True, install_byteman=True) self.cluster.start(wait_other_notice=True, wait_for_binary_proto=True, jvm_args=['-Dcassandra.enable_nodelocal_queries=true']) # enable shared memory for node in self.cluster.nodelist(): patch_start(node) print(node.logfilename()) self.nodes = self.cluster.nodelist() self.node1, self.node2, self.node3 = self.nodes session = self.exclusive_cql_connection(self.node3) replication_params = OrderedDict() replication_params['class'] = 'NetworkTopologyStrategy' replication_params['datacenter1'] = '3/1' replication_params = ', '.join("'%s': '%s'" % (k, v) for k, v in replication_params.items()) session.execute("CREATE KEYSPACE %s WITH REPLICATION={%s}" % (self.keyspace, replication_params)) print("CREATE KEYSPACE %s WITH REPLICATION={%s}" % (self.keyspace, replication_params)) session.execute( "CREATE TABLE %s.%s (pk varchar, ck int, value int, PRIMARY KEY (pk, ck)) WITH speculative_retry = 'NEVER' AND additional_write_policy = 'NEVER' AND read_repair = 'NONE'" % ( self.keyspace, self.table))
def setup_schema(self): session = self.exclusive_cql_connection(self.node1) replication_params = OrderedDict() replication_params['class'] = 'NetworkTopologyStrategy' replication_params['datacenter1'] = self.replication_factor() replication_params = ', '.join("'%s': '%s'" % (k, v) for k, v in replication_params.items()) session.execute("CREATE KEYSPACE %s WITH REPLICATION={%s}" % (self.keyspace, replication_params)) session.execute("CREATE TABLE %s.%s (pk int, ck int, value int, PRIMARY KEY (pk, ck)) WITH speculative_retry = 'NEVER' AND read_repair = 'NONE';" % (self.keyspace, self.table))
def test_keyspace_rf_changes(self): """ they should throw an exception """ session = self.exclusive_cql_connection(self.node1) replication_params = OrderedDict() replication_params['class'] = 'NetworkTopologyStrategy' assert self.replication_factor() == '3/1' replication_params['datacenter1'] = '5/2' replication_params = ', '.join("'%s': '%s'" % (k, v) for k, v in replication_params.items()) with pytest.raises(ConfigurationException): session.execute("ALTER KEYSPACE %s WITH REPLICATION={%s}" % (self.keyspace, replication_params))
def setup_cluster(self, fixture_dtest_setup): self.tokens = ['00010', '00020', '00030'] patch_start(self.cluster) self.cluster.set_configuration_options( values={ 'hinted_handoff_enabled': False, 'num_tokens': 1, 'commitlog_sync_period_in_ms': 500, 'enable_transient_replication': True, 'partitioner': 'org.apache.cassandra.dht.OrderPreservingPartitioner' }) print("CLUSTER INSTALL DIR: ") print(self.cluster.get_install_dir()) self.cluster.populate(3, tokens=self.tokens, debug=True, install_byteman=True) # self.cluster.populate(3, debug=True, install_byteman=True) self.cluster.start( wait_other_notice=True, wait_for_binary_proto=True, jvm_args=['-Dcassandra.enable_nodelocal_queries=true']) # enable shared memory for node in self.cluster.nodelist(): patch_start(node) print(node.logfilename()) self.nodes = self.cluster.nodelist() self.node1, self.node2, self.node3 = self.nodes session = self.exclusive_cql_connection(self.node3) replication_params = OrderedDict() replication_params['class'] = 'NetworkTopologyStrategy' replication_params['datacenter1'] = '3/1' replication_params = ', '.join("'%s': '%s'" % (k, v) for k, v in replication_params.items()) session.execute("CREATE KEYSPACE %s WITH REPLICATION={%s}" % (self.keyspace, replication_params)) print("CREATE KEYSPACE %s WITH REPLICATION={%s}" % (self.keyspace, replication_params)) session.execute( "CREATE TABLE %s.%s (pk varchar, ck int, value int, PRIMARY KEY (pk, ck)) WITH speculative_retry = 'NEVER' AND additional_write_policy = 'NEVER' AND read_repair = 'NONE'" % (self.keyspace, self.table))