MCPcopy Index your code
hub / github.com/apache/cassandra-python-driver / setup_keyspace

Function setup_keyspace

tests/integration/__init__.py:740–792  ·  view source on GitHub ↗
(ipformat=None, wait=True, protocol_version=None, port=9042)

Source from the content-addressed store, hash-verified

738
739
740def setup_keyspace(ipformat=None, wait=True, protocol_version=None, port=9042):
741 # wait for nodes to startup
742 if wait:
743 time.sleep(10)
744
745 if protocol_version:
746 _protocol_version = protocol_version
747 else:
748 _protocol_version = PROTOCOL_VERSION
749
750 if not ipformat:
751 cluster = TestCluster(protocol_version=_protocol_version, port=port)
752 else:
753 cluster = TestCluster(contact_points=["::1"], protocol_version=_protocol_version, port=port)
754 session = cluster.connect()
755
756 try:
757 for ksname in ('test1rf', 'test2rf', 'test3rf'):
758 if ksname in cluster.metadata.keyspaces:
759 execute_until_pass(session, "DROP KEYSPACE %s" % ksname)
760
761 ddl = '''
762 CREATE KEYSPACE test3rf
763 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'}'''
764 execute_with_long_wait_retry(session, ddl)
765
766 ddl = '''
767 CREATE KEYSPACE test2rf
768 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '2'}'''
769 execute_with_long_wait_retry(session, ddl)
770
771 ddl = '''
772 CREATE KEYSPACE test1rf
773 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}'''
774 execute_with_long_wait_retry(session, ddl)
775
776 ddl_3f = '''
777 CREATE TABLE test3rf.test (
778 k int PRIMARY KEY,
779 v int )'''
780 execute_with_long_wait_retry(session, ddl_3f)
781
782 ddl_1f = '''
783 CREATE TABLE test1rf.test (
784 k int PRIMARY KEY,
785 v int )'''
786 execute_with_long_wait_retry(session, ddl_1f)
787
788 except Exception:
789 traceback.print_exc()
790 raise
791 finally:
792 cluster.shutdown()
793
794
795class UpDownWaiter(object):

Callers 4

setup_moduleFunction · 0.90
setup_moduleFunction · 0.90
_upgrade_step_setupMethod · 0.90
use_clusterFunction · 0.85

Calls 6

TestClusterClass · 0.85
execute_until_passFunction · 0.85
sleepMethod · 0.80
connectMethod · 0.45
shutdownMethod · 0.45

Tested by 2

setup_moduleFunction · 0.72
setup_moduleFunction · 0.72