1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """Block Storage API Test (Volume Types/QoS)"""
18
19
20 from yakumo.smoketest import *
21 from yakumo import utils
22
23
25
26
27
28 LOG.info("Create QoS #1")
29 name = get_random_str('qos')
30 with c.volume_type_qos.create(name=name,
31 availability="100",
32 numberOfFailures="0") as q1:
33
34 LOG.debug("QoS #1: %s", q1.get_attrs())
35 test("QoS #1 is created", q1 is not None)
36 test("QoS #1 name is " + name, q1.name == name)
37 test("Metadata: availability -> 100", q1.availability == "100")
38 test("Metadata: numberOfFailures -> 0", q1.numberOfFailures == "0")
39
40 q1.set_metadata(foo="bar", foo2="bar2")
41 LOG.debug("QoS #1: %s", q1.get_attrs())
42 test("Metadata: availability -> 100", q1.availability == "100")
43 test("Metadata: numberOfFailures -> 0", q1.numberOfFailures == "0")
44 test("Metadata: foo -> 'bar'", q1.foo == "bar")
45 test("Metadata: foo2 -> 'bar2'", q1.foo2 == "bar2")
46
47 q1.unset_metadata('availability', 'numberOfFailures')
48 LOG.debug("QoS #1: %s", q1.get_attrs())
49 test("Metadata: availability is None", q1.availability is None)
50 test("Metadata: numberOfFailures is None", q1.numberOfFailures is None)
51 test("Metadata: foo -> 'bar'", q1.foo == "bar")
52 test("Metadata: foo2 -> 'bar2'", q1.foo2 == "bar2")
53
54 LOG.info("Create Volume Type #1")
55 name = get_random_str('volume')
56 with c.volume_type.create(name=name,
57 description='volume type 1',
58 is_public=False) as vt1:
59
60 test("Volume Type #1 is created", vt1 is not None)
61 test("Volume Type #1 name is " + name, vt1.name == name)
62
63 LOG.info("Create Volume Type #2")
64 name = get_random_str('volume')
65 with c.volume_type.create(name=name,
66 description='volume type 2',
67 is_public=False) as vt2:
68
69 test("Volume Type #2 is created", vt2 is not None)
70 test("Volume Type #2 name is " + name, vt2.name == name)
71
72 LOG.debug("Volume Type #1: associate with QoS #1")
73 q1.associate(vt1)
74 a1 = q1.get_associations()
75 LOG.debug("QoS #1 associations: %s", a1)
76 test("Volume Type #1: associated with QoS #1", vt1 in a1)
77
78 LOG.debug("Volume Type #2: associate with QoS #1")
79 q1.associate(vt2)
80 a1 = q1.get_associations()
81 LOG.debug("QoS #1 associations: %s", a1)
82 test("Volume Type #2: associated with QoS #1", vt2 in a1)
83
84 LOG.debug("Volume Type #1: disassociate from QoS #1")
85 q1.disassociate(vt1)
86 a1 = q1.get_associations()
87 LOG.debug("QoS #1 associations: %s", a1)
88 test("Volume Type #1: not associated with QoS #1",
89 vt1 not in a1)
90
91 LOG.debug("Volume Type #2: disassociate from QoS #1")
92 q1.disassociate(vt2)
93 a1 = q1.get_associations()
94 LOG.debug("QoS #1 associations: %s", a1)
95 test("Volume Type #2: not associated with QoS #1",
96 vt2 not in a1)
97
98 LOG.debug("Volume Type #1, #2: associate with QoS #1")
99 q1.associate(vt1, vt2)
100 a1 = q1.get_associations()
101 LOG.debug("QoS #1 associations: %s", a1)
102 test("Volume Type #1: associated with QoS #1", vt1 in a1)
103 test("Volume Type #2: associated with QoS #1", vt2 in a1)
104
105 LOG.debug("All Volume Type: disassociate from QoS #1")
106 q1.disassociate_all()
107 a1 = q1.get_associations()
108 LOG.debug("QoS #1 associations: %s", a1)
109 test("No volume type associated with QoS #1", a1 == [])
110
111 test("Volume Type #2 is deleted", vt1 not in c.volume.list())
112
113 test("Volume Type #1 is deleted", vt1 not in c.volume.list())
114
115 test("QoS #1 is deleted", q1 not in c.volume.list())
116
117
118 if __name__ == '__main__':
119 c = utils.get_client()
120
121 LOG.debug("list volume types: %s", [_.name for _ in c.volume_type.list()])
122 LOG.debug("list volumes: %s", [_.name for _ in c.volume.list()])
123 LOG.debug("list QoS: %s", [_.name for _ in c.volume_type_qos.list()])
124 main(c)
125 LOG.debug("list volume types: %s", [_.name for _ in c.volume_type.list()])
126 LOG.debug("list volumes: %s", [_.name for _ in c.volume.list()])
127 LOG.debug("list QoS: %s", [_.name for _ in c.volume_type_qos.list()])
128
129 show_test_summary()
130