1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """Container API Test (Container Metadata)"""
18
19
20 import sys
21
22 from yakumo.smoketest import *
23 from yakumo import utils
24
25
26 QUOTA_BYTES = 10 * 1024 ** 3
27 QUOTA_COUNT = 10
28
29
31 if not c._session.has_endpoint('object-store'):
32 return
33
34 LOG.info("Create an container")
35
36 name = get_random_str('container')
37 metadata = {'foo': 'bar', 'foo2': 'bar2'}
38 with c.container.create(name=name,
39 quota_bytes=QUOTA_BYTES,
40 quota_count=QUOTA_COUNT,
41 metadata=metadata) as co:
42
43 test("Container #1: name is " + name, co.name == name)
44 test("Container #1: quota bytes is %s" % QUOTA_BYTES,
45 co.quota_bytes == QUOTA_BYTES)
46 test("Container #1: quota count is %s" % QUOTA_COUNT,
47 co.quota_count == QUOTA_COUNT)
48
49 LOG.info("Double quotas")
50 co.update(quota_bytes=(QUOTA_BYTES * 2), quota_count=(QUOTA_COUNT * 2))
51 test("Container #1: quota bytes is %s" % (QUOTA_BYTES * 2),
52 co.quota_bytes == QUOTA_BYTES * 2)
53 test("Container #1: quota count is %s" % (QUOTA_COUNT * 2),
54 co.quota_count == QUOTA_COUNT * 2)
55
56 LOG.info("Update metadata")
57 LOG.debug("Initial metadata: %s", co.metadata)
58 test("Metadata has %s" % metadata, co.metadata == metadata)
59
60 m = {'foo2': 'bar4', 'foo3': 'bar3'}
61 LOG.debug("Set metadata : %s", m)
62 metadata.update(m)
63 co.set_metadata(**m)
64 LOG.debug("Updated metadata: %s", co.metadata)
65 test("Metadata has %s" % metadata, co.metadata == metadata)
66
67 m = ['foo', 'foo2']
68 LOG.debug("Unset metadata : %s", m)
69 for key in m:
70 metadata.pop(key)
71 co.unset_metadata(*m)
72 LOG.debug("Updated metadata: %s", co.metadata)
73 test("Metadata has %s" % metadata, co.metadata == metadata)
74
75
76 if __name__ == '__main__':
77 c = utils.get_client()
78 if not c._session.has_endpoint('object-store'):
79 sys.exit(0)
80
81 LOG.debug("list containers: %s", [_.name for _ in c.container.list()])
82 main(c)
83 LOG.debug("list containers: %s", [_.name for _ in c.container.list()])
84
85 show_test_summary()
86