root / kamaki / clients / compute / test.py @ b773795c
History | View | Annotate | Download (31.5 kB)
1 | 304a92dc | Stavros Sachtouris | # Copyright 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 304a92dc | Stavros Sachtouris | #
|
3 | 304a92dc | Stavros Sachtouris | # Redistribution and use in source and binary forms, with or
|
4 | 304a92dc | Stavros Sachtouris | # without modification, are permitted provided that the following
|
5 | 304a92dc | Stavros Sachtouris | # conditions are met:
|
6 | 304a92dc | Stavros Sachtouris | #
|
7 | 304a92dc | Stavros Sachtouris | # 1. Redistributions of source code must retain the above
|
8 | 304a92dc | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
9 | 304a92dc | Stavros Sachtouris | # disclaimer.
|
10 | 304a92dc | Stavros Sachtouris | #
|
11 | 304a92dc | Stavros Sachtouris | # 2. Redistributions in binary form must reproduce the above
|
12 | 304a92dc | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
13 | 304a92dc | Stavros Sachtouris | # disclaimer in the documentation and/or other materials
|
14 | 304a92dc | Stavros Sachtouris | # provided with the distribution.
|
15 | 304a92dc | Stavros Sachtouris | #
|
16 | 304a92dc | Stavros Sachtouris | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 304a92dc | Stavros Sachtouris | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 304a92dc | Stavros Sachtouris | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 304a92dc | Stavros Sachtouris | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 304a92dc | Stavros Sachtouris | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 304a92dc | Stavros Sachtouris | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 304a92dc | Stavros Sachtouris | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 304a92dc | Stavros Sachtouris | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 304a92dc | Stavros Sachtouris | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 304a92dc | Stavros Sachtouris | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 304a92dc | Stavros Sachtouris | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 304a92dc | Stavros Sachtouris | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 304a92dc | Stavros Sachtouris | #
|
29 | 304a92dc | Stavros Sachtouris | # The views and conclusions contained in the software and
|
30 | 304a92dc | Stavros Sachtouris | # documentation are those of the authors and should not be
|
31 | 304a92dc | Stavros Sachtouris | # interpreted as representing official policies, either expressed
|
32 | 304a92dc | Stavros Sachtouris | # or implied, of GRNET S.A.
|
33 | 304a92dc | Stavros Sachtouris | |
34 | 0482817c | Stavros Sachtouris | from mock import patch, call |
35 | 304a92dc | Stavros Sachtouris | from unittest import TestCase |
36 | 630dea9b | Stavros Sachtouris | from itertools import product |
37 | 6695edc9 | Stavros Sachtouris | from json import dumps |
38 | 5ed87051 | Stavros Sachtouris | from sys import stdout |
39 | 4a88f05b | Stavros Sachtouris | import json |
40 | 304a92dc | Stavros Sachtouris | |
41 | 3c50df2e | Stavros Sachtouris | from kamaki.clients import ClientError, compute |
42 | 304a92dc | Stavros Sachtouris | |
43 | edf8ad52 | Stavros Sachtouris | |
44 | 55faa0bc | Stavros Sachtouris | rest_pkg = 'kamaki.clients.compute.rest_api.ComputeRestClient'
|
45 | 630dea9b | Stavros Sachtouris | compute_pkg = 'kamaki.clients.compute.ComputeClient'
|
46 | edf8ad52 | Stavros Sachtouris | |
47 | 304a92dc | Stavros Sachtouris | img_ref = "1m4g3-r3f3r3nc3"
|
48 | 304a92dc | Stavros Sachtouris | vm_name = "my new VM"
|
49 | 304a92dc | Stavros Sachtouris | fid = 42
|
50 | 304a92dc | Stavros Sachtouris | vm_send = dict(server=dict( |
51 | 304a92dc | Stavros Sachtouris | flavorRef=fid, |
52 | 304a92dc | Stavros Sachtouris | name=vm_name, |
53 | 304a92dc | Stavros Sachtouris | imageRef=img_ref, |
54 | 304a92dc | Stavros Sachtouris | metadata=dict(os="debian", users="root"))) |
55 | 304a92dc | Stavros Sachtouris | vm_recv = dict(server=dict( |
56 | 304a92dc | Stavros Sachtouris | status="BUILD",
|
57 | 304a92dc | Stavros Sachtouris | updated="2013-03-01T10:04:00.637152+00:00",
|
58 | 304a92dc | Stavros Sachtouris | hostId="",
|
59 | 304a92dc | Stavros Sachtouris | name=vm_name, |
60 | 304a92dc | Stavros Sachtouris | imageRef=img_ref, |
61 | 304a92dc | Stavros Sachtouris | created="2013-03-01T10:04:00.087324+00:00",
|
62 | 304a92dc | Stavros Sachtouris | flavorRef=fid, |
63 | 304a92dc | Stavros Sachtouris | adminPass="n0n3sh@11p@55",
|
64 | 304a92dc | Stavros Sachtouris | suspended=False,
|
65 | 304a92dc | Stavros Sachtouris | progress=0,
|
66 | 304a92dc | Stavros Sachtouris | id=31173,
|
67 | bcef3ac9 | Stavros Sachtouris | metadata=dict(os="debian", users="root"))) |
68 | 304a92dc | Stavros Sachtouris | img_recv = dict(image=dict( |
69 | 304a92dc | Stavros Sachtouris | status="ACTIVE",
|
70 | 304a92dc | Stavros Sachtouris | updated="2013-02-26T11:10:14+00:00",
|
71 | 304a92dc | Stavros Sachtouris | name="Debian Base",
|
72 | 304a92dc | Stavros Sachtouris | created="2013-02-26T11:03:29+00:00",
|
73 | 304a92dc | Stavros Sachtouris | progress=100,
|
74 | 304a92dc | Stavros Sachtouris | id=img_ref, |
75 | bcef3ac9 | Stavros Sachtouris | metadata=dict(
|
76 | 304a92dc | Stavros Sachtouris | partition_table="msdos",
|
77 | 304a92dc | Stavros Sachtouris | kernel="2.6.32",
|
78 | 304a92dc | Stavros Sachtouris | osfamily="linux",
|
79 | 304a92dc | Stavros Sachtouris | users="root",
|
80 | 304a92dc | Stavros Sachtouris | gui="No GUI",
|
81 | 304a92dc | Stavros Sachtouris | sortorder="1",
|
82 | 304a92dc | Stavros Sachtouris | os="debian",
|
83 | 304a92dc | Stavros Sachtouris | root_partition="1",
|
84 | bcef3ac9 | Stavros Sachtouris | description="Debian 6.0.7 (Squeeze) Base System")))
|
85 | bcef3ac9 | Stavros Sachtouris | vm_list = dict(servers=[
|
86 | 304a92dc | Stavros Sachtouris | dict(name='n1', id=1), |
87 | bcef3ac9 | Stavros Sachtouris | dict(name='n2', id=2)]) |
88 | bcef3ac9 | Stavros Sachtouris | flavor_list = dict(flavors=[
|
89 | 0482817c | Stavros Sachtouris | dict(id=41, name="C1R1024D20"), |
90 | 0482817c | Stavros Sachtouris | dict(id=42, name="C1R1024D40"), |
91 | bcef3ac9 | Stavros Sachtouris | dict(id=43, name="C1R1028D20")]) |
92 | bcef3ac9 | Stavros Sachtouris | img_list = dict(images=[
|
93 | 304a92dc | Stavros Sachtouris | dict(name="maelstrom", id="0fb03e45-7d5a-4515-bd4e-e6bbf6457f06"), |
94 | 304a92dc | Stavros Sachtouris | dict(name="edx_saas", id="1357163d-5fd8-488e-a117-48734c526206"), |
95 | 304a92dc | Stavros Sachtouris | dict(name="Debian_Wheezy_Base", id="1f8454f0-8e3e-4b6c-ab8e-5236b728dffe"), |
96 | 304a92dc | Stavros Sachtouris | dict(name="CentOS", id="21894b48-c805-4568-ac8b-7d4bb8eb533d"), |
97 | 304a92dc | Stavros Sachtouris | dict(name="Ubuntu Desktop", id="37bc522c-c479-4085-bfb9-464f9b9e2e31"), |
98 | 304a92dc | Stavros Sachtouris | dict(name="Ubuntu 12.10", id="3a24fef9-1a8c-47d1-8f11-e07bd5e544fd"), |
99 | 304a92dc | Stavros Sachtouris | dict(name="Debian Base", id="40ace203-6254-4e17-a5cb-518d55418a7d"), |
100 | bcef3ac9 | Stavros Sachtouris | dict(name="ubuntu_bundled", id="5336e265-5c7c-4127-95cb-2bf832a79903")]) |
101 | 304a92dc | Stavros Sachtouris | |
102 | 304a92dc | Stavros Sachtouris | |
103 | 304a92dc | Stavros Sachtouris | class FR(object): |
104 | 304a92dc | Stavros Sachtouris | """FR stands for Fake Response"""
|
105 | 304a92dc | Stavros Sachtouris | json = vm_recv |
106 | 304a92dc | Stavros Sachtouris | headers = {} |
107 | 304a92dc | Stavros Sachtouris | content = json |
108 | 304a92dc | Stavros Sachtouris | status = None
|
109 | 304a92dc | Stavros Sachtouris | status_code = 200
|
110 | 304a92dc | Stavros Sachtouris | |
111 | 304a92dc | Stavros Sachtouris | |
112 | 99e4d887 | Stavros Sachtouris | def print_iterations(old, new): |
113 | 99e4d887 | Stavros Sachtouris | if new:
|
114 | 99e4d887 | Stavros Sachtouris | if new % 1000: |
115 | 99e4d887 | Stavros Sachtouris | return old
|
116 | 99e4d887 | Stavros Sachtouris | stdout.write('\b' * len('%s' % old)) |
117 | 99e4d887 | Stavros Sachtouris | stdout.write('%s' % new)
|
118 | 99e4d887 | Stavros Sachtouris | else:
|
119 | 99e4d887 | Stavros Sachtouris | stdout.write('# of loops: ')
|
120 | 99e4d887 | Stavros Sachtouris | stdout.flush() |
121 | 99e4d887 | Stavros Sachtouris | return new
|
122 | 99e4d887 | Stavros Sachtouris | |
123 | 99e4d887 | Stavros Sachtouris | |
124 | 3c50df2e | Stavros Sachtouris | class ComputeRestClient(TestCase): |
125 | 630dea9b | Stavros Sachtouris | |
126 | 55faa0bc | Stavros Sachtouris | """Set up a ComputesRest thorough test"""
|
127 | 630dea9b | Stavros Sachtouris | def setUp(self): |
128 | 630dea9b | Stavros Sachtouris | self.url = 'http://cyclades.example.com' |
129 | 630dea9b | Stavros Sachtouris | self.token = 'cyc14d3s70k3n' |
130 | 3c50df2e | Stavros Sachtouris | self.client = compute.ComputeRestClient(self.url, self.token) |
131 | 630dea9b | Stavros Sachtouris | |
132 | 630dea9b | Stavros Sachtouris | def tearDown(self): |
133 | 630dea9b | Stavros Sachtouris | FR.json = vm_recv |
134 | 630dea9b | Stavros Sachtouris | |
135 | 5ed87051 | Stavros Sachtouris | @patch('%s.set_param' % rest_pkg) |
136 | 5ed87051 | Stavros Sachtouris | @patch('%s.get' % rest_pkg, return_value=FR()) |
137 | 5ed87051 | Stavros Sachtouris | def _test_get(self, service, params, get, set_param): |
138 | d08962f0 | Stavros Sachtouris | method = getattr(self.client, '%s_get' % service) |
139 | 5ed87051 | Stavros Sachtouris | param_args = [({}, {k: k}, {k: v[1]}) for k, v in params.items()] |
140 | 99e4d887 | Stavros Sachtouris | num_of_its = 0
|
141 | 5ed87051 | Stavros Sachtouris | for i, args in enumerate(product( |
142 | f3cb8dad | Stavros Sachtouris | ('', '%s_id' % service), |
143 | 5ed87051 | Stavros Sachtouris | (None, False, True), |
144 | 630dea9b | Stavros Sachtouris | (200, 204), |
145 | 5ed87051 | Stavros Sachtouris | ({}, {'k': 'v'}), |
146 | 5ed87051 | Stavros Sachtouris | *param_args)): |
147 | 5ed87051 | Stavros Sachtouris | (srv_id, detail, success, kwargs) = args[:4]
|
148 | 5ed87051 | Stavros Sachtouris | kwargs['success'] = success
|
149 | 5ed87051 | Stavros Sachtouris | srv_kwargs = dict()
|
150 | 5ed87051 | Stavros Sachtouris | for param in args[4:]: |
151 | 5ed87051 | Stavros Sachtouris | srv_kwargs.update(param) |
152 | 5ed87051 | Stavros Sachtouris | srv_kwargs.update(kwargs) |
153 | 5ed87051 | Stavros Sachtouris | method(*args[:2], **srv_kwargs)
|
154 | 5ed87051 | Stavros Sachtouris | srv_str = '/detail' if detail else ( |
155 | 5ed87051 | Stavros Sachtouris | '/%s' % srv_id) if srv_id else '' |
156 | 5ed87051 | Stavros Sachtouris | self.assertEqual(
|
157 | 5ed87051 | Stavros Sachtouris | get.mock_calls[-1],
|
158 | 5ed87051 | Stavros Sachtouris | call('/%s%s' % (service, srv_str), **kwargs))
|
159 | 5ed87051 | Stavros Sachtouris | param_calls = [] |
160 | 5ed87051 | Stavros Sachtouris | for k, v in params.items(): |
161 | 5ed87051 | Stavros Sachtouris | real_v = srv_kwargs.get(k, v[1]) if not srv_id else v[1] |
162 | 5ed87051 | Stavros Sachtouris | param_calls.append(call(v[0], real_v, iff=real_v))
|
163 | 5ed87051 | Stavros Sachtouris | actual = set_param.mock_calls[- len(param_calls):]
|
164 | 5ed87051 | Stavros Sachtouris | self.assertEqual(sorted(actual), sorted(param_calls)) |
165 | 5ed87051 | Stavros Sachtouris | |
166 | 99e4d887 | Stavros Sachtouris | num_of_its = print_iterations(num_of_its, i) |
167 | 99e4d887 | Stavros Sachtouris | print ('\b' * len('%s' % num_of_its)) + ('%s' % i) |
168 | 630dea9b | Stavros Sachtouris | |
169 | d08962f0 | Stavros Sachtouris | @patch('%s.set_param' % rest_pkg) |
170 | d08962f0 | Stavros Sachtouris | @patch('%s.get' % rest_pkg, return_value=FR()) |
171 | d08962f0 | Stavros Sachtouris | def _test_srv_cmd_get(self, srv, cmd, params, get, set_param): |
172 | d08962f0 | Stavros Sachtouris | method = getattr(self.client, '%s_%s_get' % (srv, cmd)) |
173 | d08962f0 | Stavros Sachtouris | param_args = [({}, {k: k}, {k: v[1]}) for k, v in params.items()] |
174 | 99e4d887 | Stavros Sachtouris | num_of_its = 0
|
175 | d08962f0 | Stavros Sachtouris | for i, args in enumerate(product( |
176 | d08962f0 | Stavros Sachtouris | ('some_server_id', 'other_server_id'), |
177 | d08962f0 | Stavros Sachtouris | (None, 'xtra_id'), |
178 | d08962f0 | Stavros Sachtouris | ((304, 200), (1000)), |
179 | d08962f0 | Stavros Sachtouris | ({}, {'k': 'v'}), |
180 | d08962f0 | Stavros Sachtouris | *param_args)): |
181 | d08962f0 | Stavros Sachtouris | srv_id, xtra_id, success, kwargs = args[:4]
|
182 | 4a88f05b | Stavros Sachtouris | kwargs = dict(kwargs)
|
183 | d08962f0 | Stavros Sachtouris | kwargs['success'] = success
|
184 | d08962f0 | Stavros Sachtouris | srv_kwargs = dict()
|
185 | d08962f0 | Stavros Sachtouris | for param in args[4:]: |
186 | d08962f0 | Stavros Sachtouris | srv_kwargs.update(param) |
187 | d08962f0 | Stavros Sachtouris | srv_kwargs.update(kwargs) |
188 | d08962f0 | Stavros Sachtouris | method(*args[:2], **srv_kwargs)
|
189 | d08962f0 | Stavros Sachtouris | srv_str = '/%s/%s/%s' % (srv, srv_id, cmd)
|
190 | d08962f0 | Stavros Sachtouris | srv_str += ('/%s' % xtra_id) if xtra_id else '' |
191 | d08962f0 | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call(srv_str, **kwargs)) |
192 | d08962f0 | Stavros Sachtouris | param_calls = [] |
193 | d08962f0 | Stavros Sachtouris | for k, v in params.items(): |
194 | d08962f0 | Stavros Sachtouris | real_v = srv_kwargs.get(k, v[1])
|
195 | d08962f0 | Stavros Sachtouris | param_calls.append(call(v[0], real_v, iff=real_v))
|
196 | d08962f0 | Stavros Sachtouris | actual = set_param.mock_calls[- len(param_calls):]
|
197 | d08962f0 | Stavros Sachtouris | self.assertEqual(sorted(actual), sorted(param_calls)) |
198 | d08962f0 | Stavros Sachtouris | |
199 | 99e4d887 | Stavros Sachtouris | num_of_its = print_iterations(num_of_its, i) |
200 | 99e4d887 | Stavros Sachtouris | print ('\b' * len('%s' % num_of_its)) + ('%s' % i) |
201 | 99e4d887 | Stavros Sachtouris | |
202 | 4a88f05b | Stavros Sachtouris | @patch('%s.set_header' % rest_pkg) |
203 | 4a88f05b | Stavros Sachtouris | @patch('%s.set_param' % rest_pkg) |
204 | 4a88f05b | Stavros Sachtouris | @patch('%s.post' % rest_pkg, return_value=FR()) |
205 | 4a88f05b | Stavros Sachtouris | def _test_post(self, srv, cmd, params, post, set_param, set_header): |
206 | 4a88f05b | Stavros Sachtouris | method = getattr(
|
207 | 4a88f05b | Stavros Sachtouris | self.client, '%s_%spost' % (srv, ('%s_' % cmd) if cmd else '')) |
208 | 4a88f05b | Stavros Sachtouris | param_args = [({}, {k: k}, {k: v[1]}) for k, v in params.items()] |
209 | 4a88f05b | Stavros Sachtouris | num_of_its = 0
|
210 | 4a88f05b | Stavros Sachtouris | for i, args in enumerate(product( |
211 | 4a88f05b | Stavros Sachtouris | ('%s_id' % srv, 'some_value'), |
212 | 4a88f05b | Stavros Sachtouris | ( |
213 | 4a88f05b | Stavros Sachtouris | None,
|
214 | 4a88f05b | Stavros Sachtouris | {'some': {'data': 'in json'}}, |
215 | 4a88f05b | Stavros Sachtouris | ['k1', {'k2': 'v2', 'k3': 'v3'}, 'k4']), |
216 | 4a88f05b | Stavros Sachtouris | (202, 1453), |
217 | 4a88f05b | Stavros Sachtouris | ({}, {'k': 'v'}), |
218 | 4a88f05b | Stavros Sachtouris | *param_args)): |
219 | 4a88f05b | Stavros Sachtouris | srv_id, json_data, success, kwargs = args[:4]
|
220 | 4a88f05b | Stavros Sachtouris | kwargs = dict(kwargs)
|
221 | 4a88f05b | Stavros Sachtouris | cmd_args = (srv_id, ) if cmd else () |
222 | 4a88f05b | Stavros Sachtouris | kwargs['success'] = success
|
223 | 4a88f05b | Stavros Sachtouris | srv_kwargs = dict()
|
224 | 4a88f05b | Stavros Sachtouris | for param in args[4:]: |
225 | 4a88f05b | Stavros Sachtouris | srv_kwargs.update(param) |
226 | 4a88f05b | Stavros Sachtouris | srv_kwargs.update(kwargs) |
227 | 4a88f05b | Stavros Sachtouris | srv_kwargs['json_data'] = json_data
|
228 | 4a88f05b | Stavros Sachtouris | method(*cmd_args, **srv_kwargs) |
229 | 4a88f05b | Stavros Sachtouris | srv_str = '/%s%s' % (
|
230 | 4a88f05b | Stavros Sachtouris | srv, (('/%s/%s' % (srv_id, cmd)) if cmd else '')) |
231 | 4a88f05b | Stavros Sachtouris | kwargs['data'] = json.dumps(json_data) if json_data else None |
232 | 4a88f05b | Stavros Sachtouris | self.assertEqual(post.mock_calls[-1], call(srv_str, **kwargs)) |
233 | 4a88f05b | Stavros Sachtouris | |
234 | 4a88f05b | Stavros Sachtouris | param_calls = [] |
235 | 4a88f05b | Stavros Sachtouris | for k, v in params.items(): |
236 | 4a88f05b | Stavros Sachtouris | real_v = srv_kwargs.get(k, v[1])
|
237 | 4a88f05b | Stavros Sachtouris | param_calls.append(call(v[0], real_v, iff=real_v))
|
238 | 4a88f05b | Stavros Sachtouris | actual = set_param.mock_calls[- len(param_calls):]
|
239 | 4a88f05b | Stavros Sachtouris | self.assertEqual(sorted(actual), sorted(param_calls)) |
240 | 4a88f05b | Stavros Sachtouris | |
241 | 4a88f05b | Stavros Sachtouris | if json_data:
|
242 | 4a88f05b | Stavros Sachtouris | self.assertEqual(set_header.mock_calls[-2:], [ |
243 | 4a88f05b | Stavros Sachtouris | call('Content-Type', 'application/json'), |
244 | 4a88f05b | Stavros Sachtouris | call('Content-Length', len(kwargs['data']))]) |
245 | 4a88f05b | Stavros Sachtouris | |
246 | 4a88f05b | Stavros Sachtouris | num_of_its = print_iterations(num_of_its, i) |
247 | 4a88f05b | Stavros Sachtouris | print ('\b' * len('%s' % num_of_its)) + ('%s' % i) |
248 | 4a88f05b | Stavros Sachtouris | |
249 | 4a88f05b | Stavros Sachtouris | @patch('%s.set_header' % rest_pkg) |
250 | 4a88f05b | Stavros Sachtouris | @patch('%s.set_param' % rest_pkg) |
251 | 4a88f05b | Stavros Sachtouris | @patch('%s.put' % rest_pkg, return_value=FR()) |
252 | 4a88f05b | Stavros Sachtouris | def _test_put(self, srv, cmd, params, put, set_param, set_headers): |
253 | 4a88f05b | Stavros Sachtouris | method = getattr(self.client, '%s_%sput' % ( |
254 | 4a88f05b | Stavros Sachtouris | srv, ('%s_' % cmd) if cmd else '')) |
255 | 4a88f05b | Stavros Sachtouris | param_args = [({}, {k: k}, {k: v[1]}) for k, v in params.items()] |
256 | 4a88f05b | Stavros Sachtouris | num_of_its = 0
|
257 | 4a88f05b | Stavros Sachtouris | for i, args in enumerate(product( |
258 | 4a88f05b | Stavros Sachtouris | ('some_value', '%s_id' % srv), |
259 | 4a88f05b | Stavros Sachtouris | (None, [dict(json="data"), dict(data="json")]), |
260 | 4a88f05b | Stavros Sachtouris | (204, 504), |
261 | 4a88f05b | Stavros Sachtouris | ({}, {'k': 'v'}), |
262 | 4a88f05b | Stavros Sachtouris | *param_args)): |
263 | 4a88f05b | Stavros Sachtouris | srv_id, json_data, success, kwargs = args[:4]
|
264 | 4a88f05b | Stavros Sachtouris | kwargs = dict(kwargs)
|
265 | 4a88f05b | Stavros Sachtouris | kwargs['success'] = success
|
266 | 4a88f05b | Stavros Sachtouris | srv_kwargs = dict()
|
267 | 4a88f05b | Stavros Sachtouris | for param in args[4:]: |
268 | 4a88f05b | Stavros Sachtouris | srv_kwargs.update(param) |
269 | 4a88f05b | Stavros Sachtouris | srv_kwargs.update(kwargs) |
270 | 4a88f05b | Stavros Sachtouris | srv_kwargs['json_data'] = json_data
|
271 | 4a88f05b | Stavros Sachtouris | method(srv_id, **srv_kwargs) |
272 | 4a88f05b | Stavros Sachtouris | srv_str = '/%s/%s%s' % (srv, srv_id, ('/%s' % cmd if cmd else '')) |
273 | 4a88f05b | Stavros Sachtouris | |
274 | 4a88f05b | Stavros Sachtouris | if json_data:
|
275 | 4a88f05b | Stavros Sachtouris | json_data = dumps(json_data) |
276 | 4a88f05b | Stavros Sachtouris | self.assertEqual(set_headers.mock_calls[-2:], [ |
277 | 4a88f05b | Stavros Sachtouris | call('Content-Type', 'application/json'), |
278 | 4a88f05b | Stavros Sachtouris | call('Content-Length', len(json_data))]) |
279 | 4a88f05b | Stavros Sachtouris | self.assertEqual(
|
280 | 4a88f05b | Stavros Sachtouris | put.mock_calls[-1],
|
281 | 4a88f05b | Stavros Sachtouris | call(srv_str, data=json_data, **kwargs)) |
282 | 4a88f05b | Stavros Sachtouris | |
283 | 4a88f05b | Stavros Sachtouris | param_calls = [] |
284 | 4a88f05b | Stavros Sachtouris | for k, v in params.items(): |
285 | 4a88f05b | Stavros Sachtouris | real_v = srv_kwargs.get(k, v[1])
|
286 | 4a88f05b | Stavros Sachtouris | param_calls.append(call(v[0], real_v, iff=real_v))
|
287 | 4a88f05b | Stavros Sachtouris | actual = set_param.mock_calls[- len(param_calls):]
|
288 | 4a88f05b | Stavros Sachtouris | self.assertEqual(sorted(actual), sorted(param_calls)) |
289 | 4a88f05b | Stavros Sachtouris | |
290 | 4a88f05b | Stavros Sachtouris | num_of_its = print_iterations(num_of_its, i) |
291 | 4a88f05b | Stavros Sachtouris | print ('\b' * len('%s' % num_of_its)) + ('%s' % i) |
292 | 4a88f05b | Stavros Sachtouris | |
293 | 99e4d887 | Stavros Sachtouris | @patch('%s.delete' % rest_pkg, return_value=FR()) |
294 | 99e4d887 | Stavros Sachtouris | def _test_delete(self, srv, cmd, delete): |
295 | 99e4d887 | Stavros Sachtouris | method = getattr(
|
296 | 99e4d887 | Stavros Sachtouris | self.client, '%s_%sdelete' % (srv, ('%s_' % cmd) if cmd else '')) |
297 | 99e4d887 | Stavros Sachtouris | cmd_params = ('some_cmd_value', 'some_other_value') if cmd else () |
298 | 99e4d887 | Stavros Sachtouris | num_of_its = 0
|
299 | 99e4d887 | Stavros Sachtouris | for i, args in enumerate(product( |
300 | 99e4d887 | Stavros Sachtouris | ('%s_id' % srv, 'some_value'), |
301 | 99e4d887 | Stavros Sachtouris | (204, 208), |
302 | 99e4d887 | Stavros Sachtouris | ({}, {'k': 'v'}), |
303 | 99e4d887 | Stavros Sachtouris | *cmd_params)): |
304 | 99e4d887 | Stavros Sachtouris | (srv_id, success, kwargs) = args[:3]
|
305 | 4a88f05b | Stavros Sachtouris | kwargs = dict(kwargs)
|
306 | 99e4d887 | Stavros Sachtouris | kwargs['success'] = success
|
307 | 99e4d887 | Stavros Sachtouris | cmd_value = args[-1] if cmd else '' |
308 | 99e4d887 | Stavros Sachtouris | method_args = (srv_id, cmd_value) if cmd else (srv_id, ) |
309 | 99e4d887 | Stavros Sachtouris | method(*method_args, **kwargs) |
310 | 99e4d887 | Stavros Sachtouris | srv_str = '/%s/%s' % (srv, srv_id)
|
311 | 99e4d887 | Stavros Sachtouris | cmd_str = ('/%s/%s' % (cmd, cmd_value)) if cmd else '' |
312 | 99e4d887 | Stavros Sachtouris | self.assertEqual(
|
313 | 99e4d887 | Stavros Sachtouris | delete.mock_calls[-1],
|
314 | 99e4d887 | Stavros Sachtouris | call('%s%s' % (srv_str, cmd_str), **kwargs))
|
315 | 99e4d887 | Stavros Sachtouris | num_of_its = print_iterations(num_of_its, i) |
316 | 99e4d887 | Stavros Sachtouris | print ('\b' * len('%s' % num_of_its)) + ('%s' % i) |
317 | d08962f0 | Stavros Sachtouris | |
318 | 4a88f05b | Stavros Sachtouris | @patch('%s.get' % rest_pkg, return_value=FR()) |
319 | 4a88f05b | Stavros Sachtouris | def test_limits_get(self, get): |
320 | 4a88f05b | Stavros Sachtouris | self.client.limits_get(success='some_val') |
321 | 4a88f05b | Stavros Sachtouris | get.assert_called_once_with('/limits', success='some_val') |
322 | 4a88f05b | Stavros Sachtouris | |
323 | f3cb8dad | Stavros Sachtouris | def test_servers_get(self): |
324 | 5ed87051 | Stavros Sachtouris | params = dict(
|
325 | 5ed87051 | Stavros Sachtouris | changes_since=('changes-since', None), |
326 | 5ed87051 | Stavros Sachtouris | image=('image', None), |
327 | 5ed87051 | Stavros Sachtouris | flavor=('flavor', None), |
328 | 5ed87051 | Stavros Sachtouris | name=('name', None), |
329 | 5ed87051 | Stavros Sachtouris | marker=('marker', None), |
330 | 5ed87051 | Stavros Sachtouris | limit=('limit', None), |
331 | 5ed87051 | Stavros Sachtouris | status=('status', None), |
332 | 5ed87051 | Stavros Sachtouris | host=('host', None)) |
333 | 5ed87051 | Stavros Sachtouris | self._test_get('servers', params) |
334 | f3cb8dad | Stavros Sachtouris | |
335 | 4a88f05b | Stavros Sachtouris | def test_servers_post(self): |
336 | 4a88f05b | Stavros Sachtouris | params = dict(
|
337 | 4a88f05b | Stavros Sachtouris | security_group=('security_group', None), |
338 | 4a88f05b | Stavros Sachtouris | user_data=('user_data', None), |
339 | 4a88f05b | Stavros Sachtouris | availability_zone=('availability_zone', None)) |
340 | 4a88f05b | Stavros Sachtouris | self._test_post('servers', None, params) |
341 | 4a88f05b | Stavros Sachtouris | |
342 | 4a88f05b | Stavros Sachtouris | def test_servers_put(self): |
343 | 4a88f05b | Stavros Sachtouris | self._test_put('servers', None, dict(server_name=('server', None))) |
344 | 4a88f05b | Stavros Sachtouris | |
345 | 4a88f05b | Stavros Sachtouris | def test_servers_delete(self): |
346 | 4a88f05b | Stavros Sachtouris | self._test_delete('servers', None) |
347 | 4a88f05b | Stavros Sachtouris | |
348 | d08962f0 | Stavros Sachtouris | def test_servers_metadata_get(self): |
349 | d08962f0 | Stavros Sachtouris | self._test_srv_cmd_get('servers', 'metadata', {}) |
350 | d08962f0 | Stavros Sachtouris | |
351 | 4a88f05b | Stavros Sachtouris | def test_servers_metadata_post(self): |
352 | 4a88f05b | Stavros Sachtouris | self._test_post('servers', 'metadata', {}) |
353 | 4a88f05b | Stavros Sachtouris | |
354 | 4a88f05b | Stavros Sachtouris | def test_servers_metadata_put(self): |
355 | 4a88f05b | Stavros Sachtouris | self._test_put('servers', 'metadata', {}) |
356 | 4a88f05b | Stavros Sachtouris | |
357 | 4a88f05b | Stavros Sachtouris | def test_images_metadata_delete(self): |
358 | 4a88f05b | Stavros Sachtouris | self._test_delete('images', 'metadata') |
359 | 4a88f05b | Stavros Sachtouris | |
360 | 4a88f05b | Stavros Sachtouris | def test_servers_action_post(self): |
361 | 4a88f05b | Stavros Sachtouris | self._test_post('servers', 'action', {}) |
362 | 4a88f05b | Stavros Sachtouris | |
363 | d08962f0 | Stavros Sachtouris | def test_servers_ips_get(self): |
364 | d08962f0 | Stavros Sachtouris | params = dict(changes_since=('changes-since', None)) |
365 | d08962f0 | Stavros Sachtouris | self._test_srv_cmd_get('servers', 'ips', params) |
366 | d08962f0 | Stavros Sachtouris | |
367 | f3cb8dad | Stavros Sachtouris | def test_images_get(self): |
368 | 5ed87051 | Stavros Sachtouris | param = dict(
|
369 | 5ed87051 | Stavros Sachtouris | changes_since=('changes-since', None), |
370 | 5ed87051 | Stavros Sachtouris | server_name=('server', None), |
371 | 5ed87051 | Stavros Sachtouris | name=('name', None), |
372 | 5ed87051 | Stavros Sachtouris | status=('status', None), |
373 | 5ed87051 | Stavros Sachtouris | marker=('marker', None), |
374 | 5ed87051 | Stavros Sachtouris | limit=('limit', None), |
375 | 5ed87051 | Stavros Sachtouris | type=('type', None)) |
376 | 5ed87051 | Stavros Sachtouris | self._test_get('images', param) |
377 | f3cb8dad | Stavros Sachtouris | |
378 | f3cb8dad | Stavros Sachtouris | def test_images_delete(self): |
379 | d08962f0 | Stavros Sachtouris | self._test_delete('images', None) |
380 | d08962f0 | Stavros Sachtouris | |
381 | 4a88f05b | Stavros Sachtouris | def test_images_metadata_get(self): |
382 | 4a88f05b | Stavros Sachtouris | self._test_srv_cmd_get('images', 'metadata', {}) |
383 | 882c7e33 | Stavros Sachtouris | |
384 | 4a88f05b | Stavros Sachtouris | def test_images_metadata_post(self): |
385 | 4a88f05b | Stavros Sachtouris | self._test_post('images', 'metadata', {}) |
386 | a8fe029d | Stavros Sachtouris | |
387 | 4a88f05b | Stavros Sachtouris | def test_images_metadata_put(self): |
388 | 4a88f05b | Stavros Sachtouris | self._test_put('images', 'metadata', {}) |
389 | a8fe029d | Stavros Sachtouris | |
390 | 4a88f05b | Stavros Sachtouris | def test_servers_metadata_delete(self): |
391 | 4a88f05b | Stavros Sachtouris | self._test_delete('servers', 'metadata') |
392 | a8fe029d | Stavros Sachtouris | |
393 | 4a88f05b | Stavros Sachtouris | def test_flavors_get(self): |
394 | 4a88f05b | Stavros Sachtouris | params = dict(
|
395 | 4a88f05b | Stavros Sachtouris | changes_since=('changes-since', None), |
396 | 4a88f05b | Stavros Sachtouris | minDisk=('minDisk', None), |
397 | 4a88f05b | Stavros Sachtouris | minRam=('minRam', None), |
398 | 4a88f05b | Stavros Sachtouris | marker=('marker', None), |
399 | 4a88f05b | Stavros Sachtouris | limit=('limit', None)) |
400 | 4a88f05b | Stavros Sachtouris | self._test_get('flavors', params) |
401 | a8fe029d | Stavros Sachtouris | |
402 | 0a62912d | Stavros Sachtouris | @patch('%s.get' % rest_pkg, return_value=FR()) |
403 | 0a62912d | Stavros Sachtouris | def test_floating_ip_pools_get(self, get): |
404 | 0a62912d | Stavros Sachtouris | for args in product( |
405 | 0a62912d | Stavros Sachtouris | (200, 204), |
406 | 0a62912d | Stavros Sachtouris | ({}, {'k': 'v'})): |
407 | 4a88f05b | Stavros Sachtouris | success, kwargs = args |
408 | 4a88f05b | Stavros Sachtouris | r = self.client.floating_ip_pools_get(success, **kwargs)
|
409 | 0a62912d | Stavros Sachtouris | self.assertTrue(isinstance(r, FR)) |
410 | 0a62912d | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call( |
411 | 4a88f05b | Stavros Sachtouris | '/os-floating-ip-pools', success=success, **kwargs))
|
412 | 0a62912d | Stavros Sachtouris | |
413 | 77d1b504 | Stavros Sachtouris | @patch('%s.get' % rest_pkg, return_value=FR()) |
414 | 77d1b504 | Stavros Sachtouris | def test_floating_ips_get(self, get): |
415 | 77d1b504 | Stavros Sachtouris | for args in product( |
416 | 03033b54 | Stavros Sachtouris | ('', '192.193.194.195'), |
417 | 77d1b504 | Stavros Sachtouris | (200, 204), |
418 | 77d1b504 | Stavros Sachtouris | ({}, {'k': 'v'})): |
419 | 4a88f05b | Stavros Sachtouris | ip, success, kwargs = args |
420 | 4a88f05b | Stavros Sachtouris | r = self.client.floating_ips_get(*args[:2], **kwargs) |
421 | 77d1b504 | Stavros Sachtouris | self.assertTrue(isinstance(r, FR)) |
422 | 03033b54 | Stavros Sachtouris | expected = '' if not ip else '/%s' % ip |
423 | 77d1b504 | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call( |
424 | 4a88f05b | Stavros Sachtouris | '/os-floating-ips%s' % expected, success=success, **kwargs))
|
425 | 77d1b504 | Stavros Sachtouris | |
426 | 77d1b504 | Stavros Sachtouris | @patch('%s.set_header' % rest_pkg) |
427 | 77d1b504 | Stavros Sachtouris | @patch('%s.post' % rest_pkg, return_value=FR()) |
428 | 77d1b504 | Stavros Sachtouris | def test_floating_ips_post(self, post, SH): |
429 | 77d1b504 | Stavros Sachtouris | for args in product( |
430 | 77d1b504 | Stavros Sachtouris | (None, [dict(json="data"), dict(data="json")]), |
431 | 03033b54 | Stavros Sachtouris | ('', '192.193.194.195'), |
432 | 77d1b504 | Stavros Sachtouris | (202, 204), |
433 | 77d1b504 | Stavros Sachtouris | ({}, {'k': 'v'})): |
434 | 4a88f05b | Stavros Sachtouris | json_data, ip, success, kwargs = args |
435 | 4a88f05b | Stavros Sachtouris | self.client.floating_ips_post(*args[:3], **kwargs) |
436 | 77d1b504 | Stavros Sachtouris | if json_data:
|
437 | 77d1b504 | Stavros Sachtouris | json_data = dumps(json_data) |
438 | 77d1b504 | Stavros Sachtouris | self.assertEqual(SH.mock_calls[-2:], [ |
439 | 77d1b504 | Stavros Sachtouris | call('Content-Type', 'application/json'), |
440 | 77d1b504 | Stavros Sachtouris | call('Content-Length', len(json_data))]) |
441 | 03033b54 | Stavros Sachtouris | expected = '' if not ip else '/%s' % ip |
442 | 77d1b504 | Stavros Sachtouris | self.assertEqual(post.mock_calls[-1], call( |
443 | 4a88f05b | Stavros Sachtouris | '/os-floating-ips%s' % expected,
|
444 | 77d1b504 | Stavros Sachtouris | data=json_data, success=success, |
445 | 77d1b504 | Stavros Sachtouris | **kwargs)) |
446 | 77d1b504 | Stavros Sachtouris | |
447 | 77d1b504 | Stavros Sachtouris | @patch('%s.delete' % rest_pkg, return_value=FR()) |
448 | 03033b54 | Stavros Sachtouris | def test_floating_ips_delete(self, delete): |
449 | 77d1b504 | Stavros Sachtouris | for args in product( |
450 | 03033b54 | Stavros Sachtouris | ('', '192.193.194.195'), |
451 | 77d1b504 | Stavros Sachtouris | (204,),
|
452 | 77d1b504 | Stavros Sachtouris | ({}, {'k': 'v'})): |
453 | 4a88f05b | Stavros Sachtouris | ip, success, kwargs = args |
454 | 4a88f05b | Stavros Sachtouris | r = self.client.floating_ips_delete(*args[:2], **kwargs) |
455 | 77d1b504 | Stavros Sachtouris | self.assertTrue(isinstance(r, FR)) |
456 | 03033b54 | Stavros Sachtouris | expected = '' if not ip else '/%s' % ip |
457 | 77d1b504 | Stavros Sachtouris | self.assertEqual(delete.mock_calls[-1], call( |
458 | 4a88f05b | Stavros Sachtouris | '/os-floating-ips%s' % expected, success=success, **kwargs))
|
459 | 77d1b504 | Stavros Sachtouris | |
460 | 630dea9b | Stavros Sachtouris | |
461 | 3c50df2e | Stavros Sachtouris | class ComputeClient(TestCase): |
462 | 304a92dc | Stavros Sachtouris | |
463 | 304a92dc | Stavros Sachtouris | def assert_dicts_are_equal(self, d1, d2): |
464 | 304a92dc | Stavros Sachtouris | for k, v in d1.items(): |
465 | 304a92dc | Stavros Sachtouris | self.assertTrue(k in d2) |
466 | 304a92dc | Stavros Sachtouris | if isinstance(v, dict): |
467 | 304a92dc | Stavros Sachtouris | self.assert_dicts_are_equal(v, d2[k])
|
468 | 304a92dc | Stavros Sachtouris | else:
|
469 | 304a92dc | Stavros Sachtouris | self.assertEqual(unicode(v), unicode(d2[k])) |
470 | 304a92dc | Stavros Sachtouris | |
471 | 304a92dc | Stavros Sachtouris | """Set up a Cyclades thorough test"""
|
472 | 304a92dc | Stavros Sachtouris | def setUp(self): |
473 | 304a92dc | Stavros Sachtouris | self.url = 'http://cyclades.example.com' |
474 | 304a92dc | Stavros Sachtouris | self.token = 'cyc14d3s70k3n' |
475 | 3c50df2e | Stavros Sachtouris | self.client = compute.ComputeClient(self.url, self.token) |
476 | 304a92dc | Stavros Sachtouris | |
477 | 304a92dc | Stavros Sachtouris | def tearDown(self): |
478 | 304a92dc | Stavros Sachtouris | FR.status_code = 200
|
479 | 304a92dc | Stavros Sachtouris | FR.json = vm_recv |
480 | 304a92dc | Stavros Sachtouris | |
481 | 6d6d5141 | Stavros Sachtouris | def test_create_server(self): |
482 | edf8ad52 | Stavros Sachtouris | with patch.object(
|
483 | 3c50df2e | Stavros Sachtouris | compute.ComputeClient, 'servers_post',
|
484 | edf8ad52 | Stavros Sachtouris | side_effect=ClientError( |
485 | edf8ad52 | Stavros Sachtouris | 'REQUEST ENTITY TOO LARGE',
|
486 | edf8ad52 | Stavros Sachtouris | status=403)):
|
487 | 304a92dc | Stavros Sachtouris | self.assertRaises(
|
488 | 304a92dc | Stavros Sachtouris | ClientError, |
489 | 304a92dc | Stavros Sachtouris | self.client.create_server,
|
490 | 304a92dc | Stavros Sachtouris | vm_name, fid, img_ref) |
491 | 304a92dc | Stavros Sachtouris | |
492 | 6d6d5141 | Stavros Sachtouris | for params in product( |
493 | 6d6d5141 | Stavros Sachtouris | ('security_group', None), |
494 | 6d6d5141 | Stavros Sachtouris | ('user_data', None), |
495 | 6d6d5141 | Stavros Sachtouris | ('availability_zone', None), |
496 | 6d6d5141 | Stavros Sachtouris | (None, {'os': 'debian', 'users': 'root'})): |
497 | 6d6d5141 | Stavros Sachtouris | kwargs = dict()
|
498 | 6d6d5141 | Stavros Sachtouris | for i, k in enumerate(( |
499 | 6d6d5141 | Stavros Sachtouris | 'security_group', 'user_data', 'availability_zone')): |
500 | 6d6d5141 | Stavros Sachtouris | if params[i]:
|
501 | 6d6d5141 | Stavros Sachtouris | kwargs[k] = params[i] |
502 | 6d6d5141 | Stavros Sachtouris | with patch.object(
|
503 | 6d6d5141 | Stavros Sachtouris | compute.ComputeClient, 'servers_post',
|
504 | 6d6d5141 | Stavros Sachtouris | return_value=FR()) as post:
|
505 | 6d6d5141 | Stavros Sachtouris | r = self.client.create_server(vm_name, fid, img_ref, **kwargs)
|
506 | 6d6d5141 | Stavros Sachtouris | self.assertEqual(r, FR.json['server']) |
507 | 6d6d5141 | Stavros Sachtouris | exp_json = dict(server=dict( |
508 | 6d6d5141 | Stavros Sachtouris | flavorRef=fid, name=vm_name, imageRef=img_ref)) |
509 | 6d6d5141 | Stavros Sachtouris | for k in set([ |
510 | 6d6d5141 | Stavros Sachtouris | 'security_group',
|
511 | 6d6d5141 | Stavros Sachtouris | 'user_data',
|
512 | 6d6d5141 | Stavros Sachtouris | 'availability_zone']).difference(kwargs):
|
513 | 6d6d5141 | Stavros Sachtouris | kwargs[k] = None
|
514 | 6d6d5141 | Stavros Sachtouris | self.assertEqual(
|
515 | 6d6d5141 | Stavros Sachtouris | post.mock_calls[-1], call(json_data=exp_json, **kwargs))
|
516 | 6d6d5141 | Stavros Sachtouris | prsn = 'Personality string (does not work with real servers)'
|
517 | 6d6d5141 | Stavros Sachtouris | self.client.create_server(
|
518 | 6d6d5141 | Stavros Sachtouris | vm_name, fid, img_ref, personality=prsn, **kwargs) |
519 | 6d6d5141 | Stavros Sachtouris | exp_json['server']['personality'] = prsn |
520 | 6d6d5141 | Stavros Sachtouris | self.assertEqual(
|
521 | 6d6d5141 | Stavros Sachtouris | post.mock_calls[-1], call(json_data=exp_json, **kwargs))
|
522 | 6d6d5141 | Stavros Sachtouris | kwargs.pop('personality', None) |
523 | 6d6d5141 | Stavros Sachtouris | exp_json['server'].pop('personality', None) |
524 | 6d6d5141 | Stavros Sachtouris | mtdt = 'Metadata dict here'
|
525 | 6d6d5141 | Stavros Sachtouris | self.client.create_server(
|
526 | 6d6d5141 | Stavros Sachtouris | vm_name, fid, img_ref, metadata=mtdt, **kwargs) |
527 | 6d6d5141 | Stavros Sachtouris | exp_json['server']['metadata'] = mtdt |
528 | 6d6d5141 | Stavros Sachtouris | self.assertEqual(
|
529 | 6d6d5141 | Stavros Sachtouris | post.mock_calls[-1], call(json_data=exp_json, **kwargs))
|
530 | 304a92dc | Stavros Sachtouris | |
531 | 0067c031 | Stavros Sachtouris | @patch('%s.servers_get' % compute_pkg, return_value=FR()) |
532 | 0067c031 | Stavros Sachtouris | def test_list_servers(self, SG): |
533 | 304a92dc | Stavros Sachtouris | FR.json = vm_list |
534 | 6d6d5141 | Stavros Sachtouris | for args in product( |
535 | 6d6d5141 | Stavros Sachtouris | (False, True), |
536 | 6d6d5141 | Stavros Sachtouris | ({}, dict(status='status')), |
537 | 6d6d5141 | Stavros Sachtouris | ({}, dict(name='name')), |
538 | 6d6d5141 | Stavros Sachtouris | ({}, dict(image='image')), |
539 | 6d6d5141 | Stavros Sachtouris | ({}, dict(flavor='flavor')), |
540 | 6d6d5141 | Stavros Sachtouris | ({}, dict(host='host')), |
541 | 6d6d5141 | Stavros Sachtouris | ({}, dict(limit='limit')), |
542 | 6d6d5141 | Stavros Sachtouris | ({}, dict(marker='marker')), |
543 | 6d6d5141 | Stavros Sachtouris | ({}, dict(changes_since='changes_since'))): |
544 | 6d6d5141 | Stavros Sachtouris | detail = args[0]
|
545 | 6d6d5141 | Stavros Sachtouris | kwargs = dict()
|
546 | 6d6d5141 | Stavros Sachtouris | for param in args[1:]: |
547 | 6d6d5141 | Stavros Sachtouris | kwargs.update(param) |
548 | 6d6d5141 | Stavros Sachtouris | r = self.client.list_servers(detail, **kwargs)
|
549 | 6d6d5141 | Stavros Sachtouris | for k in set([ |
550 | 6d6d5141 | Stavros Sachtouris | 'status', 'name', |
551 | 6d6d5141 | Stavros Sachtouris | 'image', 'flavor', |
552 | 6d6d5141 | Stavros Sachtouris | 'host', 'limit', |
553 | 6d6d5141 | Stavros Sachtouris | 'marker', 'changes_since']).difference(kwargs): |
554 | 6d6d5141 | Stavros Sachtouris | kwargs[k] = None
|
555 | 6d6d5141 | Stavros Sachtouris | self.assertEqual(SG.mock_calls[-1], call(detail=detail, **kwargs)) |
556 | bcef3ac9 | Stavros Sachtouris | for i, vm in enumerate(vm_list['servers']): |
557 | b6403d2d | Stavros Sachtouris | self.assert_dicts_are_equal(r[i], vm)
|
558 | b6403d2d | Stavros Sachtouris | self.assertEqual(i + 1, len(r)) |
559 | 304a92dc | Stavros Sachtouris | |
560 | 26ccd6fb | Stavros Sachtouris | @patch('%s.servers_get' % compute_pkg, return_value=FR()) |
561 | 26ccd6fb | Stavros Sachtouris | def test_get_server_details(self, SG): |
562 | 304a92dc | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
563 | 6d6d5141 | Stavros Sachtouris | for args in product( |
564 | 6d6d5141 | Stavros Sachtouris | ({}, dict(status='status')), |
565 | 6d6d5141 | Stavros Sachtouris | ({}, dict(name='name')), |
566 | 6d6d5141 | Stavros Sachtouris | ({}, dict(image='image')), |
567 | 6d6d5141 | Stavros Sachtouris | ({}, dict(flavor='flavor')), |
568 | 6d6d5141 | Stavros Sachtouris | ({}, dict(host='host')), |
569 | 6d6d5141 | Stavros Sachtouris | ({}, dict(limit='limit')), |
570 | 6d6d5141 | Stavros Sachtouris | ({}, dict(marker='marker')), |
571 | 6d6d5141 | Stavros Sachtouris | ({}, dict(changes_since='changes_since'))): |
572 | 6d6d5141 | Stavros Sachtouris | kwargs = dict()
|
573 | 6d6d5141 | Stavros Sachtouris | for param in args: |
574 | 6d6d5141 | Stavros Sachtouris | kwargs.update(param) |
575 | 6d6d5141 | Stavros Sachtouris | r = self.client.get_server_details(vm_id, **kwargs)
|
576 | 6d6d5141 | Stavros Sachtouris | for k in set([ |
577 | 6d6d5141 | Stavros Sachtouris | 'status', 'name', |
578 | 6d6d5141 | Stavros Sachtouris | 'image', 'flavor', |
579 | 6d6d5141 | Stavros Sachtouris | 'host', 'limit', |
580 | 6d6d5141 | Stavros Sachtouris | 'marker', 'changes_since']).difference(kwargs): |
581 | 6d6d5141 | Stavros Sachtouris | kwargs[k] = None
|
582 | 6d6d5141 | Stavros Sachtouris | self.assertEqual(SG.mock_calls[-1], call(vm_id, **kwargs)) |
583 | 6d6d5141 | Stavros Sachtouris | self.assert_dicts_are_equal(r, vm_recv['server']) |
584 | 304a92dc | Stavros Sachtouris | |
585 | 2ace03e5 | Stavros Sachtouris | @patch('%s.servers_put' % compute_pkg, return_value=FR()) |
586 | 2ace03e5 | Stavros Sachtouris | def test_update_server_name(self, SP): |
587 | 304a92dc | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
588 | 304a92dc | Stavros Sachtouris | new_name = vm_name + '_new'
|
589 | 304a92dc | Stavros Sachtouris | self.client.update_server_name(vm_id, new_name)
|
590 | b6403d2d | Stavros Sachtouris | SP.assert_called_once_with(vm_id, json_data=dict(
|
591 | b6403d2d | Stavros Sachtouris | server=dict(name=new_name)))
|
592 | 304a92dc | Stavros Sachtouris | |
593 | 6d6d5141 | Stavros Sachtouris | @patch('%s.servers_action_post' % compute_pkg, return_value=FR()) |
594 | 876aae74 | Stavros Sachtouris | def test_reboot_server(self, SP): |
595 | 304a92dc | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
596 | 876aae74 | Stavros Sachtouris | for hard in (None, True): |
597 | 876aae74 | Stavros Sachtouris | self.client.reboot_server(vm_id, hard=hard)
|
598 | 6d6d5141 | Stavros Sachtouris | self.assertEqual(SP.mock_calls[-1], call(vm_id, json_data=dict( |
599 | 6d6d5141 | Stavros Sachtouris | reboot=dict(type='HARD' if hard else 'SOFT')))) |
600 | 304a92dc | Stavros Sachtouris | |
601 | 6d6d5141 | Stavros Sachtouris | @patch('%s.servers_action_post' % compute_pkg, return_value=FR()) |
602 | d07fddd9 | Stavros Sachtouris | def test_resize_server(self, SP): |
603 | d07fddd9 | Stavros Sachtouris | vm_id, flavor = vm_recv['server']['id'], flavor_list['flavors'][1] |
604 | d07fddd9 | Stavros Sachtouris | self.client.resize_server(vm_id, flavor['id']) |
605 | d07fddd9 | Stavros Sachtouris | exp = dict(resize=dict(flavorRef=flavor['id'])) |
606 | 6d6d5141 | Stavros Sachtouris | SP.assert_called_once_with(vm_id, json_data=exp) |
607 | d07fddd9 | Stavros Sachtouris | |
608 | 6d6d5141 | Stavros Sachtouris | @patch('%s.servers_metadata_put' % compute_pkg, return_value=FR()) |
609 | d560c67b | Stavros Sachtouris | def test_create_server_metadata(self, SP): |
610 | 304a92dc | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
611 | 304a92dc | Stavros Sachtouris | metadata = dict(m1='v1', m2='v2', m3='v3') |
612 | c088076b | Stavros Sachtouris | FR.json = dict(meta=vm_recv['server']) |
613 | 304a92dc | Stavros Sachtouris | for k, v in metadata.items(): |
614 | 304a92dc | Stavros Sachtouris | r = self.client.create_server_metadata(vm_id, k, v)
|
615 | 304a92dc | Stavros Sachtouris | self.assert_dicts_are_equal(r, vm_recv['server']) |
616 | d560c67b | Stavros Sachtouris | self.assertEqual(SP.mock_calls[-1], call( |
617 | 6d6d5141 | Stavros Sachtouris | vm_id, '%s' % k,
|
618 | c088076b | Stavros Sachtouris | json_data=dict(meta={k: v}), success=201)) |
619 | 304a92dc | Stavros Sachtouris | |
620 | 6d6d5141 | Stavros Sachtouris | @patch('%s.servers_metadata_get' % compute_pkg, return_value=FR()) |
621 | d224bb37 | Stavros Sachtouris | def test_get_server_metadata(self, SG): |
622 | 304a92dc | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
623 | 304a92dc | Stavros Sachtouris | metadata = dict(m1='v1', m2='v2', m3='v3') |
624 | bcef3ac9 | Stavros Sachtouris | FR.json = dict(metadata=metadata)
|
625 | 304a92dc | Stavros Sachtouris | r = self.client.get_server_metadata(vm_id)
|
626 | c088076b | Stavros Sachtouris | FR.json = dict(meta=metadata)
|
627 | 6d6d5141 | Stavros Sachtouris | SG.assert_called_once_with(vm_id, '')
|
628 | 304a92dc | Stavros Sachtouris | self.assert_dicts_are_equal(r, metadata)
|
629 | 304a92dc | Stavros Sachtouris | |
630 | 304a92dc | Stavros Sachtouris | for k, v in metadata.items(): |
631 | c088076b | Stavros Sachtouris | FR.json = dict(meta={k: v})
|
632 | 304a92dc | Stavros Sachtouris | r = self.client.get_server_metadata(vm_id, k)
|
633 | 304a92dc | Stavros Sachtouris | self.assert_dicts_are_equal(r, {k: v})
|
634 | bcef3ac9 | Stavros Sachtouris | self.assertEqual(
|
635 | 6d6d5141 | Stavros Sachtouris | SG.mock_calls[-1], call(vm_id, '%s' % k)) |
636 | 304a92dc | Stavros Sachtouris | |
637 | 6d6d5141 | Stavros Sachtouris | @patch('%s.servers_metadata_post' % compute_pkg, return_value=FR()) |
638 | e750a969 | Stavros Sachtouris | def test_update_server_metadata(self, SP): |
639 | 304a92dc | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
640 | 304a92dc | Stavros Sachtouris | metadata = dict(m1='v1', m2='v2', m3='v3') |
641 | 304a92dc | Stavros Sachtouris | FR.json = dict(metadata=metadata)
|
642 | 304a92dc | Stavros Sachtouris | r = self.client.update_server_metadata(vm_id, **metadata)
|
643 | 304a92dc | Stavros Sachtouris | self.assert_dicts_are_equal(r, metadata)
|
644 | b6403d2d | Stavros Sachtouris | SP.assert_called_once_with( |
645 | 6d6d5141 | Stavros Sachtouris | vm_id, json_data=dict(metadata=metadata), success=201) |
646 | 304a92dc | Stavros Sachtouris | |
647 | 6d6d5141 | Stavros Sachtouris | @patch('%s.servers_metadata_delete' % compute_pkg, return_value=FR()) |
648 | dbd50059 | Stavros Sachtouris | def test_delete_server_metadata(self, SD): |
649 | 304a92dc | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
650 | 304a92dc | Stavros Sachtouris | key = 'metakey'
|
651 | 304a92dc | Stavros Sachtouris | self.client.delete_server_metadata(vm_id, key)
|
652 | 6d6d5141 | Stavros Sachtouris | SD.assert_called_once_with(vm_id, key) |
653 | 304a92dc | Stavros Sachtouris | |
654 | 8c40c4a6 | Stavros Sachtouris | @patch('%s.flavors_get' % compute_pkg, return_value=FR()) |
655 | 8c40c4a6 | Stavros Sachtouris | def test_list_flavors(self, FG): |
656 | 304a92dc | Stavros Sachtouris | FR.json = flavor_list |
657 | 6d6d5141 | Stavros Sachtouris | for detail in ('', 'detail'): |
658 | 6d6d5141 | Stavros Sachtouris | r = self.client.list_flavors(detail=bool(detail)) |
659 | 6d6d5141 | Stavros Sachtouris | self.assertEqual(FG.mock_calls[-1], call(detail=bool(detail))) |
660 | bcef3ac9 | Stavros Sachtouris | self.assertEqual(r, flavor_list['flavors']) |
661 | 304a92dc | Stavros Sachtouris | |
662 | ae9c3b5f | Stavros Sachtouris | @patch('%s.flavors_get' % compute_pkg, return_value=FR()) |
663 | ae9c3b5f | Stavros Sachtouris | def test_get_flavor_details(self, FG): |
664 | bcef3ac9 | Stavros Sachtouris | FR.json = dict(flavor=flavor_list['flavors'][0]) |
665 | 304a92dc | Stavros Sachtouris | r = self.client.get_flavor_details(fid)
|
666 | b6403d2d | Stavros Sachtouris | FG.assert_called_once_with(fid) |
667 | bcef3ac9 | Stavros Sachtouris | self.assert_dicts_are_equal(r, flavor_list['flavors'][0]) |
668 | 304a92dc | Stavros Sachtouris | |
669 | b2347a17 | Stavros Sachtouris | @patch('%s.images_get' % compute_pkg, return_value=FR()) |
670 | b2347a17 | Stavros Sachtouris | def test_list_images(self, IG): |
671 | 304a92dc | Stavros Sachtouris | FR.json = img_list |
672 | 6d6d5141 | Stavros Sachtouris | for detail in ('', 'detail'): |
673 | 6d6d5141 | Stavros Sachtouris | r = self.client.list_images(detail=detail)
|
674 | 6d6d5141 | Stavros Sachtouris | self.assertEqual(IG.mock_calls[-1], call(detail=bool(detail))) |
675 | bcef3ac9 | Stavros Sachtouris | expected = img_list['images']
|
676 | b2347a17 | Stavros Sachtouris | for i in range(len(r)): |
677 | b2347a17 | Stavros Sachtouris | self.assert_dicts_are_equal(expected[i], r[i])
|
678 | 304a92dc | Stavros Sachtouris | |
679 | 937ef4dd | Stavros Sachtouris | @patch('%s.images_get' % compute_pkg, return_value=FR()) |
680 | 937ef4dd | Stavros Sachtouris | def test_get_image_details(self, IG): |
681 | 304a92dc | Stavros Sachtouris | FR.json = img_recv |
682 | 304a92dc | Stavros Sachtouris | r = self.client.get_image_details(img_ref)
|
683 | b6403d2d | Stavros Sachtouris | IG.assert_called_once_with(img_ref) |
684 | 304a92dc | Stavros Sachtouris | self.assert_dicts_are_equal(r, img_recv['image']) |
685 | 304a92dc | Stavros Sachtouris | |
686 | 6d6d5141 | Stavros Sachtouris | @patch('%s.images_metadata_get' % compute_pkg, return_value=FR()) |
687 | 304a92dc | Stavros Sachtouris | def test_get_image_metadata(self, IG): |
688 | b6403d2d | Stavros Sachtouris | for key in ('', '50m3k3y'): |
689 | c088076b | Stavros Sachtouris | FR.json = dict(meta=img_recv['image']) if ( |
690 | bcef3ac9 | Stavros Sachtouris | key) else dict(metadata=img_recv['image']) |
691 | b6403d2d | Stavros Sachtouris | r = self.client.get_image_metadata(img_ref, key)
|
692 | 6d6d5141 | Stavros Sachtouris | self.assertEqual(IG.mock_calls[-1], call(img_ref, key or '')) |
693 | b6403d2d | Stavros Sachtouris | self.assert_dicts_are_equal(img_recv['image'], r) |
694 | 304a92dc | Stavros Sachtouris | |
695 | 0651cda3 | Stavros Sachtouris | @patch('%s.servers_delete' % compute_pkg, return_value=FR()) |
696 | 0651cda3 | Stavros Sachtouris | def test_delete_server(self, SD): |
697 | 304a92dc | Stavros Sachtouris | vm_id = vm_recv['server']['id'] |
698 | 304a92dc | Stavros Sachtouris | self.client.delete_server(vm_id)
|
699 | 1df5305d | Stavros Sachtouris | SD.assert_called_once_with(vm_id) |
700 | 304a92dc | Stavros Sachtouris | |
701 | f711008c | Stavros Sachtouris | @patch('%s.images_delete' % compute_pkg, return_value=FR()) |
702 | f711008c | Stavros Sachtouris | def test_delete_image(self, ID): |
703 | 304a92dc | Stavros Sachtouris | self.client.delete_image(img_ref)
|
704 | 1df5305d | Stavros Sachtouris | ID.assert_called_once_with(img_ref) |
705 | 304a92dc | Stavros Sachtouris | |
706 | 6d6d5141 | Stavros Sachtouris | @patch('%s.images_metadata_put' % compute_pkg, return_value=FR()) |
707 | 71017d87 | Stavros Sachtouris | def test_create_image_metadata(self, IP): |
708 | 71017d87 | Stavros Sachtouris | (key, val) = ('k1', 'v1') |
709 | c088076b | Stavros Sachtouris | FR.json = dict(meta=img_recv['image']) |
710 | 71017d87 | Stavros Sachtouris | r = self.client.create_image_metadata(img_ref, key, val)
|
711 | 1df5305d | Stavros Sachtouris | IP.assert_called_once_with( |
712 | 6d6d5141 | Stavros Sachtouris | img_ref, '%s' % key,
|
713 | c088076b | Stavros Sachtouris | json_data=dict(meta={key: val}))
|
714 | 71017d87 | Stavros Sachtouris | self.assert_dicts_are_equal(r, img_recv['image']) |
715 | 304a92dc | Stavros Sachtouris | |
716 | 6d6d5141 | Stavros Sachtouris | @patch('%s.images_metadata_post' % compute_pkg, return_value=FR()) |
717 | 428aa852 | Stavros Sachtouris | def test_update_image_metadata(self, IP): |
718 | 304a92dc | Stavros Sachtouris | metadata = dict(m1='v1', m2='v2', m3='v3') |
719 | 304a92dc | Stavros Sachtouris | FR.json = dict(metadata=metadata)
|
720 | 304a92dc | Stavros Sachtouris | r = self.client.update_image_metadata(img_ref, **metadata)
|
721 | 1df5305d | Stavros Sachtouris | IP.assert_called_once_with( |
722 | 6d6d5141 | Stavros Sachtouris | img_ref, json_data=dict(metadata=metadata))
|
723 | 304a92dc | Stavros Sachtouris | self.assert_dicts_are_equal(r, metadata)
|
724 | 304a92dc | Stavros Sachtouris | |
725 | 6d6d5141 | Stavros Sachtouris | @patch('%s.images_metadata_delete' % compute_pkg, return_value=FR()) |
726 | 0482817c | Stavros Sachtouris | def test_delete_image_metadata(self, ID): |
727 | 304a92dc | Stavros Sachtouris | key = 'metakey'
|
728 | 304a92dc | Stavros Sachtouris | self.client.delete_image_metadata(img_ref, key)
|
729 | 6d6d5141 | Stavros Sachtouris | ID.assert_called_once_with(img_ref, '%s' % key)
|
730 | 304a92dc | Stavros Sachtouris | |
731 | 03033b54 | Stavros Sachtouris | @patch('%s.floating_ip_pools_get' % compute_pkg, return_value=FR()) |
732 | 03033b54 | Stavros Sachtouris | def test_get_floating_ip_pools(self, get): |
733 | 03033b54 | Stavros Sachtouris | tid = 't3n@nt_1d'
|
734 | 03033b54 | Stavros Sachtouris | r = self.client.get_floating_ip_pools(tid)
|
735 | 03033b54 | Stavros Sachtouris | self.assert_dicts_are_equal(r, FR.json)
|
736 | 03033b54 | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call(tid)) |
737 | 03033b54 | Stavros Sachtouris | |
738 | 03033b54 | Stavros Sachtouris | @patch('%s.floating_ips_get' % compute_pkg, return_value=FR()) |
739 | 03033b54 | Stavros Sachtouris | def test_get_floating_ips(self, get): |
740 | 03033b54 | Stavros Sachtouris | tid = 't3n@nt_1d'
|
741 | 03033b54 | Stavros Sachtouris | r = self.client.get_floating_ips(tid)
|
742 | 03033b54 | Stavros Sachtouris | self.assert_dicts_are_equal(r, FR.json)
|
743 | 03033b54 | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call(tid)) |
744 | 03033b54 | Stavros Sachtouris | |
745 | 03033b54 | Stavros Sachtouris | @patch('%s.floating_ips_post' % compute_pkg, return_value=FR()) |
746 | 03033b54 | Stavros Sachtouris | def test_alloc_floating_ip(self, post): |
747 | 03033b54 | Stavros Sachtouris | FR.json = dict(floating_ip=dict( |
748 | 03033b54 | Stavros Sachtouris | fixed_ip='fip',
|
749 | 03033b54 | Stavros Sachtouris | id=1,
|
750 | 03033b54 | Stavros Sachtouris | instance_id='lala',
|
751 | 03033b54 | Stavros Sachtouris | ip='102.0.0.1',
|
752 | 03033b54 | Stavros Sachtouris | pool='pisine'))
|
753 | 03033b54 | Stavros Sachtouris | for args in product( |
754 | 03033b54 | Stavros Sachtouris | ('t1', 't2'), |
755 | 03033b54 | Stavros Sachtouris | (None, 'pisine')): |
756 | 03033b54 | Stavros Sachtouris | r = self.client.alloc_floating_ip(*args)
|
757 | 03033b54 | Stavros Sachtouris | tenant_id, pool = args |
758 | 03033b54 | Stavros Sachtouris | self.assert_dicts_are_equal(r, FR.json['floating_ip']) |
759 | 03033b54 | Stavros Sachtouris | expected = dict(pool=pool) if pool else dict() |
760 | 03033b54 | Stavros Sachtouris | self.assertEqual(post.mock_calls[-1], call(tenant_id, expected)) |
761 | 03033b54 | Stavros Sachtouris | |
762 | 03033b54 | Stavros Sachtouris | @patch('%s.floating_ips_get' % compute_pkg, return_value=FR()) |
763 | 03033b54 | Stavros Sachtouris | def test_get_floating_ip(self, get): |
764 | 03033b54 | Stavros Sachtouris | FR.json = dict(floating_ips=[dict( |
765 | 03033b54 | Stavros Sachtouris | fixed_ip='fip',
|
766 | 03033b54 | Stavros Sachtouris | id=1,
|
767 | 03033b54 | Stavros Sachtouris | instance_id='lala',
|
768 | 03033b54 | Stavros Sachtouris | ip='102.0.0.1',
|
769 | 03033b54 | Stavros Sachtouris | pool='pisine'), ])
|
770 | 03033b54 | Stavros Sachtouris | for args in product( |
771 | 03033b54 | Stavros Sachtouris | ('t1', 't2'), |
772 | 03033b54 | Stavros Sachtouris | (None, 'fip')): |
773 | 03033b54 | Stavros Sachtouris | r = self.client.get_floating_ip(*args)
|
774 | 03033b54 | Stavros Sachtouris | tenant_id, fip = args |
775 | 03033b54 | Stavros Sachtouris | self.assertEqual(r, FR.json['floating_ips']) |
776 | 03033b54 | Stavros Sachtouris | self.assertEqual(get.mock_calls[-1], call(tenant_id, fip)) |
777 | 03033b54 | Stavros Sachtouris | |
778 | 03033b54 | Stavros Sachtouris | @patch('%s.floating_ips_delete' % compute_pkg, return_value=FR()) |
779 | 03033b54 | Stavros Sachtouris | def test_delete_floating_ip(self, delete): |
780 | 03033b54 | Stavros Sachtouris | for args in product( |
781 | 03033b54 | Stavros Sachtouris | ('t1', 't2'), |
782 | 03033b54 | Stavros Sachtouris | (None, 'fip')): |
783 | 03033b54 | Stavros Sachtouris | r = self.client.delete_floating_ip(*args)
|
784 | 03033b54 | Stavros Sachtouris | tenant_id, fip = args |
785 | 03033b54 | Stavros Sachtouris | self.assertEqual(r, FR.headers)
|
786 | 03033b54 | Stavros Sachtouris | self.assertEqual(delete.mock_calls[-1], call(tenant_id, fip)) |
787 | 03033b54 | Stavros Sachtouris | |
788 | 630dea9b | Stavros Sachtouris | |
789 | 304a92dc | Stavros Sachtouris | if __name__ == '__main__': |
790 | 304a92dc | Stavros Sachtouris | from sys import argv |
791 | 304a92dc | Stavros Sachtouris | from kamaki.clients.test import runTestCase |
792 | 630dea9b | Stavros Sachtouris | not_found = True
|
793 | 3c50df2e | Stavros Sachtouris | if not argv[1:] or argv[1] == 'ComputeClient': |
794 | 630dea9b | Stavros Sachtouris | not_found = False
|
795 | 3c50df2e | Stavros Sachtouris | runTestCase(ComputeClient, 'Compute Client', argv[2:]) |
796 | 55faa0bc | Stavros Sachtouris | if not argv[1:] or argv[1] == 'ComputeRest': |
797 | 630dea9b | Stavros Sachtouris | not_found = False
|
798 | 3c50df2e | Stavros Sachtouris | runTestCase(ComputeRestClient, 'ComputeRest Client', argv[2:]) |
799 | 630dea9b | Stavros Sachtouris | if not_found:
|
800 | 630dea9b | Stavros Sachtouris | print('TestCase %s not found' % argv[1]) |