@@ -75,7 +75,7 @@ def get_server_versions():
7575 if cass_version is not None :
7676 return (cass_version , cql_version )
7777
78- c = Cluster ()
78+ c = TestCluster ()
7979 s = c .connect ()
8080 row = s .execute ('SELECT cql_version, release_version FROM system.local' )[0 ]
8181
@@ -199,33 +199,14 @@ def _get_dse_version_from_cass(cass_version):
199199 CCM_KWARGS ['version' ] = CCM_VERSION
200200
201201
202- #This changes the default contact_point parameter in Cluster
203- def set_default_cass_ip ():
204- if CASSANDRA_IP .startswith ("127.0.0." ):
205- return
206- defaults = list (Cluster .__init__ .__defaults__ )
207- defaults = [[CASSANDRA_IP ]] + defaults [1 :]
208- try :
209- Cluster .__init__ .__defaults__ = tuple (defaults )
210- except :
211- Cluster .__init__ .__func__ .__defaults__ = tuple (defaults )
212-
213-
214- def set_default_beta_flag_true ():
215- defaults = list (Cluster .__init__ .__defaults__ )
216- defaults = (defaults [:28 ] + [True ] + defaults [29 :])
217- try :
218- Cluster .__init__ .__defaults__ = tuple (defaults )
219- except :
220- Cluster .__init__ .__func__ .__defaults__ = tuple (defaults )
221-
222-
202+ ALLOW_BETA_PROTOCOL = False
223203def get_default_protocol ():
224- if CASSANDRA_VERSION >= Version ('4.0' ):
204+ if CASSANDRA_VERSION >= Version ('4.0-a ' ):
225205 if DSE_VERSION :
226206 return ProtocolVersion .DSE_V2
227207 else :
228- set_default_beta_flag_true ()
208+ global ALLOW_BETA_PROTOCOL
209+ ALLOW_BETA_PROTOCOL = True
229210 return ProtocolVersion .V5
230211 if CASSANDRA_VERSION >= Version ('3.10' ):
231212 if DSE_VERSION :
@@ -254,7 +235,7 @@ def get_supported_protocol_versions():
254235 4.0(C*) -> 5(beta),4,3
255236 4.0(DSE) -> DSE_v2, DSE_V1,4,3
256237` """
257- if CASSANDRA_VERSION >= Version ('4.0' ):
238+ if CASSANDRA_VERSION >= Version ('4.0-a ' ):
258239 if DSE_VERSION :
259240 return (3 , 4 , ProtocolVersion .DSE_V1 , ProtocolVersion .DSE_V2 )
260241 else :
@@ -293,7 +274,7 @@ def get_unsupported_upper_protocol():
293274 supported by the version of C* running
294275 """
295276
296- if CASSANDRA_VERSION >= Version ('4.0' ):
277+ if CASSANDRA_VERSION >= Version ('4.0-a ' ):
297278 if DSE_VERSION :
298279 return None
299280 else :
@@ -341,9 +322,9 @@ def _id_and_mark(f):
341322greaterthanorequalcass36 = unittest .skipUnless (CASSANDRA_VERSION >= Version ('3.6' ), 'Cassandra version 3.6 or greater required' )
342323greaterthanorequalcass3_10 = unittest .skipUnless (CASSANDRA_VERSION >= Version ('3.10' ), 'Cassandra version 3.10 or greater required' )
343324greaterthanorequalcass3_11 = unittest .skipUnless (CASSANDRA_VERSION >= Version ('3.11' ), 'Cassandra version 3.11 or greater required' )
344- greaterthanorequalcass40 = unittest .skipUnless (CASSANDRA_VERSION >= Version ('4.0' ), 'Cassandra version 4.0 or greater required' )
345- lessthanorequalcass40 = unittest .skipUnless (CASSANDRA_VERSION <= Version ('4.0' ), 'Cassandra version less or equal to 4.0 required' )
346- lessthancass40 = unittest .skipUnless (CASSANDRA_VERSION < Version ('4.0' ), 'Cassandra version less than 4.0 required' )
325+ greaterthanorequalcass40 = unittest .skipUnless (CASSANDRA_VERSION >= Version ('4.0-a ' ), 'Cassandra version 4.0 or greater required' )
326+ lessthanorequalcass40 = unittest .skipUnless (CASSANDRA_VERSION <= Version ('4.0-a ' ), 'Cassandra version less or equal to 4.0 required' )
327+ lessthancass40 = unittest .skipUnless (CASSANDRA_VERSION < Version ('4.0-a ' ), 'Cassandra version less than 4.0 required' )
347328lessthancass30 = unittest .skipUnless (CASSANDRA_VERSION < Version ('3.0' ), 'Cassandra version less then 3.0 required' )
348329greaterthanorequaldse68 = unittest .skipUnless (DSE_VERSION and DSE_VERSION >= Version ('6.8' ), "DSE 6.8 or greater required for this test" )
349330greaterthanorequaldse67 = unittest .skipUnless (DSE_VERSION and DSE_VERSION >= Version ('6.7' ), "DSE 6.7 or greater required for this test" )
@@ -469,7 +450,6 @@ def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=None,
469450 dse_cluster = True if DSE_VERSION else False
470451 if not workloads :
471452 workloads = []
472- set_default_cass_ip ()
473453
474454 if ccm_options is None and DSE_VERSION :
475455 ccm_options = {"version" : CCM_VERSION }
@@ -527,9 +507,6 @@ def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=None,
527507 CCM_CLUSTER = DseCluster (path , cluster_name , ** ccm_options )
528508 CCM_CLUSTER .set_configuration_options ({'start_native_transport' : True })
529509 CCM_CLUSTER .set_configuration_options ({'batch_size_warn_threshold_in_kb' : 5 })
530- if Version (dse_version ) >= Version ('5.0' ):
531- CCM_CLUSTER .set_configuration_options ({'enable_user_defined_functions' : True })
532- CCM_CLUSTER .set_configuration_options ({'enable_scripted_user_defined_functions' : True })
533510 if Version (dse_version ) >= Version ('5.1' ):
534511 # For Inet4Address
535512 CCM_CLUSTER .set_dse_configuration_options ({
@@ -565,6 +542,12 @@ def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=None,
565542 CCM_CLUSTER .set_configuration_options ({'enable_user_defined_functions' : True })
566543 if Version (cassandra_version ) >= Version ('3.0' ):
567544 CCM_CLUSTER .set_configuration_options ({'enable_scripted_user_defined_functions' : True })
545+ if Version (cassandra_version ) >= Version ('4.0-a' ):
546+ CCM_CLUSTER .set_configuration_options ({
547+ 'enable_materialized_views' : True ,
548+ 'enable_sasi_indexes' : True ,
549+ 'enable_transient_replication' : True ,
550+ })
568551 common .switch_cluster (path , cluster_name )
569552 CCM_CLUSTER .set_configuration_options (configuration_options )
570553 CCM_CLUSTER .populate (nodes , ipformat = ipformat )
@@ -699,9 +682,9 @@ def setup_keyspace(ipformat=None, wait=True, protocol_version=None):
699682 _protocol_version = PROTOCOL_VERSION
700683
701684 if not ipformat :
702- cluster = Cluster (protocol_version = _protocol_version )
685+ cluster = TestCluster (protocol_version = _protocol_version )
703686 else :
704- cluster = Cluster (contact_points = ["::1" ], protocol_version = _protocol_version )
687+ cluster = TestCluster (contact_points = ["::1" ], protocol_version = _protocol_version )
705688 session = cluster .connect ()
706689
707690 try :
@@ -795,7 +778,7 @@ def create_keyspace(cls, rf):
795778
796779 @classmethod
797780 def common_setup (cls , rf , keyspace_creation = True , create_class_table = False , ** cluster_kwargs ):
798- cls .cluster = Cluster ( protocol_version = PROTOCOL_VERSION , ** cluster_kwargs )
781+ cls .cluster = TestCluster ( ** cluster_kwargs )
799782 cls .session = cls .cluster .connect (wait_for_all_pools = True )
800783 cls .ks_name = cls .__name__ .lower ()
801784 if keyspace_creation :
@@ -981,3 +964,19 @@ def assert_startswith(s, prefix):
981964 raise AssertionError (
982965 '{} does not start with {}' .format (repr (s ), repr (prefix ))
983966 )
967+
968+
969+ class TestCluster (object ):
970+ DEFAULT_PROTOCOL_VERSION = default_protocol_version
971+ DEFAULT_CASSANDRA_IP = CASSANDRA_IP
972+ DEFAULT_ALLOW_BETA = ALLOW_BETA_PROTOCOL
973+
974+ def __new__ (cls , ** kwargs ):
975+ if 'protocol_version' not in kwargs :
976+ kwargs ['protocol_version' ] = cls .DEFAULT_PROTOCOL_VERSION
977+ if 'contact_points' not in kwargs :
978+ kwargs ['contact_points' ] = [cls .DEFAULT_CASSANDRA_IP ]
979+ if 'allow_beta_protocol_version' not in kwargs :
980+ kwargs ['allow_beta_protocol_version' ] = cls .DEFAULT_ALLOW_BETA
981+ return Cluster (** kwargs )
982+
0 commit comments