def test_shares_relation(self): share_dict = {'id': 'fake share id1'} db_api.share_network_create(self.fake_context, self.share_nw_dict) db_api.share_create(self.fake_context, share_dict) result = db_api.share_network_get(self.fake_context, self.share_nw_dict['id']) self.assertEqual(len(result['shares']), 0)
def test_share_filter_all_by_host_with_pools_multiple_hosts(self): shares = [[api.share_create(self.ctxt, {'host': value}) for value in ('foo', 'foo#pool0', 'foo', 'foo#pool1')]] api.share_create(self.ctxt, {'host': 'foobar'}) self._assertEqualListsOfObjects(shares[0], api.share_get_all_by_host( self.ctxt, 'foo'), ignored_keys=['share_type', 'share_type_id', 'export_locations'])
def test_share_filter_all_by_host_with_pools_multiple_hosts(self): shares = [[ api.share_create(self.ctxt, {'host': value}) for value in ('foo', 'foo#pool0', 'foo', 'foo#pool1') ]] api.share_create(self.ctxt, {'host': 'foobar'}) self._assertEqualListsOfObjects( shares[0], api.share_get_all_by_host(self.ctxt, 'foo'), ignored_keys=['share_type', 'share_type_id', 'export_locations'])
def test_get_with_shares(self, shares): db_api.share_network_create(self.fake_context, self.share_nw_dict) for share in shares: share.update({'share_network_id': self.share_nw_dict['id']}) db_api.share_create(self.fake_context, share) result = db_api.share_network_get(self.fake_context, self.share_nw_dict['id']) self.assertEqual(len(result['shares']), len(shares)) for index, share in enumerate(shares): self._check_fields(expected=share, actual=result['shares'][index])
def test_share_export_locations_update_string(self): share = api.share_create(self.ctxt, {'host': 'foobar'}) initial_location = 'fake1/1/' api.share_export_locations_update(self.ctxt, share['id'], initial_location, False) actual_result = api.share_export_locations_get(self.ctxt, share['id']) self.assertTrue(actual_result == [initial_location])
def test_share_filter_by_host_with_pools(self): shares = [[db_api.share_create(self.ctxt, {'host': value}) for value in ('foo', 'foo#pool0')]] db_utils.create_share() self._assertEqualListsOfObjects(shares[0], db_api.share_get_all_by_host( self.ctxt, 'foo'), ignored_keys=['share_type', 'share_type_id', 'export_locations'])
def test_custom_query(self): share = api.share_create(self.ctxt, {'host': 'foobar'}) test_access_values = { 'share_id': share['id'], 'access_type': 'ip', 'access_to': 'fake', } share_access = api.share_access_create(self.ctxt, test_access_values) api.share_access_delete(self.ctxt, share_access.id) self.assertRaises(exception.NotFound, api.share_access_get, self.ctxt, share_access.id)
def test_share_export_locations_update_valid_order(self): share = api.share_create(self.ctxt, {'host': 'foobar'}) initial_locations = ['fake1/1/', 'fake2/2', 'fake3/3'] update_locations = ['fake4/4', 'fake2/2', 'fake3/3'] # add initial locations api.share_export_locations_update(self.ctxt, share['id'], initial_locations, False) # update locations api.share_export_locations_update(self.ctxt, share['id'], update_locations, True) actual_result = api.share_export_locations_get(self.ctxt, share['id']) # actual result should contain locations in exact same order self.assertTrue(actual_result == update_locations)
def test_get_with_shares(self, shares): db_api.share_network_create(self.fake_context, self.share_nw_dict) share_instances = [] for share in shares: share.update({'share_network_id': self.share_nw_dict['id']}) share_instances.append( db_api.share_create(self.fake_context, share).instance ) result = db_api.share_network_get(self.fake_context, self.share_nw_dict['id']) self.assertEqual(len(result['share_instances']), len(shares)) for index, share_instance in enumerate(share_instances): self.assertEqual( share_instance['share_network_id'], result['share_instances'][index]['share_network_id'] )