...
|
...
|
@@ -98,8 +98,8 @@ def test(label, cmd_args = [], retcode = 0, must_find = [], must_not_find = [],
|
98
|
98
|
def failure(message = ""):
|
99
|
99
|
global count_fail
|
100
|
100
|
if message:
|
101
|
|
- message = " (%r)" % message
|
102
|
|
- print "\x1b[31;1mFAIL%s\x1b[0m" % (message)
|
|
101
|
+ message = u" (%r)" % message
|
|
102
|
+ print u"\x1b[31;1mFAIL%s\x1b[0m" % (message)
|
103
|
103
|
count_fail += 1
|
104
|
104
|
command_output()
|
105
|
105
|
#return 1
|
...
|
...
|
@@ -325,8 +325,8 @@ test_s3cmd("Sync to S3", ['sync', 'testsuite/', pbucket(1) + '/xyz/', '--exclude
|
325
|
325
|
|
326
|
326
|
if have_encoding:
|
327
|
327
|
## ====== Sync UTF-8 / GBK / ... to S3
|
328
|
|
- test_s3cmd("Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, '%s/xyz/encodings/' % pbucket(1), '--exclude', 'demo/*', '--no-encrypt' ],
|
329
|
|
- must_find = [ u"testsuite/encodings/%(encoding)s/%(pattern)s -> %(pbucket)s/xyz/encodings/%(encoding)s/%(pattern)s" % { 'encoding' : encoding, 'pattern' : enc_pattern , 'pbucket' : pbucket(1)} ])
|
|
328
|
+ test_s3cmd(u"Sync %s to S3" % encoding, ['sync', 'testsuite/encodings/' + encoding, '%s/xyz/encodings/' % pbucket(1), '--exclude', 'demo/*', '--no-encrypt' ],
|
|
329
|
+ must_find = [ u"'testsuite/encodings/%(encoding)s/%(pattern)s' -> '%(pbucket)s/xyz/encodings/%(encoding)s/%(pattern)s'" % { 'encoding' : encoding, 'pattern' : enc_pattern , 'pbucket' : pbucket(1)} ])
|
330
|
330
|
|
331
|
331
|
|
332
|
332
|
## ====== List bucket content
|
...
|
...
|
@@ -354,7 +354,7 @@ test_flushdir("Clean testsuite-out/", "testsuite-out")
|
354
|
354
|
## ====== Put from stdin
|
355
|
355
|
f = open('testsuite/single-file/single-file.txt', 'r')
|
356
|
356
|
test_s3cmd("Put from stdin", ['put', '-', '%s/single-file/single-file.txt' % pbucket(1)],
|
357
|
|
- must_find = ["<stdin> -> %s/single-file/single-file.txt" % pbucket(1)],
|
|
357
|
+ must_find = ["'-' -> '%s/single-file/single-file.txt'" % pbucket(1)],
|
358
|
358
|
stdin = f)
|
359
|
359
|
f.close()
|
360
|
360
|
|
...
|
...
|
@@ -375,9 +375,9 @@ f.close()
|
375
|
375
|
test_flushdir("Clean testsuite-out/", "testsuite-out")
|
376
|
376
|
|
377
|
377
|
## ====== Sync from S3
|
378
|
|
-must_find = [ "%s/xyz/binary/random-crap.md5 -> testsuite-out/xyz/binary/random-crap.md5" % pbucket(1) ]
|
|
378
|
+must_find = [ "'%s/xyz/binary/random-crap.md5' -> 'testsuite-out/xyz/binary/random-crap.md5'" % pbucket(1) ]
|
379
|
379
|
if have_encoding:
|
380
|
|
- must_find.append(u"%(pbucket)s/xyz/encodings/%(encoding)s/%(pattern)s -> testsuite-out/xyz/encodings/%(encoding)s/%(pattern)s " % { 'encoding' : encoding, 'pattern' : enc_pattern, 'pbucket' : pbucket(1) })
|
|
380
|
+ must_find.append(u"'%(pbucket)s/xyz/encodings/%(encoding)s/%(pattern)s' -> 'testsuite-out/xyz/encodings/%(encoding)s/%(pattern)s' " % { 'encoding' : encoding, 'pattern' : enc_pattern, 'pbucket' : pbucket(1) })
|
381
|
381
|
test_s3cmd("Sync from S3", ['sync', '%s/xyz' % pbucket(1), 'testsuite-out'],
|
382
|
382
|
must_find = must_find)
|
383
|
383
|
|
...
|
...
|
@@ -402,7 +402,7 @@ test_flushdir("Clean testsuite-out/", "testsuite-out")
|
402
|
402
|
|
403
|
403
|
## ====== Put public, guess MIME
|
404
|
404
|
test_s3cmd("Put public, guess MIME", ['put', '--guess-mime-type', '--acl-public', 'testsuite/etc/logo.png', '%s/xyz/etc/logo.png' % pbucket(1)],
|
405
|
|
- must_find = [ "-> %s/xyz/etc/logo.png" % pbucket(1) ])
|
|
405
|
+ must_find = [ "-> '%s/xyz/etc/logo.png'" % pbucket(1) ])
|
406
|
406
|
|
407
|
407
|
|
408
|
408
|
## ====== Retrieve from URL
|
...
|
...
|
@@ -436,8 +436,8 @@ if have_wget:
|
436
|
436
|
|
437
|
437
|
## ====== Sync more to S3
|
438
|
438
|
test_s3cmd("Sync more to S3", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no-encrypt' ],
|
439
|
|
- must_find = [ "testsuite/demo/some-file.xml -> %s/xyz/demo/some-file.xml " % pbucket(1) ],
|
440
|
|
- must_not_find = [ "testsuite/etc/linked.png -> %s/xyz/etc/linked.png" % pbucket(1) ],
|
|
439
|
+ must_find = [ "'testsuite/demo/some-file.xml' -> '%s/xyz/demo/some-file.xml' " % pbucket(1) ],
|
|
440
|
+ must_not_find = [ "'testsuite/etc/linked.png' -> '%s/xyz/etc/linked.png'" % pbucket(1) ],
|
441
|
441
|
retcode = EX_PARTIAL)
|
442
|
442
|
|
443
|
443
|
|
...
|
...
|
@@ -458,24 +458,24 @@ test_s3cmd("Check MD5", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no
|
458
|
458
|
|
459
|
459
|
## ====== Rename within S3
|
460
|
460
|
test_s3cmd("Rename within S3", ['mv', '%s/xyz/etc/logo.png' % pbucket(1), '%s/xyz/etc2/Logo.PNG' % pbucket(1)],
|
461
|
|
- must_find = [ 'File %s/xyz/etc/logo.png moved to %s/xyz/etc2/Logo.PNG' % (pbucket(1), pbucket(1))])
|
|
461
|
+ must_find = [ "move: '%s/xyz/etc/logo.png' -> '%s/xyz/etc2/Logo.PNG'" % (pbucket(1), pbucket(1))])
|
462
|
462
|
|
463
|
463
|
|
464
|
464
|
## ====== Rename (NoSuchKey)
|
465
|
465
|
test_s3cmd("Rename (NoSuchKey)", ['mv', '%s/xyz/etc/logo.png' % pbucket(1), '%s/xyz/etc2/Logo.PNG' % pbucket(1)],
|
466
|
466
|
retcode = EX_NOTFOUND,
|
467
|
467
|
must_find_re = [ 'Key not found' ],
|
468
|
|
- must_not_find = [ 'File %s/xyz/etc/logo.png moved to %s/xyz/etc2/Logo.PNG' % (pbucket(1), pbucket(1)) ])
|
|
468
|
+ must_not_find = [ "move: '%s/xyz/etc/logo.png' -> '%s/xyz/etc2/Logo.PNG'" % (pbucket(1), pbucket(1)) ])
|
469
|
469
|
|
470
|
470
|
## ====== Sync more from S3 (invalid src)
|
471
|
471
|
test_s3cmd("Sync more from S3 (invalid src)", ['sync', '--delete-removed', '%s/xyz/DOESNOTEXIST' % pbucket(1), 'testsuite-out'],
|
472
|
|
- must_not_find = [ "deleted: testsuite-out/logo.png" ])
|
|
472
|
+ must_not_find = [ "delete: 'testsuite-out/logo.png'" ])
|
473
|
473
|
|
474
|
474
|
## ====== Sync more from S3
|
475
|
475
|
test_s3cmd("Sync more from S3", ['sync', '--delete-removed', '%s/xyz' % pbucket(1), 'testsuite-out'],
|
476
|
|
- must_find = [ "deleted: testsuite-out/logo.png",
|
477
|
|
- "%s/xyz/etc2/Logo.PNG -> testsuite-out/xyz/etc2/Logo.PNG" % pbucket(1),
|
478
|
|
- "%s/xyz/demo/some-file.xml -> testsuite-out/xyz/demo/some-file.xml" % pbucket(1) ],
|
|
476
|
+ must_find = [ "delete: 'testsuite-out/logo.png'",
|
|
477
|
+ "'%s/xyz/etc2/Logo.PNG' -> 'testsuite-out/xyz/etc2/Logo.PNG'" % pbucket(1),
|
|
478
|
+ "'%s/xyz/demo/some-file.xml' -> 'testsuite-out/xyz/demo/some-file.xml'" % pbucket(1) ],
|
479
|
479
|
must_not_find_re = [ "not-deleted.*etc/logo.png" ])
|
480
|
480
|
|
481
|
481
|
|
...
|
...
|
@@ -506,8 +506,8 @@ test_s3cmd("Get unicode filenames", ['get', u'%s/xyz/encodings/UTF-8/ŪņЇЌœ
|
506
|
506
|
|
507
|
507
|
## ====== Get multiple files
|
508
|
508
|
test_s3cmd("Get multiple files", ['get', '%s/xyz/etc2/Logo.PNG' % pbucket(1), '%s/xyz/etc/AtomicClockRadio.ttf' % pbucket(1), 'testsuite-out'],
|
509
|
|
- must_find = [ u"-> testsuite-out/Logo.PNG",
|
510
|
|
- u"-> testsuite-out/AtomicClockRadio.ttf" ])
|
|
509
|
+ must_find = [ u"-> 'testsuite-out/Logo.PNG'",
|
|
510
|
+ u"-> 'testsuite-out/AtomicClockRadio.ttf'" ])
|
511
|
511
|
|
512
|
512
|
## ====== Upload files differing in capitalisation
|
513
|
513
|
test_s3cmd("blah.txt / Blah.txt", ['put', '-r', 'testsuite/blahBlah', pbucket(1)],
|
...
|
...
|
@@ -515,13 +515,13 @@ test_s3cmd("blah.txt / Blah.txt", ['put', '-r', 'testsuite/blahBlah', pbucket(1)
|
515
|
515
|
|
516
|
516
|
## ====== Copy between buckets
|
517
|
517
|
test_s3cmd("Copy between buckets", ['cp', '%s/xyz/etc2/Logo.PNG' % pbucket(1), '%s/xyz/etc2/logo.png' % pbucket(3)],
|
518
|
|
- must_find = [ "File %s/xyz/etc2/Logo.PNG copied to %s/xyz/etc2/logo.png" % (pbucket(1), pbucket(3)) ])
|
|
518
|
+ must_find = [ "remote copy: '%s/xyz/etc2/Logo.PNG' -> '%s/xyz/etc2/logo.png'" % (pbucket(1), pbucket(3)) ])
|
519
|
519
|
|
520
|
520
|
## ====== Recursive copy
|
521
|
521
|
test_s3cmd("Recursive copy, set ACL", ['cp', '-r', '--acl-public', '%s/xyz/' % pbucket(1), '%s/copy' % pbucket(2), '--exclude', 'demo/dir?/*.txt', '--exclude', 'non-printables*'],
|
522
|
|
- must_find = [ "File %s/xyz/etc2/Logo.PNG copied to %s/copy/etc2/Logo.PNG" % (pbucket(1), pbucket(2)),
|
523
|
|
- "File %s/xyz/blahBlah/Blah.txt copied to %s/copy/blahBlah/Blah.txt" % (pbucket(1), pbucket(2)),
|
524
|
|
- "File %s/xyz/blahBlah/blah.txt copied to %s/copy/blahBlah/blah.txt" % (pbucket(1), pbucket(2)) ],
|
|
522
|
+ must_find = [ "remote copy: '%s/xyz/etc2/Logo.PNG' -> '%s/copy/etc2/Logo.PNG'" % (pbucket(1), pbucket(2)),
|
|
523
|
+ "remote copy: '%s/xyz/blahBlah/Blah.txt' -> '%s/copy/blahBlah/Blah.txt'" % (pbucket(1), pbucket(2)),
|
|
524
|
+ "remote copy: '%s/xyz/blahBlah/blah.txt' -> '%s/copy/blahBlah/blah.txt'" % (pbucket(1), pbucket(2)) ],
|
525
|
525
|
must_not_find = [ "demo/dir1/file1-1.txt" ])
|
526
|
526
|
|
527
|
527
|
## ====== Verify ACL and MIME type
|
...
|
...
|
@@ -546,14 +546,14 @@ test_s3cmd("Verify ACL and MIME type", ['info', '%s/copy/etc2/Logo.PNG' % pbucke
|
546
|
546
|
"URL:.*http://%s.%s/copy/etc2/Logo.PNG" % (bucket(2), cfg.host_base) ])
|
547
|
547
|
|
548
|
548
|
test_s3cmd("Add cache-control header", ['modify', '--add-header=cache-control: max-age=3600, public', '%s/copy/etc2/Logo.PNG' % pbucket(2) ],
|
549
|
|
- must_find_re = [ "File .* modified" ])
|
|
549
|
+ must_find_re = [ "modify: .*" ])
|
550
|
550
|
|
551
|
551
|
if have_wget:
|
552
|
552
|
test_wget_HEAD("HEAD check Cache-Control present", 'http://%s.%s/copy/etc2/Logo.PNG' % (bucket(2), cfg.host_base),
|
553
|
553
|
must_find_re = [ "Cache-Control: max-age=3600" ])
|
554
|
554
|
|
555
|
555
|
test_s3cmd("Remove cache-control header", ['modify', '--remove-header=cache-control', '%s/copy/etc2/Logo.PNG' % pbucket(2) ],
|
556
|
|
- must_find_re = [ "File .* modified" ])
|
|
556
|
+ must_find_re = [ "modify: .*" ])
|
557
|
557
|
|
558
|
558
|
if have_wget:
|
559
|
559
|
test_wget_HEAD("HEAD check Cache-Control not present", 'http://%s.%s/copy/etc2/Logo.PNG' % (bucket(2), cfg.host_base),
|
...
|
...
|
@@ -566,13 +566,13 @@ test_s3cmd("signurl time offset", ['signurl', '%s/copy/etc2/Logo.PNG' % pbucket(
|
566
|
566
|
|
567
|
567
|
## ====== Rename within S3
|
568
|
568
|
test_s3cmd("Rename within S3", ['mv', '%s/copy/etc2/Logo.PNG' % pbucket(2), '%s/copy/etc/logo.png' % pbucket(2)],
|
569
|
|
- must_find = [ 'File %s/copy/etc2/Logo.PNG moved to %s/copy/etc/logo.png' % (pbucket(2), pbucket(2))])
|
|
569
|
+ must_find = [ "move: '%s/copy/etc2/Logo.PNG' -> '%s/copy/etc/logo.png'" % (pbucket(2), pbucket(2))])
|
570
|
570
|
|
571
|
571
|
## ====== Sync between buckets
|
572
|
572
|
test_s3cmd("Sync remote2remote", ['sync', '%s/xyz/' % pbucket(1), '%s/copy/' % pbucket(2), '--delete-removed', '--exclude', 'non-printables*'],
|
573
|
|
- must_find = [ "File %s/xyz/demo/dir1/file1-1.txt copied to %s/copy/demo/dir1/file1-1.txt" % (pbucket(1), pbucket(2)),
|
574
|
|
- "remote copy: etc/logo.png -> etc2/Logo.PNG",
|
575
|
|
- "File %s/copy/etc/logo.png deleted" % pbucket(2) ],
|
|
573
|
+ must_find = [ "remote copy: '%s/xyz/demo/dir1/file1-1.txt' -> '%s/copy/demo/dir1/file1-1.txt'" % (pbucket(1), pbucket(2)),
|
|
574
|
+ "remote copy: 'etc/logo.png' -> 'etc2/Logo.PNG'",
|
|
575
|
+ "delete: '%s/copy/etc/logo.png'" % pbucket(2) ],
|
576
|
576
|
must_not_find = [ "blah.txt" ])
|
577
|
577
|
|
578
|
578
|
## ====== Don't Put symbolic link
|
...
|
...
|
@@ -582,11 +582,11 @@ test_s3cmd("Don't put symbolic links", ['put', 'testsuite/etc/linked1.png', 's3:
|
582
|
582
|
|
583
|
583
|
## ====== Put symbolic link
|
584
|
584
|
test_s3cmd("Put symbolic links", ['put', 'testsuite/etc/linked1.png', 's3://%s/xyz/' % bucket(1),'--follow-symlinks' ],
|
585
|
|
- must_find = [ "testsuite/etc/linked1.png -> %s/xyz/linked1.png" % pbucket(1)])
|
|
585
|
+ must_find = [ "'testsuite/etc/linked1.png' -> '%s/xyz/linked1.png'" % pbucket(1)])
|
586
|
586
|
|
587
|
587
|
## ====== Sync symbolic links
|
588
|
588
|
test_s3cmd("Sync symbolic links", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket(1), '--no-encrypt', '--follow-symlinks' ],
|
589
|
|
- must_find = ["remote copy: etc2/Logo.PNG -> etc/linked.png"],
|
|
589
|
+ must_find = ["remote copy: 'etc2/Logo.PNG' -> 'etc/linked.png'"],
|
590
|
590
|
# Don't want to recursively copy linked directories!
|
591
|
591
|
must_not_find_re = ["etc/more/linked-dir/more/give-me-more.txt",
|
592
|
592
|
"etc/brokenlink.png"],
|
...
|
...
|
@@ -594,9 +594,9 @@ test_s3cmd("Sync symbolic links", ['sync', 'testsuite/', 's3://%s/xyz/' % bucket
|
594
|
594
|
|
595
|
595
|
## ====== Multi source move
|
596
|
596
|
test_s3cmd("Multi-source move", ['mv', '-r', '%s/copy/blahBlah/Blah.txt' % pbucket(2), '%s/copy/etc/' % pbucket(2), '%s/moved/' % pbucket(2)],
|
597
|
|
- must_find = [ "File %s/copy/blahBlah/Blah.txt moved to %s/moved/Blah.txt" % (pbucket(2), pbucket(2)),
|
598
|
|
- "File %s/copy/etc/AtomicClockRadio.ttf moved to %s/moved/AtomicClockRadio.ttf" % (pbucket(2), pbucket(2)),
|
599
|
|
- "File %s/copy/etc/TypeRa.ttf moved to %s/moved/TypeRa.ttf" % (pbucket(2), pbucket(2)) ],
|
|
597
|
+ must_find = [ "move: '%s/copy/blahBlah/Blah.txt' -> '%s/moved/Blah.txt'" % (pbucket(2), pbucket(2)),
|
|
598
|
+ "move: '%s/copy/etc/AtomicClockRadio.ttf' -> '%s/moved/AtomicClockRadio.ttf'" % (pbucket(2), pbucket(2)),
|
|
599
|
+ "move: '%s/copy/etc/TypeRa.ttf' -> '%s/moved/TypeRa.ttf'" % (pbucket(2), pbucket(2)) ],
|
600
|
600
|
must_not_find = [ "blah.txt" ])
|
601
|
601
|
|
602
|
602
|
## ====== Verify move
|
...
|
...
|
@@ -615,11 +615,11 @@ test_s3cmd("List all", ['la'],
|
615
|
615
|
|
616
|
616
|
## ====== Simple delete
|
617
|
617
|
test_s3cmd("Simple delete", ['del', '%s/xyz/etc2/Logo.PNG' % pbucket(1)],
|
618
|
|
- must_find = [ "File %s/xyz/etc2/Logo.PNG deleted" % pbucket(1) ])
|
|
618
|
+ must_find = [ "delete: '%s/xyz/etc2/Logo.PNG'" % pbucket(1) ])
|
619
|
619
|
|
620
|
620
|
## ====== Simple delete with rm
|
621
|
621
|
test_s3cmd("Simple delete with rm", ['rm', '%s/xyz/test_rm/TypeRa.ttf' % pbucket(1)],
|
622
|
|
- must_find = [ "File %s/xyz/test_rm/TypeRa.ttf deleted" % pbucket(1) ])
|
|
622
|
+ must_find = [ "delete: '%s/xyz/test_rm/TypeRa.ttf'" % pbucket(1) ])
|
623
|
623
|
|
624
|
624
|
## ====== Create expiration rule with days and prefix
|
625
|
625
|
test_s3cmd("Create expiration rule with days and prefix", ['expire', pbucket(1), '--expiry-days=365', '--expiry-prefix=log/'],
|
...
|
...
|
@@ -664,23 +664,23 @@ test_s3cmd("Get requester pays flag", ['info', pbucket(2)],
|
664
|
664
|
|
665
|
665
|
## ====== Recursive delete maximum exceeed
|
666
|
666
|
test_s3cmd("Recursive delete maximum exceeded", ['del', '--recursive', '--max-delete=1', '--exclude', 'Atomic*', '%s/xyz/etc' % pbucket(1)],
|
667
|
|
- must_not_find = [ "File %s/xyz/etc/TypeRa.ttf deleted" % pbucket(1) ])
|
|
667
|
+ must_not_find = [ "delete: '%s/xyz/etc/TypeRa.ttf'" % pbucket(1) ])
|
668
|
668
|
|
669
|
669
|
## ====== Recursive delete
|
670
|
670
|
test_s3cmd("Recursive delete", ['del', '--recursive', '--exclude', 'Atomic*', '%s/xyz/etc' % pbucket(1)],
|
671
|
|
- must_find = [ "File %s/xyz/etc/TypeRa.ttf deleted" % pbucket(1) ],
|
672
|
|
- must_find_re = [ "File .*/etc/logo.png deleted" ],
|
|
671
|
+ must_find = [ "delete: '%s/xyz/etc/TypeRa.ttf'" % pbucket(1) ],
|
|
672
|
+ must_find_re = [ "delete: '.*/etc/logo.png'" ],
|
673
|
673
|
must_not_find = [ "AtomicClockRadio.ttf" ])
|
674
|
674
|
|
675
|
675
|
## ====== Recursive delete with rm
|
676
|
676
|
test_s3cmd("Recursive delete with rm", ['rm', '--recursive', '--exclude', 'Atomic*', '%s/xyz/test_rm' % pbucket(1)],
|
677
|
|
- must_find = [ "File %s/xyz/test_rm/more/give-me-more.txt deleted" % pbucket(1) ],
|
678
|
|
- must_find_re = [ "File .*/test_rm/logo.png deleted" ],
|
|
677
|
+ must_find = [ "delete: '%s/xyz/test_rm/more/give-me-more.txt'" % pbucket(1) ],
|
|
678
|
+ must_find_re = [ "delete: '.*/test_rm/logo.png'" ],
|
679
|
679
|
must_not_find = [ "AtomicClockRadio.ttf" ])
|
680
|
680
|
|
681
|
681
|
## ====== Recursive delete all
|
682
|
682
|
test_s3cmd("Recursive delete all", ['del', '--recursive', '--force', pbucket(1)],
|
683
|
|
- must_find_re = [ "File .*binary/random-crap deleted" ])
|
|
683
|
+ must_find_re = [ "delete: '.*binary/random-crap'" ])
|
684
|
684
|
|
685
|
685
|
## ====== Remove empty bucket
|
686
|
686
|
test_s3cmd("Remove empty bucket", ['rb', pbucket(1)],
|