本文整理汇总了Python中oio.container.client.ContainerClient.container_destroy方法的典型用法代码示例。如果您正苦于以下问题:Python ContainerClient.container_destroy方法的具体用法?Python ContainerClient.container_destroy怎么用?Python ContainerClient.container_destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oio.container.client.ContainerClient
的用法示例。
在下文中一共展示了ContainerClient.container_destroy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestBlobAuditorFunctional
# 需要导入模块: from oio.container.client import ContainerClient [as 别名]
# 或者: from oio.container.client.ContainerClient import container_destroy [as 别名]
class TestBlobAuditorFunctional(BaseTestCase):
def setUp(self):
super(TestBlobAuditorFunctional, self).setUp()
self.namespace = self.conf['namespace']
self.account = self.conf['account']
self.test_dir = self.conf['sds_path']
rawx_num, rawx_path, rawx_addr = self.get_service_url('rawx')
self.rawx = 'http://' + rawx_addr
self.h = hashlib.new('md5')
conf = {"namespace": self.namespace}
self.auditor = BlobAuditorWorker(conf, get_logger(None), None)
self.container_c = ContainerClient(conf)
self.blob_c = BlobClient()
self.ref = random_str(8)
self.container_c.container_create(self.account, self.ref)
self.url_rand = random_id(64)
self.data = random_str(1280)
self.h.update(self.data)
self.hash_rand = self.h.hexdigest().lower()
self.content = TestContent(
random_str(6), len(self.data), self.url_rand, 1)
self.content.id_container = cid_from_name(
self.account, self.ref).upper()
self.chunk = TestChunk(self.content.size, self.url_rand, 0,
self.hash_rand)
self.chunk_url = "%s/%s" % (self.rawx, self.chunk.id_chunk)
self.chunk_proxy = {"hash": self.chunk.md5, "pos": "0",
"size": self.chunk.size,
"url": self.chunk_url}
chunk_meta = {'content_path': self.content.path,
'container_id': self.content.id_container,
'content_chunkmethod': 'plain/nb_copy=3',
'content_policy': 'TESTPOLICY',
'content_id': '0000',
'content_version': 1,
'chunk_id': self.chunk.id_chunk,
'chunk_pos': self.chunk.pos}
self.blob_c.chunk_put(self.chunk_url, chunk_meta, self.data)
self.chunk_path = self.test_dir + '/data/' + self.namespace + \
'-rawx-1/' + self.chunk.id_chunk[0:3] + "/" + self.chunk.id_chunk
self.bad_container_id = '0'*64
def tearDown(self):
super(TestBlobAuditorFunctional, self).tearDown()
try:
self.container_c.content_delete(
self.account, self.ref, self.content.path)
except Exception:
pass
try:
self.container_c.container_destroy(self.account, self.ref)
except Exception:
pass
try:
os.remove(self.chunk_path)
except Exception:
pass
def init_content(self):
self.container_c.content_create(
self.account, self.ref, self.content.path, self.chunk.size,
self.hash_rand, data=[self.chunk_proxy])
def test_chunk_audit(self):
self.init_content()
self.auditor.chunk_audit(self.chunk_path)
def test_content_deleted(self):
self.assertRaises(exc.OrphanChunk, self.auditor.chunk_audit,
self.chunk_path)
def test_container_deleted(self):
self.container_c.container_destroy(self.account, self.ref)
self.assertRaises(exc.OrphanChunk, self.auditor.chunk_audit,
self.chunk_path)
def test_chunk_corrupted(self):
self.init_content()
with open(self.chunk_path, "w") as f:
f.write(random_str(1280))
self.assertRaises(exc.CorruptedChunk, self.auditor.chunk_audit,
self.chunk_path)
#.........这里部分代码省略.........
示例2: TestBlobAuditorFunctional
# 需要导入模块: from oio.container.client import ContainerClient [as 别名]
# 或者: from oio.container.client.ContainerClient import container_destroy [as 别名]
class TestBlobAuditorFunctional(BaseTestCase):
def setUp(self):
super(TestBlobAuditorFunctional, self).setUp()
self.namespace = self.conf['namespace']
self.account = self.conf['account']
self.test_dir = self.conf['sds_path']
self.chars = string.ascii_lowercase + string.ascii_uppercase +\
string.digits
self.chars_id = string.digits + 'ABCDEF'
self.rawx = 'http://' + self.conf["rawx"][0]['addr']
self.h = hashlib.new('md5')
conf = {"namespace": self.namespace}
self.auditor = BlobAuditorWorker(conf, get_logger(None), None)
self.container_c = ContainerClient(conf)
self.blob_c = BlobClient()
self.ref = rand_generator(self.chars, 8)
self.container_c.container_create(self.account, self.ref)
self.url_rand = rand_generator(self.chars_id, 64)
self.data = rand_generator(self.chars, 1280)
self.h.update(self.data)
self.hash_rand = self.h.hexdigest().lower()
self.content = TestContent(
rand_generator(self.chars, 6), len(self.data), self.url_rand, 1)
self.content.id_container = cid_from_name(
self.account, self.ref).upper()
self.chunk = TestChunk(self.content.size, self.url_rand, 0,
self.hash_rand)
self.chunk_url = "%s/%s" % (self.rawx, self.chunk.id_chunk)
self.chunk_proxy = {"hash": self.chunk.md5, "pos": "0",
"size": self.chunk.size,
"url": self.chunk_url}
chunk_meta = {'content_size': self.content.size,
'content_chunksnb': self.content.nb_chunks,
'content_path': self.content.path,
'content_cid': self.content.id_container,
'content_id': '0000',
'content_version': 1,
'chunk_id': self.chunk.id_chunk,
'chunk_pos': self.chunk.pos}
self.blob_c.chunk_put(self.chunk_url, chunk_meta, self.data)
self.chunk_path = self.test_dir + '/data/NS-rawx-1/' +\
self.chunk.id_chunk[0:2] + "/" + self.chunk.id_chunk
self.bad_container_id = '0'*64
def tearDown(self):
super(TestBlobAuditorFunctional, self).tearDown()
try:
self.container_c.content_delete(
self.account, self.ref, self.content.path)
except Exception:
pass
try:
self.container_c.container_destroy(self.account, self.ref)
except Exception:
pass
try:
os.remove(self.chunk_path)
except Exception:
pass
def init_content(self):
self.container_c.content_create(
self.account, self.ref, self.content.path, self.chunk.size,
self.hash_rand, data=[self.chunk_proxy])
def test_chunk_audit(self):
self.init_content()
self.auditor.chunk_audit(self.chunk_path)
def test_content_deleted(self):
self.assertRaises(exc.OrphanChunk, self.auditor.chunk_audit,
self.chunk_path)
def test_container_deleted(self):
self.container_c.container_destroy(self.account, self.ref)
self.assertRaises(exc.OrphanChunk, self.auditor.chunk_audit,
self.chunk_path)
def test_chunk_corrupted(self):
self.init_content()
with open(self.chunk_path, "w") as f:
f.write(rand_generator(self.chars, 1280))
#.........这里部分代码省略.........
示例3: TestBlobAuditorFunctional
# 需要导入模块: from oio.container.client import ContainerClient [as 别名]
# 或者: from oio.container.client.ContainerClient import container_destroy [as 别名]
class TestBlobAuditorFunctional(BaseTestCase):
def setUp(self):
super(TestBlobAuditorFunctional, self).setUp()
self.namespace = self.conf["namespace"]
self.account = self.conf["account"]
self.test_dir = self.conf["sds_path"]
rawx_num, rawx_path, rawx_addr = self.get_service_url("rawx")
self.rawx = "http://" + rawx_addr
self.h = hashlib.new("md5")
conf = {"namespace": self.namespace}
self.auditor = BlobAuditorWorker(conf, get_logger(None), None)
self.container_c = ContainerClient(conf)
self.blob_c = BlobClient()
self.ref = random_str(8)
self.container_c.container_create(self.account, self.ref)
self.url_rand = random_id(64)
self.data = random_str(1280)
self.h.update(self.data)
self.hash_rand = self.h.hexdigest().lower()
self.content = TestContent(random_str(6), len(self.data), self.url_rand, 1)
self.content.id_container = cid_from_name(self.account, self.ref).upper()
self.chunk = TestChunk(self.content.size, self.url_rand, 0, self.hash_rand)
self.chunk_url = "%s/%s" % (self.rawx, self.chunk.id_chunk)
self.chunk_proxy = {"hash": self.chunk.md5, "pos": "0", "size": self.chunk.size, "url": self.chunk_url}
chunk_meta = {
"content_path": self.content.path,
"container_id": self.content.id_container,
"chunk_method": "plain/nb_copy=3",
"policy": "TESTPOLICY",
"id": "0000",
"version": 1,
"chunk_id": self.chunk.id_chunk,
"chunk_pos": self.chunk.pos,
"chunk_hash": self.chunk.md5,
}
self.blob_c.chunk_put(self.chunk_url, chunk_meta, self.data)
self.chunk_path = (
self.test_dir
+ "/data/"
+ self.namespace
+ "-rawx-1/"
+ self.chunk.id_chunk[0:3]
+ "/"
+ self.chunk.id_chunk
)
self.bad_container_id = "0" * 64
def tearDown(self):
super(TestBlobAuditorFunctional, self).tearDown()
try:
self.container_c.content_delete(self.account, self.ref, self.content.path)
except Exception:
pass
try:
self.container_c.container_destroy(self.account, self.ref)
except Exception:
pass
try:
os.remove(self.chunk_path)
except Exception:
pass
def init_content(self):
self.container_c.content_create(
self.account, self.ref, self.content.path, self.chunk.size, self.hash_rand, data=[self.chunk_proxy]
)
def test_chunk_audit(self):
self.init_content()
self.auditor.chunk_audit(self.chunk_path)
def test_content_deleted(self):
self.assertRaises(exc.OrphanChunk, self.auditor.chunk_audit, self.chunk_path)
def test_container_deleted(self):
self.container_c.container_destroy(self.account, self.ref)
self.assertRaises(exc.OrphanChunk, self.auditor.chunk_audit, self.chunk_path)
def test_chunk_corrupted(self):
self.init_content()
with open(self.chunk_path, "w") as f:
f.write(random_str(1280))
#.........这里部分代码省略.........