Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 452 lines (351 sloc) 17.354 kb
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
1 #!/usr/bin/env python
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
2 # -*- coding=utf-8 -*-
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
3
4 ## Amazon S3cmd - testsuite
5 ## Author: Michal Ludvig <michal@logix.cz>
6 ## http://www.logix.cz/michal
7 ## License: GPL Version 2
8
9 import sys
9856527 Michael Ludvig * s3cmd, run-tests.py: Make it work on Windows.
mludvig authored
10 import os
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
11 import re
12 from subprocess import Popen, PIPE, STDOUT
f891a81 Michael Ludvig * run-tests.py: Don't assume utf-8, use preferred encoding
mludvig authored
13 import locale
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
14
15 count_pass = 0
16 count_fail = 0
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
17 count_skip = 0
18
19 test_counter = 0
20 run_tests = []
21 exclude_tests = []
22
3677a3b Michael Ludvig * run-tests.py: Added --verbose mode.
mludvig authored
23 verbose = False
24
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
25 if os.name == "posix":
26 have_wget = True
27 elif os.name == "nt":
28 have_wget = False
29 else:
30 print "Unknown platform: %s" % os.name
31 sys.exit(1)
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
32
4986ae8 Michael Ludvig * run-tests.py: Adapted to the above change.
mludvig authored
33 ## Patterns for Unicode tests
34 patterns = {}
35 patterns['UTF-8'] = u"ŪņЇЌœđЗ/☺ unicode € rocks ™"
36 patterns['GBK'] = u"12月31日/1-特色條目"
37
38 encoding = locale.getpreferredencoding()
39 if not encoding:
40 print "Guessing current system encoding failed. Consider setting $LANG variable."
41 sys.exit(1)
5f7a2d5 Michael Ludvig * s3cmd: Reworked internal handling of unicode vs encoded filenames.
mludvig authored
42 else:
43 print "System encoding: " + encoding
4986ae8 Michael Ludvig * run-tests.py: Adapted to the above change.
mludvig authored
44
45 have_encoding = os.path.isdir('testsuite/encodings/' + encoding)
46 if not have_encoding and os.path.isfile('testsuite/encodings/%s.tar.gz' % encoding):
5f7a2d5 Michael Ludvig * s3cmd: Reworked internal handling of unicode vs encoded filenames.
mludvig authored
47 os.system("tar xvz -C testsuite/encodings -f testsuite/encodings/%s.tar.gz" % encoding)
4986ae8 Michael Ludvig * run-tests.py: Adapted to the above change.
mludvig authored
48 have_encoding = os.path.isdir('testsuite/encodings/' + encoding)
49
50 if have_encoding:
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
51 #enc_base_remote = "%s/xyz/%s/" % (pbucket(1), encoding)
4986ae8 Michael Ludvig * run-tests.py: Adapted to the above change.
mludvig authored
52 enc_pattern = patterns[encoding]
5f7a2d5 Michael Ludvig * s3cmd: Reworked internal handling of unicode vs encoded filenames.
mludvig authored
53 else:
54 print encoding + " specific files not found."
4986ae8 Michael Ludvig * run-tests.py: Adapted to the above change.
mludvig authored
55
76ce644 Michael Ludvig * run-tests.py, testsuite/crappy-file-name.tar.gz:
mludvig authored
56 if not os.path.isdir('testsuite/crappy-file-name'):
57 os.system("tar xvz -C testsuite -f testsuite/crappy-file-name.tar.gz")
58 # TODO: also unpack if the tarball is newer than the directory timestamp
59 # for instance when a new version was pulled from SVN.
60
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
61 def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [], must_find_re = [], must_not_find_re = []):
3677a3b Michael Ludvig * run-tests.py: Added --verbose mode.
mludvig authored
62 def command_output():
63 print "----"
64 print " ".join([arg.find(" ")>=0 and "'%s'" % arg or arg for arg in cmd_args])
65 print "----"
66 print stdout
67 print "----"
68
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
69 def failure(message = ""):
70 global count_fail
71 if message:
f891a81 Michael Ludvig * run-tests.py: Don't assume utf-8, use preferred encoding
mludvig authored
72 message = " (%r)" % message
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
73 print "\x1b[31;1mFAIL%s\x1b[0m" % (message)
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
74 count_fail += 1
3677a3b Michael Ludvig * run-tests.py: Added --verbose mode.
mludvig authored
75 command_output()
257d632 Michael Ludvig * run-tests.py: Exit on failed test. Fixed order of tests.
mludvig authored
76 #return 1
77 sys.exit(1)
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
78 def success(message = ""):
79 global count_pass
80 if message:
f891a81 Michael Ludvig * run-tests.py: Don't assume utf-8, use preferred encoding
mludvig authored
81 message = " (%r)" % message
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
82 print "\x1b[32;1mOK\x1b[0m%s" % (message)
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
83 count_pass += 1
3677a3b Michael Ludvig * run-tests.py: Added --verbose mode.
mludvig authored
84 if verbose:
85 command_output()
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
86 return 0
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
87 def skip(message = ""):
88 global count_skip
89 if message:
f891a81 Michael Ludvig * run-tests.py: Don't assume utf-8, use preferred encoding
mludvig authored
90 message = " (%r)" % message
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
91 print "\x1b[33;1mSKIP\x1b[0m%s" % (message)
92 count_skip += 1
93 return 0
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
94 def compile_list(_list, regexps = False):
95 if type(_list) not in [ list, tuple ]:
96 _list = [_list]
97
98 if regexps == False:
4986ae8 Michael Ludvig * run-tests.py: Adapted to the above change.
mludvig authored
99 _list = [re.escape(item.encode(encoding, "replace")) for item in _list]
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
100
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
101 return [re.compile(item, re.MULTILINE) for item in _list]
102
103 global test_counter
104 test_counter += 1
105 print ("%3d %s " % (test_counter, label)).ljust(30, "."),
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
106 sys.stdout.flush()
107
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
108 if run_tests.count(test_counter) == 0 or exclude_tests.count(test_counter) > 0:
109 return skip()
110
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
111 p = Popen(cmd_args, stdout = PIPE, stderr = STDOUT, universal_newlines = True)
112 stdout, stderr = p.communicate()
113 if retcode != p.returncode:
114 return failure("retcode: %d, expected: %d" % (p.returncode, retcode))
115
116 find_list = []
117 find_list.extend(compile_list(must_find))
118 find_list.extend(compile_list(must_find_re, regexps = True))
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
119 find_list_patterns = []
120 find_list_patterns.extend(must_find)
121 find_list_patterns.extend(must_find_re)
122
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
123 not_find_list = []
124 not_find_list.extend(compile_list(must_not_find))
125 not_find_list.extend(compile_list(must_not_find_re, regexps = True))
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
126 not_find_list_patterns = []
127 not_find_list_patterns.extend(must_not_find)
128 not_find_list_patterns.extend(must_not_find_re)
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
129
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
130 for index in range(len(find_list)):
131 match = find_list[index].search(stdout)
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
132 if not match:
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
133 return failure("pattern not found: %s" % find_list_patterns[index])
134 for index in range(len(not_find_list)):
135 match = not_find_list[index].search(stdout)
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
136 if match:
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
137 return failure("pattern found: %s (match: %s)" % (not_find_list_patterns[index], match.group(0)))
3677a3b Michael Ludvig * run-tests.py: Added --verbose mode.
mludvig authored
138
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
139 return success()
140
141 def test_s3cmd(label, cmd_args = [], **kwargs):
142 if not cmd_args[0].endswith("s3cmd"):
9856527 Michael Ludvig * s3cmd, run-tests.py: Make it work on Windows.
mludvig authored
143 cmd_args.insert(0, "python")
144 cmd_args.insert(1, "s3cmd")
145
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
146 return test(label, cmd_args, **kwargs)
147
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
148 def test_mkdir(label, dir_name):
149 if os.name in ("posix", "nt"):
150 cmd = ['mkdir']
151 else:
152 print "Unknown platform: %s" % os.name
153 sys.exit(1)
154 cmd.append(dir_name)
155 return test(label, cmd)
156
157 def test_rmdir(label, dir_name):
158 if os.path.isdir(dir_name):
159 if os.name == "posix":
160 cmd = ['rm', '-rf']
161 elif os.name == "nt":
162 cmd = ['rmdir', '/s/q']
163 else:
164 print "Unknown platform: %s" % os.name
165 sys.exit(1)
166 cmd.append(dir_name)
167 return test(label, cmd)
168
3894a49 Michael Ludvig * run-tests.py: Updated paths for the new sync
mludvig authored
169 def test_flushdir(label, dir_name):
170 test_rmdir(label + "(rm)", dir_name)
171 return test_mkdir(label + "(mk)", dir_name)
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
172
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
173 bucket_prefix = ''
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
174 argv = sys.argv[1:]
175 while argv:
176 arg = argv.pop(0)
177 if arg in ("-h", "--help"):
178 print "%s A B K..O -N" % sys.argv[0]
179 print "Run tests number A, B and K through to O, except for N"
180 sys.exit(0)
181 if arg in ("-l", "--list"):
182 exclude_tests = range(0, 999)
183 break
3677a3b Michael Ludvig * run-tests.py: Added --verbose mode.
mludvig authored
184 if arg in ("-v", "--verbose"):
185 verbose = True
186 continue
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
187 if arg in ("-p", "--bucket-prefix"):
188 try:
189 bucket_prefix = argv.pop(0)
190 except IndexError:
191 print "Bucket prefix option must explicitly supply a bucket name prefix"
192 sys.exit(0)
193 continue
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
194 if arg.find("..") >= 0:
195 range_idx = arg.find("..")
196 range_start = arg[:range_idx] or 0
197 range_end = arg[range_idx+2:] or 999
198 run_tests.extend(range(int(range_start), int(range_end) + 1))
199 elif arg.startswith("-"):
200 exclude_tests.append(int(arg[1:]))
201 else:
202 run_tests.append(int(arg))
203
204 if not run_tests:
205 run_tests = range(0, 999)
206
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
207 # helper functions for generating bucket names
208 def bucket(tail):
209 '''Test bucket name'''
210 return '%ss3cmd-autotest-%s' % (bucket_prefix, tail)
211 def pbucket(tail):
212 '''Like bucket(), but prepends "s3://" for you'''
213 return 's3://' + bucket(tail)
214
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
215 ## ====== Remove test buckets
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
216 test_s3cmd("Remove test buckets", ['rb', '-r', pbucket(1), pbucket(2), pbucket(3)],
217 must_find = [ "Bucket '%s/' removed" % pbucket(1),
218 "Bucket '%s/' removed" % pbucket(2),
219 "Bucket '%s/' removed" % pbucket(3) ])
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
220
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
221
222 ## ====== Create one bucket (EU)
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
223 test_s3cmd("Create one bucket (EU)", ['mb', '--bucket-location=EU', pbucket(1)],
224 must_find = "Bucket '%s/' created" % pbucket(1))
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
225
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
226
227
228 ## ====== Create multiple buckets
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
229 test_s3cmd("Create multiple buckets", ['mb', pbucket(2), pbucket(3)],
230 must_find = [ "Bucket '%s/' created" % pbucket(2), "Bucket '%s/' created" % pbucket(3)])
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
231
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
232
233 ## ====== Invalid bucket name
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
234 test_s3cmd("Invalid bucket name", ["mb", "--bucket-location=EU", pbucket('EU')],
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
235 retcode = 1,
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
236 must_find = "ERROR: Parameter problem: Bucket name '%s' contains disallowed character" % bucket('EU'),
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
237 must_not_find_re = "Bucket.*created")
238
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
239
240 ## ====== Buckets list
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
241 test_s3cmd("Buckets list", ["ls"],
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
242 must_find = [ "autotest-1", "autotest-2", "autotest-3" ], must_not_find_re = "autotest-EU")
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
243
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
244
245 ## ====== Sync to S3
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
246 test_s3cmd("Sync to S3", ['sync', 'testsuite/', pbucket(1) + '/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ],
76ce644 Michael Ludvig * run-tests.py, testsuite/crappy-file-name.tar.gz:
mludvig authored
247 must_find = [ "WARNING: 32 non-printable characters replaced in: crappy-file-name/too-crappy ^A^B^C^D^E^F^G^H^I^J^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_^? +-[\]^<>%%\"'#{}`&?.end",
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
248 "stored as '%s/xyz/crappy-file-name/too-crappy ^A^B^C^D^E^F^G^H^I^J^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\^]^^^_^? +-[\\]^<>%%%%\"'#{}`&?.end'" % pbucket(1) ],
3894a49 Michael Ludvig * run-tests.py: Updated paths for the new sync
mludvig authored
249 must_not_find_re = [ "\.svn/", "\.png$" ])
4986ae8 Michael Ludvig * run-tests.py: Adapted to the above change.
mludvig authored
250
251 if have_encoding:
252 ## ====== Sync UTF-8 / GBK / ... to S3
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
253 test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, '%s/xyz/encodings/' % pbucket(1), '--exclude', '.svn/*', '--no-encrypt' ],
254 must_find = [ u"File 'testsuite/encodings/%(encoding)s/%(pattern)s' stored as '%(pbucket)s/xyz/encodings/%(encoding)s/%(pattern)s'" % { 'encoding' : encoding, 'pattern' : enc_pattern , 'pbucket' : pbucket(1)} ])
9856527 Michael Ludvig * s3cmd, run-tests.py: Make it work on Windows.
mludvig authored
255
256
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
257 ## ====== List bucket content
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
258 must_find_re = [ u"DIR %s/xyz/binary/$" % pbucket(1) , u"DIR %s/xyz/etc/$" % pbucket(1) ]
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
259 must_not_find = [ u"random-crap.md5", u".svn" ]
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
260 test_s3cmd("List bucket content", ['ls', '%s/xyz/' % pbucket(1) ],
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
261 must_find_re = must_find_re,
262 must_not_find = must_not_find)
9856527 Michael Ludvig * s3cmd, run-tests.py: Make it work on Windows.
mludvig authored
263
264
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
265 ## ====== List bucket recursive
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
266 must_find = [ u"%s/xyz/binary/random-crap.md5" % pbucket(1) ]
4986ae8 Michael Ludvig * run-tests.py: Adapted to the above change.
mludvig authored
267 if have_encoding:
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
268 must_find.append(u"%(pbucket)s/xyz/encodings/%(encoding)s/%(pattern)s" % { 'encoding' : encoding, 'pattern' : enc_pattern, 'pbucket' : pbucket(1) })
269 test_s3cmd("List bucket recursive", ['ls', '--recursive', pbucket(1)],
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
270 must_find = must_find,
271 must_not_find = [ "logo.png" ])
9856527 Michael Ludvig * s3cmd, run-tests.py: Make it work on Windows.
mludvig authored
272
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
273 ## ====== FIXME
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
274 # test_s3cmd("Recursive put", ['put', '--recursive', 'testsuite/etc', '%s/xyz/' % pbucket(1) ])
9856527 Michael Ludvig * s3cmd, run-tests.py: Make it work on Windows.
mludvig authored
275
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
276
3894a49 Michael Ludvig * run-tests.py: Updated paths for the new sync
mludvig authored
277 ## ====== Clean up local destination dir
278 test_flushdir("Clean testsuite-out/", "testsuite-out")
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
279
280
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
281 ## ====== Sync from S3
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
282 must_find = [ "File '%s/xyz/binary/random-crap.md5' stored as 'testsuite-out/xyz/binary/random-crap.md5'" % pbucket(1) ]
4986ae8 Michael Ludvig * run-tests.py: Adapted to the above change.
mludvig authored
283 if have_encoding:
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
284 must_find.append(u"File '%(pbucket)s/xyz/encodings/%(encoding)s/%(pattern)s' stored as 'testsuite-out/xyz/encodings/%(encoding)s/%(pattern)s' " % { 'encoding' : encoding, 'pattern' : enc_pattern, 'pbucket' : pbucket(1) })
285 test_s3cmd("Sync from S3", ['sync', '%s/xyz' % pbucket(1), 'testsuite-out'],
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
286 must_find = must_find)
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
287
288
3894a49 Michael Ludvig * run-tests.py: Updated paths for the new sync
mludvig authored
289 ## ====== Clean up local destination dir
290 test_flushdir("Clean testsuite-out/", "testsuite-out")
291
292
e3244a8 Michael Ludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
293 ## ====== Put public, guess MIME
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
294 test_s3cmd("Put public, guess MIME", ['put', '--guess-mime-type', '--acl-public', 'testsuite/etc/logo.png', '%s/xyz/etc/logo.png' % pbucket(1)],
295 must_find = [ "stored as '%s/xyz/etc/logo.png'" % pbucket(1) ])
e3244a8 Michael Ludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
296
297
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
298 ## ====== Retrieve from URL
299 if have_wget:
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
300 test("Retrieve from URL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.s3.amazonaws.com/xyz/etc/logo.png' % bucket(1)],
e3244a8 Michael Ludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
301 must_find_re = [ 'logo.png.*saved \[22059/22059\]' ])
302
303
304 ## ====== Change ACL to Private
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
305 test_s3cmd("Change ACL to Private", ['setacl', '--acl-private', '%s/xyz/etc/l*.png' % pbucket(1)],
e3244a8 Michael Ludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
306 must_find = [ "logo.png: ACL set to Private" ])
307
308
309 ## ====== Verify Private ACL
310 if have_wget:
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
311 test("Verify Private ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.s3.amazonaws.com/xyz/etc/logo.png' % bucket(1)],
e3244a8 Michael Ludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
312 retcode = 1,
313 must_find_re = [ 'ERROR 403: Forbidden' ])
314
315
316 ## ====== Change ACL to Public
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
317 test_s3cmd("Change ACL to Public", ['setacl', '--acl-public', '--recursive', '%s/xyz/etc/' % pbucket(1) , '-v'],
e3244a8 Michael Ludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
318 must_find = [ "logo.png: ACL set to Public" ])
319
320
321 ## ====== Verify Public ACL
322 if have_wget:
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
323 test("Verify Public ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.s3.amazonaws.com/xyz/etc/logo.png' % bucket(1)],
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
324 must_find_re = [ 'logo.png.*saved \[22059/22059\]' ])
325
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
326
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
327 ## ====== Sync more to S3
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
328 test_s3cmd("Sync more to S3", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no-encrypt' ],
4f8a35b Aaron Maxwell Test case for following symlinks (simplest case) (currently fails)
redsymbol authored
329 must_find = [ "File 'testsuite/.svn/entries' stored as '%s/xyz/.svn/entries' " % pbucket(1) ],
7b5df26 Aaron Maxwell Implementation of --follow-symlinks option (nonrecursive case)
redsymbol authored
330 must_not_find = [ "File 'testsuite/etc/linked.png' stored as '%s/xyz/etc/linked.png" % pbucket(1) ])
4f8a35b Aaron Maxwell Test case for following symlinks (simplest case) (currently fails)
redsymbol authored
331
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
332
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
333
334 ## ====== Rename within S3
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
335 test_s3cmd("Rename within S3", ['mv', '%s/xyz/etc/logo.png' % pbucket(1), '%s/xyz/etc2/Logo.PNG' % pbucket(1)],
336 must_find = [ 'File %s/xyz/etc/logo.png moved to %s/xyz/etc2/Logo.PNG' % (pbucket(1), pbucket(1))])
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
337
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
338
339 ## ====== Rename (NoSuchKey)
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
340 test_s3cmd("Rename (NoSuchKey)", ['mv', '%s/xyz/etc/logo.png' % pbucket(1), '%s/xyz/etc2/Logo.PNG' % pbucket(1)],
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
341 retcode = 1,
342 must_find_re = [ 'ERROR:.*NoSuchKey' ],
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
343 must_not_find = [ 'File %s/xyz/etc/logo.png moved to %s/xyz/etc2/Logo.PNG' % (pbucket(1), pbucket(1)) ])
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
344
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
345
257d632 Michael Ludvig * run-tests.py: Exit on failed test. Fixed order of tests.
mludvig authored
346 ## ====== Sync more from S3
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
347 test_s3cmd("Sync more from S3", ['sync', '--delete-removed', '%s/xyz' % pbucket(1), 'testsuite-out'],
3894a49 Michael Ludvig * run-tests.py: Updated paths for the new sync
mludvig authored
348 must_find = [ "deleted: testsuite-out/logo.png",
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
349 "File '%s/xyz/etc2/Logo.PNG' stored as 'testsuite-out/xyz/etc2/Logo.PNG' (22059 bytes" % pbucket(1),
350 "File '%s/xyz/.svn/entries' stored as 'testsuite-out/xyz/.svn/entries' " % pbucket(1) ],
257d632 Michael Ludvig * run-tests.py: Exit on failed test. Fixed order of tests.
mludvig authored
351 must_not_find_re = [ "not-deleted.*etc/logo.png" ])
352
353
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
354 ## ====== Make dst dir for get
355 test_rmdir("Remove dst dir for get", "testsuite-out")
356
357
358 ## ====== Get multiple files
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
359 test_s3cmd("Get multiple files", ['get', '%s/xyz/etc2/Logo.PNG' % pbucket(1), '%s/xyz/etc/AtomicClockRadio.ttf' % pbucket(1), 'testsuite-out'],
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
360 retcode = 1,
361 must_find = [ 'Destination must be a directory when downloading multiple sources.' ])
362
363
364 ## ====== Make dst dir for get
365 test_mkdir("Make dst dir for get", "testsuite-out")
366
367
368 ## ====== Get multiple files
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
369 test_s3cmd("Get multiple files", ['get', '%s/xyz/etc2/Logo.PNG' % pbucket(1), '%s/xyz/etc/AtomicClockRadio.ttf' % pbucket(1), 'testsuite-out'],
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
370 must_find = [ u"saved as 'testsuite-out/Logo.PNG'", u"saved as 'testsuite-out/AtomicClockRadio.ttf'" ])
371
dc1c96c Michael Ludvig 2009-05-27 Michal Ludvig <michal@logix.cz>
mludvig authored
372 ## ====== Upload files differing in capitalisation
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
373 test_s3cmd("blah.txt / Blah.txt", ['put', '-r', 'testsuite/blahBlah', pbucket(1)],
374 must_find = [ '%s/blahBlah/Blah.txt' % pbucket(1), '%s/blahBlah/blah.txt' % pbucket(1)])
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
375
e0b946c Michael Ludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
376 ## ====== Copy between buckets
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
377 test_s3cmd("Copy between buckets", ['cp', '%s/xyz/etc2/Logo.PNG' % pbucket(1), '%s/xyz/etc2/logo.png' % pbucket(3)],
378 must_find = [ "File %s/xyz/etc2/Logo.PNG copied to %s/xyz/etc2/logo.png" % (pbucket(1), pbucket(3)) ])
e0b946c Michael Ludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
379
380 ## ====== Recursive copy
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
381 test_s3cmd("Recursive copy, set ACL", ['cp', '-r', '--acl-public', '%s/xyz/' % pbucket(1), '%s/copy' % pbucket(2), '--exclude', '.svn/*', '--exclude', 'too-crappy*'],
382 must_find = [ "File %s/xyz/etc2/Logo.PNG copied to %s/copy/etc2/Logo.PNG" % (pbucket(1), pbucket(2)),
383 "File %s/xyz/blahBlah/Blah.txt copied to %s/copy/blahBlah/Blah.txt" % (pbucket(1), pbucket(2)),
384 "File %s/xyz/blahBlah/blah.txt copied to %s/copy/blahBlah/blah.txt" % (pbucket(1), pbucket(2)) ],
e0b946c Michael Ludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
385 must_not_find = [ ".svn" ])
386
8ab3c3a Aaron Maxwell Negative test for s3cmd put --follow-symlinks
redsymbol authored
387 ## ====== Don't Put symbolic link
6332b62 Aaron Maxwell More thorough and precise tests for --follow-symlinks
redsymbol authored
388 test_s3cmd("Don't put symbolic links", ['put', 'testsuite/etc/linked1.png', 's3://%s/xyz/' % bucket(1),],
8ab3c3a Aaron Maxwell Negative test for s3cmd put --follow-symlinks
redsymbol authored
389 must_not_find_re = [ "linked1.png"])
390
8c3bd02 Aaron Maxwell Test for s3cmd put --follow-symlinks
redsymbol authored
391 ## ====== Put symbolic link
392 test_s3cmd("Put symbolic links", ['put', 'testsuite/etc/linked1.png', 's3://%s/xyz/' % bucket(1),'--follow-symlinks' ],
6332b62 Aaron Maxwell More thorough and precise tests for --follow-symlinks
redsymbol authored
393 must_find = [ "File 'testsuite/etc/linked1.png' stored as '%s/xyz/linked1.png'" % pbucket(1)])
8c3bd02 Aaron Maxwell Test for s3cmd put --follow-symlinks
redsymbol authored
394
7b5df26 Aaron Maxwell Implementation of --follow-symlinks option (nonrecursive case)
redsymbol authored
395 ## ====== Sync symbolic links
396 test_s3cmd("Sync symbolic links", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no-encrypt', '--follow-symlinks' ],
6332b62 Aaron Maxwell More thorough and precise tests for --follow-symlinks
redsymbol authored
397 must_find = ["File 'testsuite/etc/linked.png' stored as '%s/xyz/etc/linked.png'" % pbucket(1),
398 "File 'testsuite/etc/more/give-me-more.txt' stored as '%s/xyz/etc/more/give-me-more.txt'" % pbucket(1)],
399 # Don't want to recursively copy linked directories!
400 must_not_find_re = ["etc/more/linked-dir/more/give-me-more.txt",
401 "etc/brokenlink.png"],
402 )
7b5df26 Aaron Maxwell Implementation of --follow-symlinks option (nonrecursive case)
redsymbol authored
403
e0b946c Michael Ludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
404 ## ====== Verify ACL and MIME type
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
405 test_s3cmd("Verify ACL and MIME type", ['info', '%s/copy/etc2/Logo.PNG' % pbucket(2) ],
e0b946c Michael Ludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
406 must_find_re = [ "MIME type:.*image/png",
407 "ACL:.*\*anon\*: READ",
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
408 "URL:.*http://%s.s3.amazonaws.com/copy/etc2/Logo.PNG" % bucket(2) ])
e0b946c Michael Ludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
409
410 ## ====== Multi source move
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
411 test_s3cmd("Multi-source move", ['mv', '-r', '%s/copy/blahBlah/Blah.txt' % pbucket(2), '%s/copy/etc/' % pbucket(2), '%s/moved/' % pbucket(2)],
412 must_find = [ "File %s/copy/blahBlah/Blah.txt moved to %s/moved/Blah.txt" % (pbucket(2), pbucket(2)),
413 "File %s/copy/etc/AtomicClockRadio.ttf moved to %s/moved/AtomicClockRadio.ttf" % (pbucket(2), pbucket(2)),
414 "File %s/copy/etc/TypeRa.ttf moved to %s/moved/TypeRa.ttf" % (pbucket(2), pbucket(2)) ],
e0b946c Michael Ludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
415 must_not_find = [ "blah.txt" ])
416
417 ## ====== Verify move
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
418 test_s3cmd("Verify move", ['ls', '-r', pbucket(2)],
419 must_find = [ "%s/moved/Blah.txt" % pbucket(2),
420 "%s/moved/AtomicClockRadio.ttf" % pbucket(2),
421 "%s/moved/TypeRa.ttf" % pbucket(2),
422 "%s/copy/blahBlah/blah.txt" % pbucket(2) ],
423 must_not_find = [ "%s/copy/blahBlah/Blah.txt" % pbucket(2),
424 "%s/copy/etc/AtomicClockRadio.ttf" % pbucket(2),
425 "%s/copy/etc/TypeRa.ttf" % pbucket(2) ])
e0b946c Michael Ludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
426
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
427 ## ====== Simple delete
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
428 test_s3cmd("Simple delete", ['del', '%s/xyz/etc2/Logo.PNG' % pbucket(1)],
429 must_find = [ "File %s/xyz/etc2/Logo.PNG deleted" % pbucket(1) ])
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
430
431
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
432 ## ====== Recursive delete
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
433 test_s3cmd("Recursive delete", ['del', '--recursive', '--exclude', 'Atomic*', '%s/xyz/etc' % pbucket(1)],
434 must_find = [ "File %s/xyz/etc/TypeRa.ttf deleted" % pbucket(1) ],
76ce644 Michael Ludvig * run-tests.py, testsuite/crappy-file-name.tar.gz:
mludvig authored
435 must_find_re = [ "File .*\.svn/entries deleted" ],
1ae39a8 Michael Ludvig * s3cmd, run-test.py, TODO, NEWS: Added --dry-run
mludvig authored
436 must_not_find = [ "AtomicClockRadio.ttf" ])
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
437
438 ## ====== Recursive delete all
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
439 test_s3cmd("Recursive delete all", ['del', '--recursive', '--force', pbucket(1)],
e5b4705 Michael Ludvig * run-tests.py: Fixed for new messages.
mludvig authored
440 must_find_re = [ "File .*binary/random-crap deleted" ])
f11319b Michael Ludvig * run-tests.py: Added a lot of new tests.
mludvig authored
441
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
442
443 ## ====== Remove empty bucket
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
444 test_s3cmd("Remove empty bucket", ['rb', pbucket(1)],
445 must_find = [ "Bucket '%s/' removed" % pbucket(1) ])
330c51e Michael Ludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
446
ca86524 Michael Ludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
447
448 ## ====== Remove remaining buckets
31fadab Aaron Maxwell Provide --bucket-prefix for run-tests.py
redsymbol authored
449 test_s3cmd("Remove remaining buckets", ['rb', '--recursive', pbucket(2), pbucket(3)],
450 must_find = [ "Bucket '%s/' removed" % pbucket(2),
451 "Bucket '%s/' removed" % pbucket(3) ])
Something went wrong with that request. Please try again.