def test_index_slice(self):
        self.client.request('set_keyspace', {'keyspace': 'Keyspace1'})
        cp = dict(column_family='Indexed1')
        self.client.request('insert', dict(key='key1', column_parent=cp, column=dict(name='birthdate', value=i64(1), timestamp=0), consistency_level='ONE'))
        self.client.request('insert', dict(key='key2', column_parent=cp, column=dict(name='birthdate', value=i64(2), timestamp=0), consistency_level='ONE'))
        self.client.request('insert', dict(key='key2', column_parent=cp, column=dict(name='b', value=i64(2), timestamp=0), consistency_level='ONE'))
        self.client.request('insert', dict(key='key3', column_parent=cp, column=dict(name='birthdate', value=i64(3), timestamp=0), consistency_level='ONE'))
        self.client.request('insert', dict(key='key3', column_parent=cp, column=dict(name='b', value=i64(3), timestamp=0), consistency_level='ONE'))

        # simple query on one index expression
        sp = dict(slice_range=dict(start='', finish='', reversed=False, count=1000))
        clause = dict(expressions=[dict(column_name='birthdate', op='EQ', value=i64(1))], start_key='', count=100)
        result = self.client.request('get_indexed_slices', dict(column_parent=cp, index_clause=clause, column_predicate=sp, consistency_level='ONE'))
        assert len(result) == 1, result
        assert result[0]['key'] == 'key1'
        assert len(result[0]['columns']) == 1, result[0]['columns']

        # solo unindexed expression is invalid
        clause = dict(expressions=[dict(column_name='b', op='EQ', value=i64(1))], start_key='', count=100)
        avro_utils.assert_raises(AvroRemoteException,
            self.client.request, 'get_indexed_slices', dict(column_parent=cp, index_clause=clause, column_predicate=sp, consistency_level='ONE'))

        # but unindexed expression added to indexed one is ok
        clause = dict(expressions=[dict(column_name='b', op='EQ', value=i64(3)),
                                   dict(column_name='birthdate', op='EQ', value=i64(3))],
                                   start_key='', count=100)
        result = self.client.request('get_indexed_slices', dict(column_parent=cp, index_clause=clause, column_predicate=sp, consistency_level='ONE'))
        assert len(result) == 1, result
        assert result[0]['key'] == 'key3'
        assert len(result[0]['columns']) == 2, result[0]['columns']
Ejemplo n.º 2
0
    def test_remove_simple(self):
        "removing a simple column"
        self.client.request('set_keyspace', {'keyspace': 'Keyspace1'})

        params = dict()
        params['key'] = 'key1'
        params['column_parent'] = {'column_family': 'Standard1'}
        params['column'] = new_column(1)
        params['consistency_level'] = 'ONE'
        self.client.request('insert', params)

        read_params = dict()
        read_params['key'] = params['key']
        read_params['column_path'] = dict()
        read_params['column_path']['column_family'] = 'Standard1'
        read_params['column_path']['column'] = params['column']['name']
        read_params['consistency_level'] = 'ONE'

        cosc = self.client.request('get', read_params)

        avro_utils.assert_cosc(cosc)

        remove_params = read_params
        remove_params['timestamp'] = timestamp()

        self.client.request('remove', remove_params)

        avro_utils.assert_raises(AvroRemoteException, self.client.request,
                                 'get', read_params)
