Skip to content
Newer
Older
100755 457 lines (356 sloc) 17.1 KB
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
1 #!/usr/bin/env python
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
2 # -*- coding=utf-8 -*-
330c51e @mludvig * 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 @mludvig * s3cmd, run-tests.py: Make it work on Windows.
mludvig authored
10 import os
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
11 import re
12 from subprocess import Popen, PIPE, STDOUT
f891a81 @mludvig * run-tests.py: Don't assume utf-8, use preferred encoding
mludvig authored
13 import locale
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
14
15 count_pass = 0
16 count_fail = 0
ca86524 @mludvig * 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 @mludvig * run-tests.py: Added --verbose mode.
mludvig authored
23 verbose = False
24
ca86524 @mludvig * 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 @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
32
4986ae8 @mludvig * 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 @mludvig * s3cmd: Reworked internal handling of unicode vs encoded filenames.
mludvig authored
42 else:
43 print "System encoding: " + encoding
4986ae8 @mludvig * 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 @mludvig * 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 @mludvig * 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 @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
51 #enc_base_remote = "%s/xyz/%s/" % (pbucket(1), encoding)
4986ae8 @mludvig * run-tests.py: Adapted to the above change.
mludvig authored
52 enc_pattern = patterns[encoding]
5f7a2d5 @mludvig * s3cmd: Reworked internal handling of unicode vs encoded filenames.
mludvig authored
53 else:
54 print encoding + " specific files not found."
4986ae8 @mludvig * run-tests.py: Adapted to the above change.
mludvig authored
55
76ce644 @mludvig * 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 @mludvig * 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 @mludvig * 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 @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
69 def failure(message = ""):
70 global count_fail
71 if message:
f891a81 @mludvig * run-tests.py: Don't assume utf-8, use preferred encoding
mludvig authored
72 message = " (%r)" % message
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
73 print "\x1b[31;1mFAIL%s\x1b[0m" % (message)
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
74 count_fail += 1
3677a3b @mludvig * run-tests.py: Added --verbose mode.
mludvig authored
75 command_output()
257d632 @mludvig * run-tests.py: Exit on failed test. Fixed order of tests.
mludvig authored
76 #return 1
77 sys.exit(1)
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
78 def success(message = ""):
79 global count_pass
80 if message:
f891a81 @mludvig * run-tests.py: Don't assume utf-8, use preferred encoding
mludvig authored
81 message = " (%r)" % message
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
82 print "\x1b[32;1mOK\x1b[0m%s" % (message)
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
83 count_pass += 1
3677a3b @mludvig * run-tests.py: Added --verbose mode.
mludvig authored
84 if verbose:
85 command_output()
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
86 return 0
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
87 def skip(message = ""):
88 global count_skip
89 if message:
f891a81 @mludvig * run-tests.py: Don't assume utf-8, use preferred encoding
mludvig authored
90 message = " (%r)" % message
ca86524 @mludvig * 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 @mludvig * 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 @mludvig * run-tests.py: Adapted to the above change.
mludvig authored
99 _list = [re.escape(item.encode(encoding, "replace")) for item in _list]
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
100
ca86524 @mludvig * 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 @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
106 sys.stdout.flush()
107
ca86524 @mludvig * 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 @mludvig * 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 @mludvig * 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 @mludvig * 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 @mludvig * 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 @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
129
f11319b @mludvig * 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 @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
132 if not match:
f11319b @mludvig * 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 @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
136 if match:
f11319b @mludvig * 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 @mludvig * run-tests.py: Added --verbose mode.
mludvig authored
138
330c51e @mludvig * 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 @mludvig * 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 @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
146 return test(label, cmd_args, **kwargs)
147
ca86524 @mludvig * 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 @mludvig * 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 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
172
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
173 bucket_prefix = ''
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
174 argv = sys.argv[1:]
175 while argv:
176 arg = argv.pop(0)
136c28e @redsymbol Guard against common error when using --bucket-prefix
redsymbol authored
177 if arg.startswith('--bucket-prefix='):
178 print "Usage: '--bucket-prefix PREFIX', not '--bucket-prefix=PREFIX'"
179 sys.exit(0)
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
180 if arg in ("-h", "--help"):
181 print "%s A B K..O -N" % sys.argv[0]
182 print "Run tests number A, B and K through to O, except for N"
183 sys.exit(0)
184 if arg in ("-l", "--list"):
185 exclude_tests = range(0, 999)
186 break
3677a3b @mludvig * run-tests.py: Added --verbose mode.
mludvig authored
187 if arg in ("-v", "--verbose"):
188 verbose = True
189 continue
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
190 if arg in ("-p", "--bucket-prefix"):
191 try:
192 bucket_prefix = argv.pop(0)
193 except IndexError:
194 print "Bucket prefix option must explicitly supply a bucket name prefix"
195 sys.exit(0)
196 continue
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
197 if arg.find("..") >= 0:
198 range_idx = arg.find("..")
199 range_start = arg[:range_idx] or 0
200 range_end = arg[range_idx+2:] or 999
201 run_tests.extend(range(int(range_start), int(range_end) + 1))
202 elif arg.startswith("-"):
203 exclude_tests.append(int(arg[1:]))
204 else:
205 run_tests.append(int(arg))
206
207 if not run_tests:
208 run_tests = range(0, 999)
209
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
210 # helper functions for generating bucket names
211 def bucket(tail):
212 '''Test bucket name'''
2895644 @redsymbol use Autotest-3, not autotest-3
redsymbol authored
213 label = 'autotest'
214 if str(tail) == '3':
215 label = 'Autotest'
216 return '%ss3cmd-%s-%s' % (bucket_prefix, label, tail)
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
217 def pbucket(tail):
218 '''Like bucket(), but prepends "s3://" for you'''
219 return 's3://' + bucket(tail)
220
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
221 ## ====== Remove test buckets
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
222 test_s3cmd("Remove test buckets", ['rb', '-r', pbucket(1), pbucket(2), pbucket(3)],
223 must_find = [ "Bucket '%s/' removed" % pbucket(1),
224 "Bucket '%s/' removed" % pbucket(2),
225 "Bucket '%s/' removed" % pbucket(3) ])
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
226
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
227
228 ## ====== Create one bucket (EU)
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
229 test_s3cmd("Create one bucket (EU)", ['mb', '--bucket-location=EU', pbucket(1)],
230 must_find = "Bucket '%s/' created" % pbucket(1))
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
231
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
232
233
234 ## ====== Create multiple buckets
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
235 test_s3cmd("Create multiple buckets", ['mb', pbucket(2), pbucket(3)],
236 must_find = [ "Bucket '%s/' created" % pbucket(2), "Bucket '%s/' created" % pbucket(3)])
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
237
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
238
239 ## ====== Invalid bucket name
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
240 test_s3cmd("Invalid bucket name", ["mb", "--bucket-location=EU", pbucket('EU')],
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
241 retcode = 1,
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
242 must_find = "ERROR: Parameter problem: Bucket name '%s' contains disallowed character" % bucket('EU'),
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
243 must_not_find_re = "Bucket.*created")
244
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
245
246 ## ====== Buckets list
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
247 test_s3cmd("Buckets list", ["ls"],
2895644 @redsymbol use Autotest-3, not autotest-3
redsymbol authored
248 must_find = [ "autotest-1", "autotest-2", "Autotest-3" ], must_not_find_re = "autotest-EU")
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
249
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
250
251 ## ====== Sync to S3
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
252 test_s3cmd("Sync to S3", ['sync', 'testsuite/', pbucket(1) + '/xyz/', '--exclude', '.svn/*', '--exclude', '*.png', '--no-encrypt', '--exclude-from', 'testsuite/exclude.encodings' ],
76ce644 @mludvig * run-tests.py, testsuite/crappy-file-name.tar.gz:
mludvig authored
253 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 @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
254 "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 @mludvig * run-tests.py: Updated paths for the new sync
mludvig authored
255 must_not_find_re = [ "\.svn/", "\.png$" ])
4986ae8 @mludvig * run-tests.py: Adapted to the above change.
mludvig authored
256
257 if have_encoding:
258 ## ====== Sync UTF-8 / GBK / ... to S3
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
259 test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, '%s/xyz/encodings/' % pbucket(1), '--exclude', '.svn/*', '--no-encrypt' ],
260 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 @mludvig * s3cmd, run-tests.py: Make it work on Windows.
mludvig authored
261
262
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
263 ## ====== List bucket content
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
264 must_find_re = [ u"DIR %s/xyz/binary/$" % pbucket(1) , u"DIR %s/xyz/etc/$" % pbucket(1) ]
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
265 must_not_find = [ u"random-crap.md5", u".svn" ]
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
266 test_s3cmd("List bucket content", ['ls', '%s/xyz/' % pbucket(1) ],
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
267 must_find_re = must_find_re,
268 must_not_find = must_not_find)
9856527 @mludvig * s3cmd, run-tests.py: Make it work on Windows.
mludvig authored
269
270
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
271 ## ====== List bucket recursive
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
272 must_find = [ u"%s/xyz/binary/random-crap.md5" % pbucket(1) ]
4986ae8 @mludvig * run-tests.py: Adapted to the above change.
mludvig authored
273 if have_encoding:
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
274 must_find.append(u"%(pbucket)s/xyz/encodings/%(encoding)s/%(pattern)s" % { 'encoding' : encoding, 'pattern' : enc_pattern, 'pbucket' : pbucket(1) })
275 test_s3cmd("List bucket recursive", ['ls', '--recursive', pbucket(1)],
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
276 must_find = must_find,
277 must_not_find = [ "logo.png" ])
9856527 @mludvig * s3cmd, run-tests.py: Make it work on Windows.
mludvig authored
278
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
279 ## ====== FIXME
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
280 # test_s3cmd("Recursive put", ['put', '--recursive', 'testsuite/etc', '%s/xyz/' % pbucket(1) ])
9856527 @mludvig * s3cmd, run-tests.py: Make it work on Windows.
mludvig authored
281
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
282
3894a49 @mludvig * run-tests.py: Updated paths for the new sync
mludvig authored
283 ## ====== Clean up local destination dir
284 test_flushdir("Clean testsuite-out/", "testsuite-out")
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
285
286
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
287 ## ====== Sync from S3
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
288 must_find = [ "File '%s/xyz/binary/random-crap.md5' stored as 'testsuite-out/xyz/binary/random-crap.md5'" % pbucket(1) ]
4986ae8 @mludvig * run-tests.py: Adapted to the above change.
mludvig authored
289 if have_encoding:
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
290 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) })
291 test_s3cmd("Sync from S3", ['sync', '%s/xyz' % pbucket(1), 'testsuite-out'],
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
292 must_find = must_find)
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
293
294
3894a49 @mludvig * run-tests.py: Updated paths for the new sync
mludvig authored
295 ## ====== Clean up local destination dir
296 test_flushdir("Clean testsuite-out/", "testsuite-out")
297
298
e3244a8 @mludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
299 ## ====== Put public, guess MIME
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
300 test_s3cmd("Put public, guess MIME", ['put', '--guess-mime-type', '--acl-public', 'testsuite/etc/logo.png', '%s/xyz/etc/logo.png' % pbucket(1)],
301 must_find = [ "stored as '%s/xyz/etc/logo.png'" % pbucket(1) ])
e3244a8 @mludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
302
303
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
304 ## ====== Retrieve from URL
305 if have_wget:
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
306 test("Retrieve from URL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.s3.amazonaws.com/xyz/etc/logo.png' % bucket(1)],
e3244a8 @mludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
307 must_find_re = [ 'logo.png.*saved \[22059/22059\]' ])
308
309
310 ## ====== Change ACL to Private
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
311 test_s3cmd("Change ACL to Private", ['setacl', '--acl-private', '%s/xyz/etc/l*.png' % pbucket(1)],
e3244a8 @mludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
312 must_find = [ "logo.png: ACL set to Private" ])
313
314
315 ## ====== Verify Private ACL
316 if have_wget:
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
317 test("Verify Private ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.s3.amazonaws.com/xyz/etc/logo.png' % bucket(1)],
e3244a8 @mludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
318 retcode = 1,
319 must_find_re = [ 'ERROR 403: Forbidden' ])
320
321
322 ## ====== Change ACL to Public
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
323 test_s3cmd("Change ACL to Public", ['setacl', '--acl-public', '--recursive', '%s/xyz/etc/' % pbucket(1) , '-v'],
e3244a8 @mludvig * S3/ACL.py: Move attributes from class to instance.
mludvig authored
324 must_find = [ "logo.png: ACL set to Public" ])
325
326
327 ## ====== Verify Public ACL
328 if have_wget:
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
329 test("Verify Public ACL", ['wget', '-O', 'testsuite-out/logo.png', 'http://%s.s3.amazonaws.com/xyz/etc/logo.png' % bucket(1)],
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
330 must_find_re = [ 'logo.png.*saved \[22059/22059\]' ])
331
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
332
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
333 ## ====== Sync more to S3
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
334 test_s3cmd("Sync more to S3", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no-encrypt' ],
4f8a35b @redsymbol Test case for following symlinks (simplest case) (currently fails)
redsymbol authored
335 must_find = [ "File 'testsuite/.svn/entries' stored as '%s/xyz/.svn/entries' " % pbucket(1) ],
7b5df26 @redsymbol Implementation of --follow-symlinks option (nonrecursive case)
redsymbol authored
336 must_not_find = [ "File 'testsuite/etc/linked.png' stored as '%s/xyz/etc/linked.png" % pbucket(1) ])
4f8a35b @redsymbol Test case for following symlinks (simplest case) (currently fails)
redsymbol authored
337
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
338
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
339
340 ## ====== Rename within S3
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
341 test_s3cmd("Rename within S3", ['mv', '%s/xyz/etc/logo.png' % pbucket(1), '%s/xyz/etc2/Logo.PNG' % pbucket(1)],
342 must_find = [ 'File %s/xyz/etc/logo.png moved to %s/xyz/etc2/Logo.PNG' % (pbucket(1), pbucket(1))])
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
343
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
344
345 ## ====== Rename (NoSuchKey)
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
346 test_s3cmd("Rename (NoSuchKey)", ['mv', '%s/xyz/etc/logo.png' % pbucket(1), '%s/xyz/etc2/Logo.PNG' % pbucket(1)],
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
347 retcode = 1,
348 must_find_re = [ 'ERROR:.*NoSuchKey' ],
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
349 must_not_find = [ 'File %s/xyz/etc/logo.png moved to %s/xyz/etc2/Logo.PNG' % (pbucket(1), pbucket(1)) ])
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
350
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
351
257d632 @mludvig * run-tests.py: Exit on failed test. Fixed order of tests.
mludvig authored
352 ## ====== Sync more from S3
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
353 test_s3cmd("Sync more from S3", ['sync', '--delete-removed', '%s/xyz' % pbucket(1), 'testsuite-out'],
3894a49 @mludvig * run-tests.py: Updated paths for the new sync
mludvig authored
354 must_find = [ "deleted: testsuite-out/logo.png",
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
355 "File '%s/xyz/etc2/Logo.PNG' stored as 'testsuite-out/xyz/etc2/Logo.PNG' (22059 bytes" % pbucket(1),
356 "File '%s/xyz/.svn/entries' stored as 'testsuite-out/xyz/.svn/entries' " % pbucket(1) ],
257d632 @mludvig * run-tests.py: Exit on failed test. Fixed order of tests.
mludvig authored
357 must_not_find_re = [ "not-deleted.*etc/logo.png" ])
358
359
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
360 ## ====== Make dst dir for get
361 test_rmdir("Remove dst dir for get", "testsuite-out")
362
363
364 ## ====== Get multiple files
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
365 test_s3cmd("Get multiple files", ['get', '%s/xyz/etc2/Logo.PNG' % pbucket(1), '%s/xyz/etc/AtomicClockRadio.ttf' % pbucket(1), 'testsuite-out'],
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
366 retcode = 1,
367 must_find = [ 'Destination must be a directory when downloading multiple sources.' ])
368
369
370 ## ====== Make dst dir for get
371 test_mkdir("Make dst dir for get", "testsuite-out")
372
373
374 ## ====== Get multiple files
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
375 test_s3cmd("Get multiple files", ['get', '%s/xyz/etc2/Logo.PNG' % pbucket(1), '%s/xyz/etc/AtomicClockRadio.ttf' % pbucket(1), 'testsuite-out'],
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
376 must_find = [ u"saved as 'testsuite-out/Logo.PNG'", u"saved as 'testsuite-out/AtomicClockRadio.ttf'" ])
377
dc1c96c @mludvig 2009-05-27 Michal Ludvig <michal@logix.cz>
mludvig authored
378 ## ====== Upload files differing in capitalisation
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
379 test_s3cmd("blah.txt / Blah.txt", ['put', '-r', 'testsuite/blahBlah', pbucket(1)],
380 must_find = [ '%s/blahBlah/Blah.txt' % pbucket(1), '%s/blahBlah/blah.txt' % pbucket(1)])
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
381
e0b946c @mludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
382 ## ====== Copy between buckets
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
383 test_s3cmd("Copy between buckets", ['cp', '%s/xyz/etc2/Logo.PNG' % pbucket(1), '%s/xyz/etc2/logo.png' % pbucket(3)],
384 must_find = [ "File %s/xyz/etc2/Logo.PNG copied to %s/xyz/etc2/logo.png" % (pbucket(1), pbucket(3)) ])
e0b946c @mludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
385
386 ## ====== Recursive copy
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
387 test_s3cmd("Recursive copy, set ACL", ['cp', '-r', '--acl-public', '%s/xyz/' % pbucket(1), '%s/copy' % pbucket(2), '--exclude', '.svn/*', '--exclude', 'too-crappy*'],
388 must_find = [ "File %s/xyz/etc2/Logo.PNG copied to %s/copy/etc2/Logo.PNG" % (pbucket(1), pbucket(2)),
389 "File %s/xyz/blahBlah/Blah.txt copied to %s/copy/blahBlah/Blah.txt" % (pbucket(1), pbucket(2)),
390 "File %s/xyz/blahBlah/blah.txt copied to %s/copy/blahBlah/blah.txt" % (pbucket(1), pbucket(2)) ],
e0b946c @mludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
391 must_not_find = [ ".svn" ])
392
8ab3c3a @redsymbol Negative test for s3cmd put --follow-symlinks
redsymbol authored
393 ## ====== Don't Put symbolic link
6332b62 @redsymbol More thorough and precise tests for --follow-symlinks
redsymbol authored
394 test_s3cmd("Don't put symbolic links", ['put', 'testsuite/etc/linked1.png', 's3://%s/xyz/' % bucket(1),],
8ab3c3a @redsymbol Negative test for s3cmd put --follow-symlinks
redsymbol authored
395 must_not_find_re = [ "linked1.png"])
396
8c3bd02 @redsymbol Test for s3cmd put --follow-symlinks
redsymbol authored
397 ## ====== Put symbolic link
398 test_s3cmd("Put symbolic links", ['put', 'testsuite/etc/linked1.png', 's3://%s/xyz/' % bucket(1),'--follow-symlinks' ],
6332b62 @redsymbol More thorough and precise tests for --follow-symlinks
redsymbol authored
399 must_find = [ "File 'testsuite/etc/linked1.png' stored as '%s/xyz/linked1.png'" % pbucket(1)])
8c3bd02 @redsymbol Test for s3cmd put --follow-symlinks
redsymbol authored
400
7b5df26 @redsymbol Implementation of --follow-symlinks option (nonrecursive case)
redsymbol authored
401 ## ====== Sync symbolic links
402 test_s3cmd("Sync symbolic links", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no-encrypt', '--follow-symlinks' ],
e3d232e @redsymbol correct error in test
redsymbol authored
403 must_find = ["File 'testsuite/etc/linked.png' stored as '%s/xyz/etc/linked.png'" % pbucket(1)],
6332b62 @redsymbol More thorough and precise tests for --follow-symlinks
redsymbol authored
404 # Don't want to recursively copy linked directories!
405 must_not_find_re = ["etc/more/linked-dir/more/give-me-more.txt",
406 "etc/brokenlink.png"],
407 )
7b5df26 @redsymbol Implementation of --follow-symlinks option (nonrecursive case)
redsymbol authored
408
e0b946c @mludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
409 ## ====== Verify ACL and MIME type
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
410 test_s3cmd("Verify ACL and MIME type", ['info', '%s/copy/etc2/Logo.PNG' % pbucket(2) ],
e0b946c @mludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
411 must_find_re = [ "MIME type:.*image/png",
412 "ACL:.*\*anon\*: READ",
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
413 "URL:.*http://%s.s3.amazonaws.com/copy/etc2/Logo.PNG" % bucket(2) ])
e0b946c @mludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
414
415 ## ====== Multi source move
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
416 test_s3cmd("Multi-source move", ['mv', '-r', '%s/copy/blahBlah/Blah.txt' % pbucket(2), '%s/copy/etc/' % pbucket(2), '%s/moved/' % pbucket(2)],
417 must_find = [ "File %s/copy/blahBlah/Blah.txt moved to %s/moved/Blah.txt" % (pbucket(2), pbucket(2)),
418 "File %s/copy/etc/AtomicClockRadio.ttf moved to %s/moved/AtomicClockRadio.ttf" % (pbucket(2), pbucket(2)),
419 "File %s/copy/etc/TypeRa.ttf moved to %s/moved/TypeRa.ttf" % (pbucket(2), pbucket(2)) ],
e0b946c @mludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
420 must_not_find = [ "blah.txt" ])
421
422 ## ====== Verify move
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
423 test_s3cmd("Verify move", ['ls', '-r', pbucket(2)],
424 must_find = [ "%s/moved/Blah.txt" % pbucket(2),
425 "%s/moved/AtomicClockRadio.ttf" % pbucket(2),
426 "%s/moved/TypeRa.ttf" % pbucket(2),
427 "%s/copy/blahBlah/blah.txt" % pbucket(2) ],
428 must_not_find = [ "%s/copy/blahBlah/Blah.txt" % pbucket(2),
429 "%s/copy/etc/AtomicClockRadio.ttf" % pbucket(2),
430 "%s/copy/etc/TypeRa.ttf" % pbucket(2) ])
e0b946c @mludvig * s3cmd: Support for recursive [cp] and [mv], including
mludvig authored
431
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
432 ## ====== Simple delete
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
433 test_s3cmd("Simple delete", ['del', '%s/xyz/etc2/Logo.PNG' % pbucket(1)],
434 must_find = [ "File %s/xyz/etc2/Logo.PNG deleted" % pbucket(1) ])
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
435
436
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
437 ## ====== Recursive delete
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
438 test_s3cmd("Recursive delete", ['del', '--recursive', '--exclude', 'Atomic*', '%s/xyz/etc' % pbucket(1)],
439 must_find = [ "File %s/xyz/etc/TypeRa.ttf deleted" % pbucket(1) ],
76ce644 @mludvig * run-tests.py, testsuite/crappy-file-name.tar.gz:
mludvig authored
440 must_find_re = [ "File .*\.svn/entries deleted" ],
1ae39a8 @mludvig * s3cmd, run-test.py, TODO, NEWS: Added --dry-run
mludvig authored
441 must_not_find = [ "AtomicClockRadio.ttf" ])
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
442
443 ## ====== Recursive delete all
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
444 test_s3cmd("Recursive delete all", ['del', '--recursive', '--force', pbucket(1)],
e5b4705 @mludvig * run-tests.py: Fixed for new messages.
mludvig authored
445 must_find_re = [ "File .*binary/random-crap deleted" ])
f11319b @mludvig * run-tests.py: Added a lot of new tests.
mludvig authored
446
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
447
448 ## ====== Remove empty bucket
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
449 test_s3cmd("Remove empty bucket", ['rb', pbucket(1)],
450 must_find = [ "Bucket '%s/' removed" % pbucket(1) ])
330c51e @mludvig * testsuite, run-tests.py: Added testsuite with first few tests.
mludvig authored
451
ca86524 @mludvig * run-tests.py: Improved testsuite, added parameters support
mludvig authored
452
453 ## ====== Remove remaining buckets
31fadab @redsymbol Provide --bucket-prefix for run-tests.py
redsymbol authored
454 test_s3cmd("Remove remaining buckets", ['rb', '--recursive', pbucket(2), pbucket(3)],
455 must_find = [ "Bucket '%s/' removed" % pbucket(2),
456 "Bucket '%s/' removed" % pbucket(3) ])
Something went wrong with that request. Please try again.