Example #1
0
 def create_cf(self):
     cf_def = self.Cassandra.CfDef(name=self.cf_name, keyspace=self.ks_name)
     retry_till_success(self.client.system_add_column_family, cf_def, timeout=30)
     time.sleep(0.5)
     retry_till_success(self.wait_for_agreement, timeout=10)
     time.sleep(0.5)
     return self
Example #2
0
 def create_cf(self):
     cf_def = self.Cassandra.CfDef(name=self.cf_name, keyspace=self.ks_name)
     retry_till_success(self.client.system_add_column_family, cf_def, timeout=30)
     time.sleep(0.5)
     retry_till_success(self.wait_for_agreement, timeout=10)
     time.sleep(0.5)
     return self
Example #3
0
    def insert_columns(self, num_rows=10, consistency_level='QUORUM'):
        """ Insert some basic values """
        cf_parent = self.Cassandra.ColumnParent(column_family=self.cf_name)

        for row_key in ('row_%d'%i for i in xrange(num_rows)):
            col = self.Cassandra.Column(name='col_0', value='val_0',
                    timestamp=int(time.time()*1000))
            retry_till_success(self.client.insert,
                    key=row_key, column_parent=cf_parent, column=col,
                    consistency_level=self._translate_cl(consistency_level),
                    timeout=30)
        return self
Example #4
0
    def insert_columns(self, num_rows=10, consistency_level='QUORUM'):
        """ Insert some basic values """
        cf_parent = self.Cassandra.ColumnParent(column_family=self.cf_name)

        for row_key in ('row_%d' % i for i in xrange(num_rows)):
            col = self.Cassandra.Column(name='col_0', value='val_0',
                                        timestamp=int(time.time() * 1000))
            retry_till_success(self.client.insert,
                               key=row_key, column_parent=cf_parent, column=col,
                               consistency_level=self._translate_cl(consistency_level),
                               timeout=30)
        return self
Example #5
0
 def create_ks(self, replication_factor=1):
     if self.cassandra_interface == '07':
         ks_def = self.Cassandra.KsDef(name=self.ks_name,
                 strategy_class='org.apache.cassandra.locator.SimpleStrategy',
                 replication_factor=int(replication_factor),
                 cf_defs=[])
     else:
         ks_def = self.Cassandra.KsDef(name=self.ks_name,
                 strategy_class='org.apache.cassandra.locator.SimpleStrategy',
                 strategy_options={'replication_factor': str(replication_factor)},
                 cf_defs=[])
     retry_till_success(self.client.system_add_keyspace, ks_def, timeout=30)
     time.sleep(0.5)
     retry_till_success(self.wait_for_agreement, timeout=10)
     time.sleep(0.5)
     self.use_ks()
     return self
Example #6
0
 def create_ks(self, replication_factor=1):
     if self.cassandra_interface == '07':
         ks_def = self.Cassandra.KsDef(name=self.ks_name,
                                       strategy_class='org.apache.cassandra.locator.SimpleStrategy',
                                       replication_factor=int(replication_factor),
                                       cf_defs=[])
     else:
         ks_def = self.Cassandra.KsDef(name=self.ks_name,
                                       strategy_class='org.apache.cassandra.locator.SimpleStrategy',
                                       strategy_options={'replication_factor': str(replication_factor)},
                                       cf_defs=[])
     retry_till_success(self.client.system_add_keyspace, ks_def, timeout=30)
     time.sleep(0.5)
     retry_till_success(self.wait_for_agreement, timeout=10)
     time.sleep(0.5)
     self.use_ks()
     return self
Example #7
0
 def query_columns(self, num_rows=10, consistency_level='QUORUM'):
     """ Check that the values inserted in insert_columns() are present """
     for row_key in ('row_%d'%i for i in xrange(num_rows)):
         cpath = self.Cassandra.ColumnPath(column_family=self.cf_name,
                 column='col_0')
         cosc = retry_till_success(self.client.get, key=row_key, column_path=cpath,
                 consistency_level=self._translate_cl(consistency_level),
                 timeout=30)
         col = cosc.column
         value = col.value
         assert value == 'val_0', "column did not have the same value that was inserted!"
     return self
Example #8
0
 def query_columns(self, num_rows=10, consistency_level='QUORUM'):
     """ Check that the values inserted in insert_columns() are present """
     for row_key in ('row_%d' % i for i in xrange(num_rows)):
         cpath = self.Cassandra.ColumnPath(column_family=self.cf_name,
                                           column='col_0')
         cosc = retry_till_success(self.client.get, key=row_key, column_path=cpath,
                                   consistency_level=self._translate_cl(consistency_level),
                                   timeout=30)
         col = cosc.column
         value = col.value
         assert value == 'val_0', "column did not have the same value that was inserted!"
     return self
    def one_one_test(self):
        cluster = self.cluster

        cluster.populate(3).start()
        [node1, node2, node3] = cluster.nodelist()

        cursor1 = self.patient_cql_connection(node1).cursor()
        self.create_ks(cursor1, "ks", 3)
        create_c1c2_table(self, cursor1)

        cursor2 = self.patient_cql_connection(node2, "ks").cursor()

        # insert and get at CL.ONE
        for n in xrange(0, 100):
            insert_c1c2(cursor1, n, "ONE")
            retry_till_success(query_c1c2, cursor2, n, "ONE", timeout=5)

        # shutdown a node an test again
        node3.stop(wait_other_notice=True)
        for n in xrange(100, 200):
            insert_c1c2(cursor1, n, "ONE")
            retry_till_success(query_c1c2, cursor2, n, "ONE", timeout=5)

        # shutdown a second node an test again
        node2.stop(wait_other_notice=True)
        for n in xrange(200, 300):
            insert_c1c2(cursor1, n, "ONE")
            retry_till_success(query_c1c2, cursor1, n, "ONE", timeout=5)
    def one_one_test(self):
        cluster = self.cluster

        cluster.populate(3).start()
        [node1, node2, node3] = cluster.nodelist()

        cursor1 = self.patient_cql_connection(node1).cursor()
        self.create_ks(cursor1, 'ks', 3)
        create_c1c2_table(self, cursor1)

        cursor2 = self.patient_cql_connection(node2, 'ks').cursor()

        # insert and get at CL.ONE
        for n in xrange(0, 100):
            insert_c1c2(cursor1, n, "ONE")
            retry_till_success(query_c1c2, cursor2, n, "ONE", timeout=5)

        # shutdown a node an test again
        node3.stop(wait_other_notice=True)
        for n in xrange(100, 200):
            insert_c1c2(cursor1, n, "ONE")
            retry_till_success(query_c1c2, cursor2, n, "ONE", timeout=5)

        # shutdown a second node an test again
        node2.stop(wait_other_notice=True)
        for n in xrange(200, 300):
            insert_c1c2(cursor1, n, "ONE")
            retry_till_success(query_c1c2, cursor1, n, "ONE", timeout=5)
Example #11
0
 def use_ks(self):
     retry_till_success(self.client.set_keyspace, self.ks_name, timeout=30)
     return self
Example #12
0
 def use_ks(self):
     retry_till_success(self.client.set_keyspace, self.ks_name, timeout=30)
     return self