Ejemplo n.º 3
0
    def test_create_rename_recreate(self):
        # create
        cf = {"keyspace": "CreateRenameRecreate", "name": "CF_1"}
        keyspace1 = {
            "name": "CreateRenameRecreate",
            "strategy_class": "org.apache.cassandra.locator.SimpleStrategy",
            "strategy_options": {},
            "replication_factor": 1,
            "cf_defs": [cf],
        }
        self.client.request("set_keyspace", {"keyspace": "system"})
        self.client.request("system_add_keyspace", {"ks_def": keyspace1})
        assert self.client.request("describe_keyspace", {"keyspace": keyspace1["name"]})

        # rename
        self.client.request(
            "system_rename_keyspace", {"old_name": keyspace1["name"], "new_name": keyspace1["name"] + "_renamed"}
        )
        assert self.client.request("describe_keyspace", {"keyspace": keyspace1["name"] + "_renamed"})
        avro_utils.assert_raises(
            AvroRemoteException, self.client.request, "describe_keyspace", {"keyspace": keyspace1["name"]}
        )

        # recreate
        self.client.request("system_add_keyspace", {"ks_def": keyspace1})
        assert self.client.request("describe_keyspace", {"keyspace": keyspace1["name"]})
    def test_remove_simple(self):
        "removing a simple column"
        self.client.request('set_keyspace', {'keyspace': 'Keyspace1'})

        params = dict()
        params['key'] = 'key1'
        params['column_parent'] = {'column_family': 'Standard1'}
        params['column'] = new_column(1)
        params['consistency_level'] = 'ONE'
        self.client.request('insert', params)

        read_params = dict()
        read_params['key'] = params['key']
        read_params['column_path'] = dict()
        read_params['column_path']['column_family'] = 'Standard1'
        read_params['column_path']['column'] = params['column']['name']
        read_params['consistency_level'] = 'ONE'

        cosc = self.client.request('get', read_params)

        avro_utils.assert_cosc(cosc)

        remove_params = read_params
        remove_params['timestamp'] = timestamp()

        self.client.request('remove', remove_params)

        avro_utils.assert_raises(AvroRemoteException,
                self.client.request, 'get', read_params)
