root / kamaki / cli / commands / livetest.py @ 5033585e
History | View | Annotate | Download (7.2 kB)
1 | 33e3437a | Stavros Sachtouris | # Copyright 2012-2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 33e3437a | Stavros Sachtouris | #
|
3 | 33e3437a | Stavros Sachtouris | # Redistribution and use in source and binary forms, with or
|
4 | 33e3437a | Stavros Sachtouris | # without modification, are permitted provided that the following
|
5 | 33e3437a | Stavros Sachtouris | # conditions are met:
|
6 | 33e3437a | Stavros Sachtouris | #
|
7 | 33e3437a | Stavros Sachtouris | # 1. Redistributions of source code must retain the above
|
8 | 33e3437a | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
9 | 33e3437a | Stavros Sachtouris | # disclaimer.
|
10 | 33e3437a | Stavros Sachtouris | #
|
11 | 33e3437a | Stavros Sachtouris | # 2. Redistributions in binary form must reproduce the above
|
12 | 33e3437a | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
13 | 33e3437a | Stavros Sachtouris | # disclaimer in the documentation and/or other materials
|
14 | 33e3437a | Stavros Sachtouris | # provided with the distribution.
|
15 | 33e3437a | Stavros Sachtouris | #
|
16 | 33e3437a | Stavros Sachtouris | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 33e3437a | Stavros Sachtouris | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 33e3437a | Stavros Sachtouris | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 33e3437a | Stavros Sachtouris | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 33e3437a | Stavros Sachtouris | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 33e3437a | Stavros Sachtouris | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 33e3437a | Stavros Sachtouris | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 33e3437a | Stavros Sachtouris | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 33e3437a | Stavros Sachtouris | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 33e3437a | Stavros Sachtouris | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 33e3437a | Stavros Sachtouris | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 33e3437a | Stavros Sachtouris | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 33e3437a | Stavros Sachtouris | #
|
29 | 33e3437a | Stavros Sachtouris | # The views and conclusions contained in the software and
|
30 | 33e3437a | Stavros Sachtouris | # documentation are those of the authors and should not be
|
31 | 33e3437a | Stavros Sachtouris | # interpreted as representing official policies, either expressed
|
32 | 33e3437a | Stavros Sachtouris | # or implied, of GRNET S.A.command
|
33 | 33e3437a | Stavros Sachtouris | |
34 | 1f0370c9 | Stavros Sachtouris | from kamaki.cli.commands import errors |
35 | e0f40c94 | Stavros Sachtouris | from kamaki.cli import command |
36 | 03fd7ddb | Stavros Sachtouris | from kamaki.cli.commands import _command_init |
37 | af6de846 | Stavros Sachtouris | from kamaki.cli.command_tree import CommandTree |
38 | f5f2dc53 | Stavros Sachtouris | from kamaki.clients import livetest |
39 | 1f0370c9 | Stavros Sachtouris | from kamaki.cli.errors import raiseCLIError |
40 | 234954d1 | Stavros Sachtouris | |
41 | a29d2f88 | Stavros Sachtouris | livetest_cmds = CommandTree('livetest', 'Client func. tests on live servers') |
42 | f5f2dc53 | Stavros Sachtouris | _commands = [livetest_cmds] |
43 | 234954d1 | Stavros Sachtouris | |
44 | af6de846 | Stavros Sachtouris | |
45 | f5f2dc53 | Stavros Sachtouris | class _livetest_init(_command_init): |
46 | 0d249b3e | Stavros Sachtouris | |
47 | 5207c784 | Stavros Sachtouris | def _run(self, client, method=None): |
48 | 75c3fc42 | Stavros Sachtouris | if method:
|
49 | 4ff9d6e2 | Stavros Sachtouris | livetest.main([client, method], config=self.config)
|
50 | 75c3fc42 | Stavros Sachtouris | else:
|
51 | 4ff9d6e2 | Stavros Sachtouris | livetest.main([client], config=self.config)
|
52 | 234954d1 | Stavros Sachtouris | |
53 | 5207c784 | Stavros Sachtouris | def main(self, client, method=None): |
54 | 5207c784 | Stavros Sachtouris | return self._run(client, method) |
55 | 5207c784 | Stavros Sachtouris | |
56 | af6de846 | Stavros Sachtouris | |
57 | f5f2dc53 | Stavros Sachtouris | @command(livetest_cmds)
|
58 | f5f2dc53 | Stavros Sachtouris | class livetest_error(_livetest_init): |
59 | 3667e969 | Stavros Sachtouris | """Create an error message with optional message"""
|
60 | 3667e969 | Stavros Sachtouris | |
61 | 1f0370c9 | Stavros Sachtouris | @errors.generic.all
|
62 | 1f0370c9 | Stavros Sachtouris | def _run(self, errmsg='', importance=0, index=0): |
63 | 3667e969 | Stavros Sachtouris | l = [1, 2] |
64 | 3667e969 | Stavros Sachtouris | try:
|
65 | 3667e969 | Stavros Sachtouris | l[int(index)]
|
66 | 3667e969 | Stavros Sachtouris | except Exception as err: |
67 | 3667e969 | Stavros Sachtouris | raiseCLIError(err, errmsg, importance) |
68 | 3667e969 | Stavros Sachtouris | raiseCLIError(None, errmsg, importance)
|
69 | 3667e969 | Stavros Sachtouris | |
70 | 1f0370c9 | Stavros Sachtouris | def main(self, errmsg='', importance=0, index=0): |
71 | 1f0370c9 | Stavros Sachtouris | self._run(errmsg, importance, index)
|
72 | 1f0370c9 | Stavros Sachtouris | |
73 | 3667e969 | Stavros Sachtouris | |
74 | f5f2dc53 | Stavros Sachtouris | @command(livetest_cmds)
|
75 | f5f2dc53 | Stavros Sachtouris | class livetest_args(_livetest_init): |
76 | e0f40c94 | Stavros Sachtouris | """Test how arguments are treated by kamaki"""
|
77 | e0f40c94 | Stavros Sachtouris | |
78 | 1f0370c9 | Stavros Sachtouris | @errors.generic.all
|
79 | 1f0370c9 | Stavros Sachtouris | def _run(self, *args): |
80 | 1d0f1ffa | Stavros Sachtouris | self.writeln(args)
|
81 | e0f40c94 | Stavros Sachtouris | |
82 | 1f0370c9 | Stavros Sachtouris | def main(self, *args): |
83 | 1f0370c9 | Stavros Sachtouris | self._run(args)
|
84 | 1f0370c9 | Stavros Sachtouris | |
85 | e0f40c94 | Stavros Sachtouris | |
86 | f5f2dc53 | Stavros Sachtouris | @command(livetest_cmds)
|
87 | f5f2dc53 | Stavros Sachtouris | class livetest_all(_livetest_init): |
88 | 75c3fc42 | Stavros Sachtouris | """test all clients"""
|
89 | 78496d42 | Stavros Sachtouris | |
90 | 1f0370c9 | Stavros Sachtouris | @errors.generic.all
|
91 | 1f0370c9 | Stavros Sachtouris | def _run(self): |
92 | 75c3fc42 | Stavros Sachtouris | for client in ('pithos', 'cyclades', 'image', 'astakos'): |
93 | 5207c784 | Stavros Sachtouris | super(self.__class__, self)._run(client) |
94 | 78496d42 | Stavros Sachtouris | |
95 | 1f0370c9 | Stavros Sachtouris | def main(self): |
96 | 1f0370c9 | Stavros Sachtouris | self._run()
|
97 | 1f0370c9 | Stavros Sachtouris | |
98 | 78496d42 | Stavros Sachtouris | |
99 | f5f2dc53 | Stavros Sachtouris | @command(livetest_cmds)
|
100 | f5f2dc53 | Stavros Sachtouris | class livetest_pithos(_livetest_init): |
101 | 75c3fc42 | Stavros Sachtouris | """ test Pithos client"""
|
102 | 78496d42 | Stavros Sachtouris | |
103 | 1f0370c9 | Stavros Sachtouris | @errors.generic.all
|
104 | 1f0370c9 | Stavros Sachtouris | def _run(self, method=None): |
105 | 5207c784 | Stavros Sachtouris | super(self.__class__, self)._run('pithos', method) |
106 | 78496d42 | Stavros Sachtouris | |
107 | 1f0370c9 | Stavros Sachtouris | def main(self, method=None): |
108 | 1f0370c9 | Stavros Sachtouris | self._run(method)
|
109 | 1f0370c9 | Stavros Sachtouris | |
110 | 78496d42 | Stavros Sachtouris | |
111 | f5f2dc53 | Stavros Sachtouris | @command(livetest_cmds)
|
112 | f5f2dc53 | Stavros Sachtouris | class livetest_cyclades(_livetest_init): |
113 | 75c3fc42 | Stavros Sachtouris | """ test Cyclades client"""
|
114 | c59aef27 | Stavros Sachtouris | |
115 | 1f0370c9 | Stavros Sachtouris | @errors.generic.all
|
116 | 1f0370c9 | Stavros Sachtouris | def _run(self, method=None): |
117 | 5207c784 | Stavros Sachtouris | super(self.__class__, self)._run('cyclades', method) |
118 | c59aef27 | Stavros Sachtouris | |
119 | 1f0370c9 | Stavros Sachtouris | def main(self, method=None): |
120 | 1f0370c9 | Stavros Sachtouris | self._run(method)
|
121 | 1f0370c9 | Stavros Sachtouris | |
122 | 78496d42 | Stavros Sachtouris | |
123 | f5f2dc53 | Stavros Sachtouris | @command(livetest_cmds)
|
124 | f5f2dc53 | Stavros Sachtouris | class livetest_image(_livetest_init): |
125 | 75c3fc42 | Stavros Sachtouris | """ test Image client"""
|
126 | 0d249b3e | Stavros Sachtouris | |
127 | 1f0370c9 | Stavros Sachtouris | @errors.generic.all
|
128 | 1f0370c9 | Stavros Sachtouris | def _run(self, method=None): |
129 | 5207c784 | Stavros Sachtouris | super(self.__class__, self)._run('image', method) |
130 | 33e3437a | Stavros Sachtouris | |
131 | 1f0370c9 | Stavros Sachtouris | def main(self, method=None): |
132 | 1f0370c9 | Stavros Sachtouris | self._run(method)
|
133 | 1f0370c9 | Stavros Sachtouris | |
134 | 78496d42 | Stavros Sachtouris | |
135 | f5f2dc53 | Stavros Sachtouris | @command(livetest_cmds)
|
136 | f5f2dc53 | Stavros Sachtouris | class livetest_astakos(_livetest_init): |
137 | 75c3fc42 | Stavros Sachtouris | """ test Astakos client"""
|
138 | 33e3437a | Stavros Sachtouris | |
139 | 1f0370c9 | Stavros Sachtouris | @errors.generic.all
|
140 | 1f0370c9 | Stavros Sachtouris | def _run(self, method=None): |
141 | 5207c784 | Stavros Sachtouris | super(self.__class__, self)._run('astakos', method) |
142 | b9b7bd83 | Stavros Sachtouris | |
143 | 1f0370c9 | Stavros Sachtouris | def main(self, method=None): |
144 | 1f0370c9 | Stavros Sachtouris | self._run(method)
|
145 | 1f0370c9 | Stavros Sachtouris | |
146 | b9b7bd83 | Stavros Sachtouris | |
147 | f5f2dc53 | Stavros Sachtouris | @command(livetest_cmds)
|
148 | f5f2dc53 | Stavros Sachtouris | class livetest_prints(_livetest_init): |
149 | b9b7bd83 | Stavros Sachtouris | """ user-test print methods for lists and dicts"""
|
150 | b9b7bd83 | Stavros Sachtouris | |
151 | b9b7bd83 | Stavros Sachtouris | d1 = {'key0a': 'val0a', 'key0b': 'val0b', 'key0c': 'val0c'} |
152 | b9b7bd83 | Stavros Sachtouris | |
153 | b9b7bd83 | Stavros Sachtouris | l1 = [1, 'string', '3', 'many (2 or 3) numbers and strings combined', 5] |
154 | b9b7bd83 | Stavros Sachtouris | |
155 | a494a741 | Stavros Sachtouris | d2 = {'id': 'val0a', 'key0b': d1, 'title': l1} |
156 | b9b7bd83 | Stavros Sachtouris | |
157 | b9b7bd83 | Stavros Sachtouris | l2 = [d2, l1, d1] |
158 | b9b7bd83 | Stavros Sachtouris | |
159 | de73876b | Stavros Sachtouris | spr_msg = 'long key of size 75 characters is used to check the effects on'
|
160 | de73876b | Stavros Sachtouris | spr_msg += ' total result for long messages that drive pep8 completely mad'
|
161 | de73876b | Stavros Sachtouris | d3 = {'dict 1': d1, 'dict 2': d2, 'list2': l2, spr_msg: l1} |
162 | f91bc6b1 | Stavros Sachtouris | |
163 | 1f0370c9 | Stavros Sachtouris | @errors.generic.all
|
164 | 1f0370c9 | Stavros Sachtouris | def _run(self): |
165 | a494a741 | Stavros Sachtouris | from kamaki.cli.utils import print_dict, print_list, print_items |
166 | 1d0f1ffa | Stavros Sachtouris | self.writeln('Test simple dict:\n- - -') |
167 | b9b7bd83 | Stavros Sachtouris | print_dict(self.d1)
|
168 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -\n') |
169 | 1d0f1ffa | Stavros Sachtouris | self.writeln('\nTest simple list:\n- - -') |
170 | b9b7bd83 | Stavros Sachtouris | print_list(self.l1)
|
171 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -\n') |
172 | 1d0f1ffa | Stavros Sachtouris | self.writeln('\nTest 2-level dict:\n- - -') |
173 | f91bc6b1 | Stavros Sachtouris | print_dict(self.d2)
|
174 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -\n') |
175 | 1d0f1ffa | Stavros Sachtouris | self.writeln('\nTest non-trivial list:\n- - -') |
176 | f91bc6b1 | Stavros Sachtouris | print_list(self.l2)
|
177 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -') |
178 | 1d0f1ffa | Stavros Sachtouris | self.writeln('\nTest extreme dict:\n- - -') |
179 | f91bc6b1 | Stavros Sachtouris | print_dict(self.d3)
|
180 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -\n') |
181 | 1d0f1ffa | Stavros Sachtouris | self.writeln('Test simple enumerated dict:\n- - -') |
182 | f8681ec8 | Stavros Sachtouris | print_dict(self.d1, with_enumeration=True) |
183 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -\n') |
184 | 1d0f1ffa | Stavros Sachtouris | self.writeln('\nTest simple enumerated list:\n- - -') |
185 | f8681ec8 | Stavros Sachtouris | print_list(self.l1, with_enumeration=True) |
186 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -\n') |
187 | 1d0f1ffa | Stavros Sachtouris | self.writeln('Test non-trivial deep-enumerated dict:\n- - -') |
188 | f8681ec8 | Stavros Sachtouris | print_dict(self.d2, with_enumeration=True, recursive_enumeration=True) |
189 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -\n') |
190 | 1d0f1ffa | Stavros Sachtouris | self.writeln('\nTest non-trivial enumerated list:\n- - -') |
191 | f8681ec8 | Stavros Sachtouris | print_list(self.l2, with_enumeration=True) |
192 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -\n') |
193 | 1d0f1ffa | Stavros Sachtouris | self.writeln('\nTest print_items with id:\n- - -') |
194 | de73876b | Stavros Sachtouris | print_items([ |
195 | de73876b | Stavros Sachtouris | {'id': '42', 'title': 'lalakis 1', 'content': self.d1}, |
196 | a494a741 | Stavros Sachtouris | {'id': '142', 'title': 'lalakis 2', 'content': self.d2}]) |
197 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -') |
198 | 1d0f1ffa | Stavros Sachtouris | self.writeln('\nTest print_items with id and enumeration:\n- - -') |
199 | 24ff0a35 | Stavros Sachtouris | print_items( |
200 | 24ff0a35 | Stavros Sachtouris | [ |
201 | de73876b | Stavros Sachtouris | {'id': '42', 'title': 'lalakis 1', 'content': self.d1}, |
202 | de73876b | Stavros Sachtouris | {'id': '142', 'title': 'lalakis 2', 'content': self.d2}], |
203 | a494a741 | Stavros Sachtouris | with_enumeration=True)
|
204 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -') |
205 | 1d0f1ffa | Stavros Sachtouris | self.writeln('\nTest print_items with id, title, redundancy:\n- - -') |
206 | 24ff0a35 | Stavros Sachtouris | print_items( |
207 | 24ff0a35 | Stavros Sachtouris | [ |
208 | de73876b | Stavros Sachtouris | {'id': '42', 'title': 'lalakis 1', 'content': self.d1}, |
209 | de73876b | Stavros Sachtouris | {'id': '142', 'title': 'lalakis 2', 'content': self.d2}], |
210 | a494a741 | Stavros Sachtouris | title=('id', 'title'), |
211 | a494a741 | Stavros Sachtouris | with_redundancy=True)
|
212 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -') |
213 | 1d0f1ffa | Stavros Sachtouris | self.writeln('\nTest print_items with lists- - -') |
214 | a494a741 | Stavros Sachtouris | print_items([['i00', 'i01', 'i02'], [self.l2, 'i11', self.d1], 3]) |
215 | 1d0f1ffa | Stavros Sachtouris | self.writeln('- - -') |
216 | 1f0370c9 | Stavros Sachtouris | |
217 | 1f0370c9 | Stavros Sachtouris | def main(self): |
218 | 1f0370c9 | Stavros Sachtouris | self._run() |