[Pkg-owncloud-commits] [owncloud-client] 302/333: Add a new test script to check for big file chunking.

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:17:07 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 a759c93fb67349a014de328182eb8ac8d215c245
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Fri Apr 4 16:33:25 2014 +0200

    Add a new test script to check for big file chunking.
---
 csync/tests/ownCloud/ownCloud/Test.pm | 25 ++++++++++++--
 csync/tests/ownCloud/t1.pl            |  2 --
 csync/tests/ownCloud/t6.pl            | 61 +++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/csync/tests/ownCloud/ownCloud/Test.pm b/csync/tests/ownCloud/ownCloud/Test.pm
index 69468b4..84e509d 100644
--- a/csync/tests/ownCloud/ownCloud/Test.pm
+++ b/csync/tests/ownCloud/ownCloud/Test.pm
@@ -32,7 +32,7 @@ use Digest::MD5;
 use Unicode::Normalize;
 use LWP::UserAgent;
 use LWP::Protocol::https;
-use HTTP::Request::Common qw( POST  DELETE );
+use HTTP::Request::Common qw( POST GET DELETE );
 use File::Basename;
 
 use Encode qw(from_to);
@@ -65,7 +65,7 @@ our %config;
                   putToDirLWP localDir remoteDir localCleanup createLocalFile md5OfFile
                   remoteCleanup server initLocalDir initRemoteDir moveRemoteFile
                   printInfo remoteFileId createShare removeShare
-                  configValue testDirUrl);
+                  configValue testDirUrl getToFileLWP);
 
 sub server
 {
@@ -530,6 +530,27 @@ sub putToDirLWP($$)
     }
 }
 
+# does a simple GET of a file in the testdir to a local file.
+sub getToFileLWP( $$ )
+{
+    my ($file, $localFile) = @_;
+    my $geturl = testDirUrl() . $file;
+    print "GETting $geturl to $localFile\n";
+
+    my $ua  = LWP::UserAgent->new();
+    $ua->agent( "ownCloudTest_$localDir");
+    # my $req = $ua->get($geturl, ":content_file" => $localFile);
+    my $req = HTTP::Request->new( GET => $geturl );
+    $req->authorization_basic("$user", "$passwd");
+    my $response = $ua->request($req);
+
+    if ($response->is_success()) {
+      print "OK: ", $response->content;
+    } else {
+      die( "HTTP GET failed: " . $response->as_string );
+    }
+}
+
 sub createLocalFile( $$ ) 
 {
   my ($fname, $size) = @_;
diff --git a/csync/tests/ownCloud/t1.pl b/csync/tests/ownCloud/t1.pl
index f14860f..8a578a8 100755
--- a/csync/tests/ownCloud/t1.pl
+++ b/csync/tests/ownCloud/t1.pl
@@ -145,8 +145,6 @@ assertLocalAndRemoteDir( 'fromLocal1', 0);
 assert( -e localDir().'remoteToLocal1/rtlX' );
 assert( -e localDir().'remoteToLocal1/rtlX/rtl11/file.txt' );
 
-
-
 # ==================================================================
 
 cleanup();
diff --git a/csync/tests/ownCloud/t6.pl b/csync/tests/ownCloud/t6.pl
new file mode 100755
index 0000000..73e9e1b
--- /dev/null
+++ b/csync/tests/ownCloud/t6.pl
@@ -0,0 +1,61 @@
+#!/usr/bin/perl
+#
+# Test script for the ownCloud module of csync.
+# This script requires a running ownCloud instance accessible via HTTP.
+# It does quite some fancy tests and asserts the results.
+#
+# Copyright (C) by Klaas Freitag <freitag at owncloud.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+use lib ".";
+
+use Carp::Assert;
+use File::Copy;
+use ownCloud::Test;
+
+use strict;
+
+print "Hello, this is t6, a tester for csync with ownCloud.\n";
+
+initTesting();
+
+# Big file chunking
+printInfo( "Do a big file that is chunked");
+createLocalFile( localDir().'BIG.file', 22272592 );
+assert( -e localDir().'BIG.file' );
+my $bigMd5 = md5OfFile( localDir().'BIG.file' );
+
+csync();
+my $newMd5 = md5OfFile( localDir().'BIG.file' );
+assert( $newMd5 eq $bigMd5 );
+
+# download
+my $ctrlFile = "/tmp/file.download";
+getToFileLWP( 'BIG.file', $ctrlFile );
+
+assert( -e $ctrlFile, "File does not exist!" );
+
+# assert files
+my $dlMd5 = md5OfFile( $ctrlFile );
+assert( $dlMd5 eq $newMd5 );
+
+
+# ==================================================================
+
+cleanup();
+
+# --

-- 
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