Ejemplo n.º 5
0
    def test_index_slice(self):
        self.client.request('set_keyspace', {'keyspace': 'Keyspace1'})
        cp = dict(column_family='Indexed1')
        self.client.request('insert', dict(key='key1', column_parent=cp, column=dict(name='birthdate', value=i64(1), timestamp=0), consistency_level='ONE'))
        self.client.request('insert', dict(key='key2', column_parent=cp, column=dict(name='birthdate', value=i64(2), timestamp=0), consistency_level='ONE'))
        self.client.request('insert', dict(key='key2', column_parent=cp, column=dict(name='b', value=i64(2), timestamp=0), consistency_level='ONE'))
        self.client.request('insert', dict(key='key3', column_parent=cp, column=dict(name='birthdate', value=i64(3), timestamp=0), consistency_level='ONE'))
        self.client.request('insert', dict(key='key3', column_parent=cp, column=dict(name='b', value=i64(3), timestamp=0), consistency_level='ONE'))

        # simple query on one index expression
        sp = dict(slice_range=dict(start='', finish='', reversed=False, count=1000))
        clause = dict(expressions=[dict(column_name='birthdate', op='EQ', value=i64(1))], start_key='', count=100)
        result = self.client.request('get_indexed_slices', dict(column_parent=cp, index_clause=clause, column_predicate=sp, consistency_level='ONE'))
        assert len(result) == 1, result
        assert result[0]['key'] == 'key1'
        assert len(result[0]['columns']) == 1, result[0]['columns']

        # solo unindexed expression is invalid
        clause = dict(expressions=[dict(column_name='b', op='EQ', value=i64(1))], start_key='', count=100)
        avro_utils.assert_raises(AvroRemoteException,
            self.client.request, 'get_indexed_slices', dict(column_parent=cp, index_clause=clause, column_predicate=sp, consistency_level='ONE'))

        # but unindexed expression added to indexed one is ok
        clause = dict(expressions=[dict(column_name='b', op='EQ', value=i64(3)),
                                   dict(column_name='birthdate', op='EQ', value=i64(3))],
                                   start_key='', count=100)
        result = self.client.request('get_indexed_slices', dict(column_parent=cp, index_clause=clause, column_predicate=sp, consistency_level='ONE'))
        assert len(result) == 1, result
        assert result[0]['key'] == 'key3'
        assert len(result[0]['columns']) == 2, result[0]['columns']
    def test_system_column_family_operations(self):
        "adding, renaming, and removing column families"
        self.client.request('set_keyspace', {'keyspace': 'Keyspace1'})
        
        # create
        columnDef = dict()
        columnDef['name'] = b'ValidationColumn'
        columnDef['validation_class'] = 'BytesType'
        
        cfDef = dict()
        cfDef['keyspace'] = 'Keyspace1'
        cfDef['name'] = 'NewColumnFamily'
        cfDef['column_metadata'] = [columnDef]
        
        s = self.client.request('system_add_column_family', {'cf_def' : cfDef})
        assert isinstance(s, unicode), \
            'returned type is %s, (not \'unicode\')' % type(s)
        
        ks1 = self.client.request(
            'describe_keyspace', {'keyspace' : 'Keyspace1'})
        assert 'NewColumnFamily' in [x['name'] for x in ks1['cf_defs']]
        cfDef = [x for x in ks1['cf_defs'] if x['name']=='NewColumnFamily'][0]
        assert cfDef['id'] > 1000, str(cfid)

        # modify invalid
        cfDef['comparator_type'] = 'LongType' 
        avro_utils.assert_raises(AvroRemoteException,
                self.client.request,
                'system_update_column_family',
                {'cf_def': cfDef})
        
        # modify valid
        cfDef['comparator_type'] = 'BytesType' # revert back to old value.
        cfDef['row_cache_size'] = 25
        cfDef['gc_grace_seconds'] = 1
        self.client.request('system_update_column_family', {'cf_def': cfDef})
        ks1 = self.client.request('describe_keyspace', {'keyspace': 'Keyspace1'})
        server_cf = [x for x in ks1['cf_defs'] if x['name']=='NewColumnFamily'][0]
        assert server_cf
        assert server_cf['row_cache_size'] == 25
        assert server_cf['gc_grace_seconds'] == 1
        
        # rename
        self.client.request('system_rename_column_family',
            {'old_name' : 'NewColumnFamily', 'new_name': 'RenameColumnFamily'})
        ks1 = self.client.request(
            'describe_keyspace', {'keyspace' : 'Keyspace1'})
        assert 'RenameColumnFamily' in [x['name'] for x in ks1['cf_defs']]

        # drop
        self.client.request('system_drop_column_family',
            {'column_family' : 'RenameColumnFamily'})
        ks1 = self.client.request(
                'describe_keyspace', {'keyspace' : 'Keyspace1'})
        assert 'RenameColumnFamily' not in [x['name'] for x in ks1['cf_defs']]
        assert 'NewColumnFamily' not in [x['name'] for x in ks1['cf_defs']]
        assert 'Standard1' in [x['name'] for x in ks1['cf_defs']]
 def test_system_keyspace_operations(self):
     "adding, renaming, and removing keyspaces"
     
     # create
     keyspace = dict()
     keyspace['name'] = 'CreateKeyspace'
     keyspace['strategy_class'] = 'org.apache.cassandra.locator.SimpleStrategy'
     keyspace['replication_factor'] = 1
     keyspace['strategy_options'] = {}
     cfdef = dict();
     cfdef['keyspace'] = 'CreateKeyspace'
     cfdef['name'] = 'CreateKsCf'
     keyspace['cf_defs'] = [cfdef]
     
     s = self.client.request('system_add_keyspace', {'ks_def' : keyspace})
     assert isinstance(s, unicode), 'returned type is %s, (not \'unicode\')' % type(s)
     
     self.client.request('set_keyspace', {'keyspace' : 'CreateKeyspace'})
     
     # modify invalid
     modified_keyspace = {'name': 'CreateKeyspace', 
                          'strategy_class': 'org.apache.cassandra.locator.OldNetworkTopologyStrategy',
                          'strategy_options': {}, 
                          'replication_factor': 2, 
                          'cf_defs': []}
     avro_utils.assert_raises(AvroRemoteException,
             self.client.request,
             'system_update_keyspace',
             {'ks_def': modified_keyspace})
     
     # modify valid
     modified_keyspace['replication_factor'] = 1
     self.client.request('system_update_keyspace', {'ks_def': modified_keyspace})
     modks = self.client.request('describe_keyspace', {'keyspace': 'CreateKeyspace'})
     assert modks['replication_factor'] == modified_keyspace['replication_factor']
     assert modks['strategy_class'] == modified_keyspace['strategy_class']
     
     # rename
     self.client.request('set_keyspace', {'keyspace' : 'CreateKeyspace'})
     s = self.client.request(
             'system_rename_keyspace', {'old_name' : 'CreateKeyspace', 'new_name' : 'RenameKeyspace'})
     assert isinstance(s, unicode), 'returned type is %s, (not \'unicode\')' % type(s)
     renameks = self.client.request('describe_keyspace',
             {'keyspace': 'RenameKeyspace'})
     assert renameks['name'] == 'RenameKeyspace'
     assert renameks['cf_defs'][0]['name'] == 'CreateKsCf'
     
     # drop
     s = self.client.request('system_drop_keyspace', {'keyspace' : 'RenameKeyspace'})
     assert isinstance(s, unicode), 'returned type is %s, (not \'unicode\')' % type(s)
     avro_utils.assert_raises(AvroRemoteException,
                   self.client.request,
                   'describe_keyspace',
                   {'keyspace' : 'RenameKeyspace'})
