зеркало из https://github.com/nextcloud/desktop.git
Add a new test script to check for big file chunking.
This commit is contained in:
Родитель
57c59850e1
Коммит
a759c93fb6
|
@ -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) = @_;
|
||||
|
|
|
@ -145,8 +145,6 @@ assertLocalAndRemoteDir( 'fromLocal1', 0);
|
|||
assert( -e localDir().'remoteToLocal1/rtlX' );
|
||||
assert( -e localDir().'remoteToLocal1/rtlX/rtl11/file.txt' );
|
||||
|
||||
|
||||
|
||||
# ==================================================================
|
||||
|
||||
cleanup();
|
||||
|
|
|
@ -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@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();
|
||||
|
||||
# --
|
Загрузка…
Ссылка в новой задаче