[Pkg-owncloud-commits] [owncloud-client] 232/332: tx.pl: Add a chunking update test, test for precondition failed.

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:07:04 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 8d85516e726bbfc625fbb2cbeebcc0cf311fa28f
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Tue Jul 22 18:07:34 2014 +0200

    tx.pl: Add a chunking update test, test for precondition failed.
---
 csync/tests/ownCloud/t6.pl | 47 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/csync/tests/ownCloud/t6.pl b/csync/tests/ownCloud/t6.pl
index b93de0f..66019fe 100755
--- a/csync/tests/ownCloud/t6.pl
+++ b/csync/tests/ownCloud/t6.pl
@@ -33,6 +33,34 @@ print "Hello, this is t6, a tester for csync with ownCloud.\n";
 
 initTesting();
 
+sub createPostUpdateScript()
+{
+    my $srcFile = localDir()."BIG.file";
+    my $cred = configValue("user") . ":" . configValue("passwd");
+    my $cmd = "curl -T $srcFile -u $cred " . testDirUrl();
+    my $script = "/tmp/post_update_script.sh";
+    open SC, ">$script" || die("Can not create script file");
+    print SC "#!/bin/bash\n";
+    print SC "$cmd\n";
+    close SC;
+    chmod 0755, $script;
+
+    return $script;
+}
+
+sub getETagFromJournal($)
+{
+    my ($num) = @_;
+    
+    my $sql = "sqlite3 " . localDir() . ".csync_journal.db \"SELECT md5 FROM metadata WHERE path='BIG.file';\"";
+    open(my $fh, '-|', $sql) or die $!;
+    my $etag  = <$fh>;
+    close $fh;
+    print "$num etag: $etag";
+
+    return $etag;
+}
+
 sub chunkFileTest( $$ ) 
 {
     my ($name, $size) = @_;
@@ -63,10 +91,27 @@ sub chunkFileTest( $$ )
 printInfo("Big file that needs chunking with default chunk size");
 chunkFileTest( "BIG.file", 23251233 );
 
+printInfo("Update the existing file and trigger reupload");
 # change the existing file again -> update
 chunkFileTest( "BIG.file", 21762122 );
 
- # Set a custom chunk size in environment.
+printInfo("Cause a precondition failed error");
+# Now overwrite the existing file to change it
+createLocalFile( localDir()."BIG.file", 21832199 );
+# and create a post update script
+my $script = createPostUpdateScript();
+$ENV{'OWNCLOUD_POST_UPDATE_SCRIPT'} = $script;
+
+# Save the etag before the sync
+my $firstETag = getETagFromJournal('First');
+csync(); # Sync, which ends in a precondition failed error 
+# get the etag again. It has to be unchanged because of the error.
+my $secondETag = getETagFromJournal('Second');
+assert( $firstETag eq $secondETag, "Different ETags, no precondition error." );
+
+unlink($script);
+
+# Set a custom chunk size in environment.
 my $ChunkSize = 1*1024*1024;
 $ENV{'OWNCLOUD_CHUNK_SIZE'} = $ChunkSize;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list