Ejemplo n.º 8
0
    def test_system_keyspace_operations(self):
        "adding, renaming, and removing keyspaces"

        # create
        keyspace = dict()
        keyspace['name'] = 'CreateKeyspace'
        keyspace[
            'strategy_class'] = 'org.apache.cassandra.locator.SimpleStrategy'
        keyspace['replication_factor'] = 1
        keyspace['strategy_options'] = {}
        cfdef = dict()
        cfdef['keyspace'] = 'CreateKeyspace'
        cfdef['name'] = 'CreateKsCf'
        keyspace['cf_defs'] = [cfdef]

        #test invalid strategy class
        keyspace['strategy_class'] = 'InvalidStrategy'
        avro_utils.assert_raises(AvroRemoteException, self.client.request,
                                 'system_add_keyspace', {'ks_def': keyspace})

        keyspace[
            'strategy_class'] = 'org.apache.cassandra.locator.SimpleStrategy'
        s = self.client.request('system_add_keyspace', {'ks_def': keyspace})
        assert isinstance(
            s, unicode), 'returned type is %s, (not \'unicode\')' % type(s)

        self.client.request('set_keyspace', {'keyspace': 'CreateKeyspace'})

        # modify valid
        modified_keyspace = {
            'name': 'CreateKeyspace',
            'strategy_class':
            'org.apache.cassandra.locator.OldNetworkTopologyStrategy',
            'strategy_options': {},
            'replication_factor': 1,
            'cf_defs': []
        }
        self.client.request('system_update_keyspace',
                            {'ks_def': modified_keyspace})
        modks = self.client.request('describe_keyspace',
                                    {'keyspace': 'CreateKeyspace'})
        assert modks['replication_factor'] == modified_keyspace[
            'replication_factor']
        assert modks['strategy_class'] == modified_keyspace['strategy_class']

        # drop
        s = self.client.request('system_drop_keyspace',
                                {'keyspace': 'CreateKeyspace'})
        assert isinstance(
            s, unicode), 'returned type is %s, (not \'unicode\')' % type(s)
        avro_utils.assert_raises(AvroRemoteException, self.client.request,
                                 'describe_keyspace',
                                 {'keyspace': 'CreateKeyspace'})
Ejemplo n.º 9
0
 def test_missing_super(self):
     "verifies that inserting doesn't yield false positives."
     self._set_keyspace('Keyspace1')
     avro_utils.assert_raises(
         AvroRemoteException, self.client.request, 'get',
         _make_read_params('key1', 'Super1', 'sc1', avro_utils.i64(1),
                           'ONE'))
     self._insert_super()
     avro_utils.assert_raises(
         AvroRemoteException, self.client.request, 'get',
         _make_read_params('key1', 'Super1', 'sc1', avro_utils.i64(1),
                           'ONE'))
 def test_missing_super(self):
     "verifies that inserting doesn't yield false positives."
     self._set_keyspace('Keyspace1')
     avro_utils.assert_raises(AvroRemoteException,
             self.client.request,
             'get',
             _make_read_params('key1', 'Super1', 'sc1', avro_utils.i64(1), 'ONE'))
     self._insert_super()
     avro_utils.assert_raises(AvroRemoteException,
             self.client.request,
             'get',
             _make_read_params('key1', 'Super1', 'sc1', avro_utils.i64(1), 'ONE'))
Ejemplo n.º 11
0
    def test_system_column_family_operations(self):
        "adding, renaming, and removing column families"
        self.client.request("set_keyspace", {"keyspace": "Keyspace1"})

        # create
        columnDef = dict()
        columnDef["name"] = b"ValidationColumn"
        columnDef["validation_class"] = "BytesType"

        cfDef = dict()
        cfDef["keyspace"] = "Keyspace1"
        cfDef["name"] = "NewColumnFamily"
        cfDef["column_metadata"] = [columnDef]

        s = self.client.request("system_add_column_family", {"cf_def": cfDef})
        assert isinstance(s, unicode), "returned type is %s, (not 'unicode')" % type(s)

        ks1 = self.client.request("describe_keyspace", {"keyspace": "Keyspace1"})
        assert "NewColumnFamily" in [x["name"] for x in ks1["cf_defs"]]
        cfDef = [x for x in ks1["cf_defs"] if x["name"] == "NewColumnFamily"][0]
        assert cfDef["id"] > 1000, str(cfid)

        # modify invalid
        cfDef["comparator_type"] = "LongType"
        avro_utils.assert_raises(
            AvroRemoteException, self.client.request, "system_update_column_family", {"cf_def": cfDef}
        )

        # modify valid
        cfDef["comparator_type"] = "BytesType"  # revert back to old value.
        cfDef["row_cache_size"] = 25
        cfDef["gc_grace_seconds"] = 1
        self.client.request("system_update_column_family", {"cf_def": cfDef})
        ks1 = self.client.request("describe_keyspace", {"keyspace": "Keyspace1"})
        server_cf = [x for x in ks1["cf_defs"] if x["name"] == "NewColumnFamily"][0]
        assert server_cf
        assert server_cf["row_cache_size"] == 25
        assert server_cf["gc_grace_seconds"] == 1

        # rename
        self.client.request(
            "system_rename_column_family", {"old_name": "NewColumnFamily", "new_name": "RenameColumnFamily"}
        )
        ks1 = self.client.request("describe_keyspace", {"keyspace": "Keyspace1"})
        assert "RenameColumnFamily" in [x["name"] for x in ks1["cf_defs"]]

        # drop
        self.client.request("system_drop_column_family", {"column_family": "RenameColumnFamily"})
        ks1 = self.client.request("describe_keyspace", {"keyspace": "Keyspace1"})
        assert "RenameColumnFamily" not in [x["name"] for x in ks1["cf_defs"]]
        assert "NewColumnFamily" not in [x["name"] for x in ks1["cf_defs"]]
        assert "Standard1" in [x["name"] for x in ks1["cf_defs"]]
Ejemplo n.º 12
0
    def test_system_keyspace_operations(self):
        "adding, renaming, and removing keyspaces"

        # create
        keyspace = dict()
        keyspace["name"] = "CreateKeyspace"
        keyspace["strategy_class"] = "org.apache.cassandra.locator.SimpleStrategy"
        keyspace["replication_factor"] = 1
        keyspace["strategy_options"] = {}
        cfdef = dict()
        cfdef["keyspace"] = "CreateKeyspace"
        cfdef["name"] = "CreateKsCf"
        keyspace["cf_defs"] = [cfdef]

        s = self.client.request("system_add_keyspace", {"ks_def": keyspace})
        assert isinstance(s, unicode), "returned type is %s, (not 'unicode')" % type(s)

        self.client.request("set_keyspace", {"keyspace": "CreateKeyspace"})

        # modify invalid
        modified_keyspace = {
            "name": "CreateKeyspace",
            "strategy_class": "org.apache.cassandra.locator.OldNetworkTopologyStrategy",
            "strategy_options": {},
            "replication_factor": 2,
            "cf_defs": [],
        }
        avro_utils.assert_raises(
            AvroRemoteException, self.client.request, "system_update_keyspace", {"ks_def": modified_keyspace}
        )

        # modify valid
        modified_keyspace["replication_factor"] = 1
        self.client.request("system_update_keyspace", {"ks_def": modified_keyspace})
        modks = self.client.request("describe_keyspace", {"keyspace": "CreateKeyspace"})
        assert modks["replication_factor"] == modified_keyspace["replication_factor"]
        assert modks["strategy_class"] == modified_keyspace["strategy_class"]

        # rename
        self.client.request("set_keyspace", {"keyspace": "CreateKeyspace"})
        s = self.client.request("system_rename_keyspace", {"old_name": "CreateKeyspace", "new_name": "RenameKeyspace"})
        assert isinstance(s, unicode), "returned type is %s, (not 'unicode')" % type(s)
        renameks = self.client.request("describe_keyspace", {"keyspace": "RenameKeyspace"})
        assert renameks["name"] == "RenameKeyspace"
        assert renameks["cf_defs"][0]["name"] == "CreateKsCf"

        # drop
        s = self.client.request("system_drop_keyspace", {"keyspace": "RenameKeyspace"})
        assert isinstance(s, unicode), "returned type is %s, (not 'unicode')" % type(s)
        avro_utils.assert_raises(
            AvroRemoteException, self.client.request, "describe_keyspace", {"keyspace": "RenameKeyspace"}
        )
Ejemplo n.º 13
0
    def test_system_column_family_operations(self):
        "adding, renaming, and removing column families"
        self.client.request('set_keyspace', {'keyspace': 'Keyspace1'})

        # create
        columnDef = dict()
        columnDef['name'] = b'ValidationColumn'
        columnDef['validation_class'] = 'BytesType'

        cfDef = dict()
        cfDef['keyspace'] = 'Keyspace1'
        cfDef['name'] = 'NewColumnFamily'
        cfDef['column_metadata'] = [columnDef]

        s = self.client.request('system_add_column_family', {'cf_def': cfDef})
        assert isinstance(s, unicode), \
            'returned type is %s, (not \'unicode\')' % type(s)

        ks1 = self.client.request('describe_keyspace',
                                  {'keyspace': 'Keyspace1'})
        assert 'NewColumnFamily' in [x['name'] for x in ks1['cf_defs']]
        cfDef = [x for x in ks1['cf_defs']
                 if x['name'] == 'NewColumnFamily'][0]
        assert cfDef['id'] > 1000, str(cfid)

        # modify invalid
        cfDef['comparator_type'] = 'LongType'
        avro_utils.assert_raises(AvroRemoteException, self.client.request,
                                 'system_update_column_family',
                                 {'cf_def': cfDef})

        # modify valid
        cfDef['comparator_type'] = 'BytesType'  # revert back to old value.
        cfDef['row_cache_size'] = 25
        cfDef['gc_grace_seconds'] = 1
        self.client.request('system_update_column_family', {'cf_def': cfDef})
        ks1 = self.client.request('describe_keyspace',
                                  {'keyspace': 'Keyspace1'})
        server_cf = [
            x for x in ks1['cf_defs'] if x['name'] == 'NewColumnFamily'
        ][0]
        assert server_cf
        assert server_cf['row_cache_size'] == 25
        assert server_cf['gc_grace_seconds'] == 1

        # drop
        self.client.request('system_drop_column_family',
                            {'column_family': 'NewColumnFamily'})
        ks1 = self.client.request('describe_keyspace',
                                  {'keyspace': 'Keyspace1'})
        assert 'NewColumnFamily' not in [x['name'] for x in ks1['cf_defs']]
        assert 'Standard1' in [x['name'] for x in ks1['cf_defs']]
Ejemplo n.º 14
0
    def test_batch_mutate(self):
        "batching addition/removal mutations"
        self.client.request('set_keyspace', {'keyspace': 'Keyspace1'})

        mutations = list()

        # New column mutations
        for i in range(3):
            cosc = {'column': new_column(i)}
            mutation = {'column_or_supercolumn': cosc}
            mutations.append(mutation)

        map_entry = {'key': 'key1', 'mutations': {'Standard1': mutations}}

        params = dict()
        params['mutation_map'] = [map_entry]
        params['consistency_level'] = 'ONE'

        self.client.request('batch_mutate', params)

        # Verify that new columns were added
        for i in range(3):
            column = new_column(i)
            cosc = self.__get('key1', 'Standard1', None, column['name'])
            avro_utils.assert_cosc(cosc)
            avro_utils.assert_columns_match(cosc['column'], column)

        # Add one more column; remove one column
        extra_column = new_column(3)
        remove_column = new_column(0)
        mutations = [{'column_or_supercolumn': {'column': extra_column}}]
        deletion = dict()
        deletion['timestamp'] = timestamp()
        deletion['predicate'] = {'column_names': [remove_column['name']]}
        mutations.append({'deletion': deletion})

        map_entry = {'key': 'key1', 'mutations': {'Standard1': mutations}}

        params = dict()
        params['mutation_map'] = [map_entry]
        params['consistency_level'] = 'ONE'

        self.client.request('batch_mutate', params)

        # Ensure successful column removal
        avro_utils.assert_raises(AvroRemoteException, self.__get, 'key1',
                                 'Standard1', None, remove_column['name'])

        # Ensure successful column addition
        cosc = self.__get('key1', 'Standard1', None, extra_column['name'])
        avro_utils.assert_cosc(cosc)
        avro_utils.assert_columns_match(cosc['column'], extra_column)
    def test_batch_mutate(self):
        "batching addition/removal mutations"
        self.client.request('set_keyspace', {'keyspace': 'Keyspace1'})

        mutations = list()
       
        # New column mutations
        for i in range(3):
            cosc = {'column': new_column(i)}
            mutation = {'column_or_supercolumn': cosc}
            mutations.append(mutation)

        map_entry = {'key': 'key1', 'mutations': {'Standard1': mutations}}

        params = dict()
        params['mutation_map'] = [map_entry]
        params['consistency_level'] = 'ONE'

        self.client.request('batch_mutate', params)

        # Verify that new columns were added
        for i in range(3):
            column = new_column(i)
            cosc = self.__get('key1', 'Standard1', None, column['name'])
            avro_utils.assert_cosc(cosc)
            avro_utils.assert_columns_match(cosc['column'], column)

        # Add one more column; remove one column
        extra_column = new_column(3); remove_column = new_column(0)
        mutations = [{'column_or_supercolumn': {'column': extra_column}}]
        deletion = dict()
        deletion['timestamp'] = timestamp()
        deletion['predicate'] = {'column_names': [remove_column['name']]}
        mutations.append({'deletion': deletion})

        map_entry = {'key': 'key1', 'mutations': {'Standard1': mutations}}

        params = dict()
        params['mutation_map'] = [map_entry]
        params['consistency_level'] = 'ONE'

        self.client.request('batch_mutate', params)

        # Ensure successful column removal
        avro_utils.assert_raises(AvroRemoteException,
                self.__get, 'key1', 'Standard1', None, remove_column['name'])

        # Ensure successful column addition
        cosc = self.__get('key1', 'Standard1', None, extra_column['name'])
        avro_utils.assert_cosc(cosc)
        avro_utils.assert_columns_match(cosc['column'], extra_column)
 def test_describe_ring_on_invalid_keyspace(self):
     "getting ring meta-data w/ an invalid keyspace"
     avro_utils.assert_raises(AvroRemoteException, self.client.request,
                   'describe_ring', {'keyspace':'system'})
Ejemplo n.º 17
0
 def test_describe_ring_on_invalid_keyspace(self):
     "getting ring meta-data w/ an invalid keyspace"
     avro_utils.assert_raises(AvroRemoteException, self.client.request,
                              'describe_ring', {'keyspace': 'system'})