Remove old test scripts

Fixes: 7679
This commit is contained in:
Hannah von Reth 2020-02-03 14:23:09 +01:00 committed by Kevin Ottens
parent 466e8abc91
commit e08645f259
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
32 changed files with 0 additions and 9179 deletions

View file

@ -1,48 +0,0 @@
Torture for ownCloud Client
===========================
This is a set of scripts comprising of two parts:
* ``torture_gen_layout.pl``: Generation of layout files (random)
* ``torture_create_files.pl``: Generation of a real file tree based on the
layout files (deterministic)
These scripts allow a data set to be produced with the following criteria:
* realistic in naming
* realistic in file size
* realistic in structural size
without checking in the actual data. Instead, a layout file that gets generated
once (reference.lay) is checked in. This makes it possible to produce
standardized benchmarks for mirall. It allows checking for files gone
missing in action and other kinds of corruption produced during sync runs.
``torture_create_files.pl`` can be fine tuned via variables in the script
header. It sources its file names from ``dict`` wordlist, file extensions and
other parameters can be added as needed. The defaults should be reasonable
in terms of size.
The ``references/`` directory contains default folder layouts.
Usage
-----
In order to create a reference layout and create a tree from it::
./torture_gen_layout.pl > reference.lay
./torture_create_files.pl reference.lay <targetdir>
TODO
----
* Based on the layout file, write a validator that checks files for existence
and size without requiring a full reference tree to be created via
``./torture_gen_layout.pl``.
* The current file naming is fairly tame (i.e. almost within ASCII range).
Extending it randomly is dangerous, we first need to filter all
characters forbidden by various OSes. Or maybe not, because we want to
see what happens? :-). Anyway, you have been warned.

File diff suppressed because it is too large Load diff

View file

@ -1,37 +0,0 @@
#!/usr/bin/env perl
#
# Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License
# for more details.
#
use strict;
use File::Path qw(make_path);
use File::Basename qw(dirname);
if (scalar @ARGV < 2) {
print "Usage: $0 input.lay <offsetdir>\n";
exit;
}
my ($file, $offset_dir) = @ARGV;
open FILE, "<", $file or die $!;
while (<FILE>) {
my ($fillfile, $size) = split(/:/, $_);
$fillfile = $offset_dir . '/' . $fillfile;
my $dir = dirname $fillfile;
if (!-d $dir) { make_path $dir; }
open FILLFILE, ">", $fillfile;
print "writing $fillfile with $size bytes\n...";
print FILLFILE 0x01 x $size;
close FILLFILE;
}

View file

@ -1,85 +0,0 @@
#!/usr/bin/env perl
#
# Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License
# for more details.
#
use strict;
use Data::Random::WordList;
############################################################################
# Which extensions to randomly assign
my @exts = ('txt', 'pdf', 'html', 'docx', 'xlsx', 'pptx', 'odt', 'ods', 'odp');
# Maximum depth of the target structure
my $depth = 4;
# Maximum amount of subfolders within a folder
my $max_subfolder = 10;
# Maximum amount of files within a folder
my $max_files_per_folder = 100;
# Maximum file size
my $max_file_size = 1024**2;
############################################################################
sub gen_entries($)
{
my ($count) = @_;
my $wl = new Data::Random::WordList( wordlist => '/usr/share/dict/words' );
my @rand_words = $wl->get_words($count);
foreach(@rand_words) {
$_ =~ s/\'//g;
}
$wl->close();
return @rand_words;
}
sub create_subdir($)
{
my ($depth) = @_;
$depth--;
my %dir_tree = ( );
my @dirs = gen_entries(int(rand($max_subfolders)));
my @files = gen_entries(int(rand($max_files_per_folder)));
foreach my $file(@files) {
$dir_tree{$file} = int(rand($max_file_size));
}
if ($depth > 0) {
foreach my $dir(@dirs) {
$dir_tree{$dir} = create_subdir($depth);
}
}
return \%dir_tree;
}
sub create_dir_listing(@)
{
my ($tree, $prefix) = @_;
foreach my $key(keys %$tree) {
my $entry = $tree->{$key};
#print "$entry:".scalar $entry.":".ref $entry."\n";
if (ref $entry eq "HASH") {
create_dir_listing($tree->{$key}, "$prefix/$key");
} else {
my $ext = @exts[rand @exts];
print "$prefix/$key.$ext:$entry\n";
}
}
}
srand();
my $dir = create_subdir($depth);
create_dir_listing($dir, '.');

View file

@ -1 +0,0 @@
t1.cfg

View file

@ -1,32 +0,0 @@
t1 - an integration test script for csync syncing to ownCloud.
Note: This test script uses perl HTTP::DAV. This package needs to
be in version 0.47 at least. Many distros deliver older versions.
t1 uses a perl WebDAV client lib to sync to an existing instance of
ownCloud. For that, various files are copied around, synced and the
results are tested through their existance, the filesize and the
modification times. All tests are asserts, which means that the
scripts stops if a test fails.
How to call:
First, configure the script. For that, create a file t1.cfg. There
is t1.cfg.in as an example. Yeah, this test script is not secure,
make sure to run it with a weak account and in a save environment.
To start the script, call ./t1.pl on the commandline. A lot of
output is generated. If the script does not fail, everything works.
Before it actually ends, it takes a four seconds break for you to
interrupt with Ctrl-C. If you don't do that, it removes all its
traces...
If SSL should be used, SSL must be available to LWP connections. To
disable host checking for crappy SSL certs, do
export PERL_LWP_SSL_VERIFY_HOSTNAME=0
Have fun,
Klaas Freitag <freitag@owncloud.com>

View file

@ -1,3 +0,0 @@
*.part
]*.directory

View file

@ -1,803 +0,0 @@
#
# Copyright (c) 2013 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
#
################################################################
# Contributors:
# Klaas Freitag <freitag@owncloud.com>
#
package ownCloud::Test;
use strict;
use Exporter;
use HTTP::DAV 0.47;
use Data::Dumper;
use File::Glob ':glob';
use Digest::MD5;
use Unicode::Normalize;
use LWP::UserAgent;
use LWP::Protocol::https;
use HTTP::Request::Common qw( POST GET DELETE );
use File::Basename;
use IO::Handle;
use POSIX qw/strftime/;
use Carp;
use Encode qw(from_to);
use utf8;
if ($^O eq "darwin") {
eval "require Encode::UTF8Mac";
}
use open ':encoding(utf8)';
use vars qw( @ISA @EXPORT @EXPORT_OK $d %config);
our $owncloud = "http://localhost/oc/remote.php/webdav/";
our $owncloud_plain; # the server url without the uniq testing dir
our $user = "joe";
our $passwd = 'XXXXX'; # Mind to be secure.
our $ld_libpath = "/home/joe/owncloud.com/buildcsync/modules";
our $csync = "/home/joe/owncloud.com/buildcsync/client/ocsync";
our $ocs_url;
our $share_user;
our $share_passwd;
our $remoteDir;
our $localDir;
our $infoCnt = 1;
our %config;
@ISA = qw(Exporter);
@EXPORT = qw( initTesting createRemoteDir removeRemoteDir createLocalDir cleanup csync
assertLocalDirs assertLocalAndRemoteDir glob_put put_to_dir
putToDirLWP localDir remoteDir localCleanup createLocalFile md5OfFile
remoteCleanup server initLocalDir initRemoteDir moveRemoteFile
printInfo remoteFileProp remoteFileId createShare removeShare assert
configValue testDirUrl getToFileLWP getToFileCurl);
sub server
{
return $owncloud;
}
sub fromFileName($)
{
my ($file) = @_;
if ( $^O eq "darwin" ) {
my $fromFileName = NFC( Encode::decode('utf-8', $file) );
return $fromFileName;
} else {
return $file;
}
}
sub setCredentials
{
my ($dav, $user, $passwd) = @_;
$dav->credentials(-url=> $owncloud, -realm=>"sabre/dav",
-user=> $user, -pass=> $passwd);
$dav->credentials(-url=> $owncloud, -realm=>"ownCloud",
-user=> $user, -pass=> $passwd);
}
sub initTesting(;$)
{
my ($prefix) = @_;
my $cfgFile = "./t1.cfg";
$cfgFile = "/etc/ownCloud/t1.cfg" if( -r "/etc/ownCloud/t1.cfg" );
if( -r "$cfgFile" ) {
%config = do $cfgFile;
warn "Could not parse t1.cfg: $!\n" unless %config;
warn "Could not do t1.cfg: $@\n" if $@;
$user = $config{user} if( $config{user} );
$passwd = $config{passwd} if( $config{passwd} );
$owncloud = $config{url} if( $config{url} );
$ld_libpath = $config{ld_libpath} if( $config{ld_libpath} );
$csync = $config{csync} if( $config{csync} );
$ocs_url = $config{ocs_url} if( $config{ocs_url} );
$share_user = $config{share_user} if( $config{share_user} );
$share_passwd = $config{share_passwd} if( $config{share_passwd} );
print "Read config from $cfgFile: $config{url}\n";
} else {
print STDERR "Could not read a config file $cfgFile\n";
exit(1);
}
$owncloud .= "/" unless( $owncloud =~ /\/$/ );
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
print "Connecting to ownCloud at ". $owncloud ."\n";
# For SSL set the environment variable needed by the LWP module for SSL
if( $owncloud =~ /^https/ ) {
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0
}
my $ua = HTTP::DAV::UserAgent->new(keep_alive => 1 );
$d = HTTP::DAV->new(-useragent => $ua);
setCredentials($d, $user, $passwd);
# $d->DebugLevel(3);
$prefix = "t1" unless( defined $prefix );
my $dirId = sprintf("%02d", rand(100));
my $dateTime = strftime('%Y%m%d%H%M%S',localtime);
my $dir = sprintf( "%s-%s-%s/", $prefix, $dateTime, $dirId );
$localDir = $dir;
$localDir .= "/" unless( $localDir =~ /\/$/ );
$remoteDir = $dir;
initRemoteDir();
initLocalDir();
printf( "Test directory name is %s\n", $dir );
}
sub configValue($;$)
{
my ($configName, $default) = @_;
if( $config{$configName} ) {
return $config{$configName} ;
} else {
return $default;
}
}
# Returns the full url to the testing dir, ie.
# http://localhost/owncloud/remote.php/webdav/t1-0543
sub testDirUrl()
{
print "WARN: Remote dir still empty, first call initRemoteDir!\n" unless($remoteDir);
return $owncloud . $remoteDir;
}
# Call this first to create the unique test dir stored in
# the global var $remoteDir;
sub initRemoteDir
{
$d->open( $owncloud )
or die("Couldn't open $owncloud: " .$d->message . "\n");
my $url = testDirUrl();
my $re = $d->mkcol( $url );
if( $re == 0 ) {
print "Failed to create test dir $url\n";
exit 1;
}
}
sub initLocalDir
{
mkdir ($localDir, 0777 );
}
sub removeRemoteDir($;$)
{
my ($dir, $optionsRef) = @_;
my $url = testDirUrl() . $dir;
if( $optionsRef && $optionsRef->{user} && $optionsRef->{passwd} ) {
setCredentials($d, $optionsRef->{user}, $optionsRef->{passwd});
if( $optionsRef->{url} ) {
$url = $optionsRef->{url} . $dir;
}
}
$d->open( $owncloud );
print $d->message . "\n";
my $re = $d->delete( $url );
if( $re == 0 ) {
print "Failed to remove directory <$url>:" . $d->message() ."\n";
}
return $re;
}
sub createRemoteDir(;$$)
{
my ($dir, $optionsRef) = @_;
my $url = testDirUrl() . $dir;
if( $optionsRef && $optionsRef->{user} && $optionsRef->{passwd} ) {
setCredentials($d, $optionsRef->{user}, $optionsRef->{passwd});
if( $optionsRef->{url} ) {
$url = $optionsRef->{url} . $dir;
}
}
$d->open( $owncloud );
print $d->message . "\n";
my $re = $d->mkcol( $url );
if( $re == 0 ) {
print "Failed to create directory <$url>: " . $d->message() ."\n";
exit 1;
}
$d->open( $url );
return $re;
}
sub createLocalDir($)
{
my ($dir) = (@_);
$dir = $localDir . $dir;
print "Creating local dir: $dir\n";
mkdir( $dir, 0777 );
}
sub cleanup()
{
# ==================================================================
print "\n################################################\n";
printf( " all cool - %d tests succeeded in %s.\n", $infoCnt-1, $remoteDir);
print "#################################################\n";
print "\nInterrupt before cleanup in 4 seconds...\n";
sleep(4);
remoteCleanup( '' );
localCleanup( '' );
}
sub remoteCleanup($)
{
my ($dir) = @_;
my $url = testDirUrl().$dir;
$d->open( -url => $url );
print "Cleaning Remote!\n";
my $re = $d->delete( $url );
if( $re == 0 ) {
print "Failed to cleanup directory <$url>\n";
}
return $re;
}
sub localCleanup($)
{
my ($dir) = @_;
# don't play child games here:
$dir = "$localDir/$dir";
system( "rm -rf $dir" );
}
# parameter: the expected return code
sub csync( ;$ )
{
my $expected = $_[0] // 0;
my $url = testDirUrl();
if( $url =~ /^https:/ ) {
$url =~ s#^https://##; # Remove the leading http://
$url = "ownclouds://$user:$passwd@". $url;
} elsif( $url =~ /^http:/ ) {
$url =~ s#^http://##;
$url = "owncloud://$user:$passwd@". $url;
}
print "CSync URL: $url\n";
my $args = "--trust --exclude exclude.cfg"; # Trust crappy SSL certificates
my $cmd = "LD_LIBRARY_PATH=$ld_libpath $csync $args $localDir $url";
print "Starting: $cmd\n";
my $result = system( $cmd );
$result == ($expected << 8) or die("Wrong csync return code or crash! $result\n");
}
#
# Check local directories if they have the same content.
#
sub assertLocalDirs( $$ )
{
my ($dir1, $dir2) = @_;
print "Asserting $dir1 <-> $dir2\n";
opendir(my $dh, $dir1 ) || die;
while(readdir $dh) {
assert( -e "$dir2/$_", " $dir2/$_ do not exist" );
next if( -d "$dir1/$_"); # don't compare directory sizes.
my $s1 = -s "$dir1/$_";
my $s2 = -s "$dir2/$_";
assert( $s1 == $s2, "$dir1/$_ <-> $dir2/$_ size not equal ($s1 != $s2)" );
}
closedir $dh;
}
sub localDir()
{
return $localDir;
}
sub remoteDir()
{
return $remoteDir;
}
#
# Check if a local and a remote dir have the same content
#
sub assertFile($$)
{
my ($localFile, $res) = @_;
print "Asserting $localFile and " . $res->get_property("rel_uri") . "\n";
my $remoteModTime = $res->get_property( "lastmodifiedepoch" ) ;
my $localFile2 = $localFile;
if ($^O eq "darwin") {
from_to($localFile2, 'utf-8-mac', 'utf-8');
}
my $stat_ok = stat( $localFile2 );
print " *** STAT failed for $localFile2\n" unless( $stat_ok );
assert($stat_ok, "Stat failed for file $localFile");
my @info = stat( $localFile2 );
my $localModTime = $info[9];
assert( $remoteModTime == $localModTime, "Modified-Times differ: remote: $remoteModTime <-> local: $localModTime" );
print "local versuse Remote modtime: $localModTime <-> $remoteModTime\n";
# check for the same file size
my $localSize = $info[7];
my $remoteSize = $res->get_property( "getcontentlength" );
if( $remoteSize ) { # directories do not have a contentlength
print "Local versus Remote size: $localSize <-> $remoteSize\n";
# assert( $localSize == $remoteSize, "File sizes differ" ); # FIXME enable this again but it causes trouble on Jenkins all the time.
}
}
sub registerSeen($$)
{
my ($seenRef, $file) = @_;
$seenRef->{$file} = 1;
}
sub traverse( $$;$ )
{
my ($remote, $acceptConflicts, $aurl) = @_;
$remote .= '/' unless $remote =~ /(^|\/)$/;
my $url = testDirUrl() . $remote;
if( $aurl ) {
$url = $aurl . $remote;
}
printf("===============> $url\n");
my %seen;
setCredentials($d, $user, $passwd);
$d->open( $owncloud );
if( my $r = $d->propfind( -url => $url, -depth => 1 ) ) {
if( $r->get_resourcelist ) {
foreach my $res ( $r->get_resourcelist->get_resources() ) {
my $filename = $res->get_property("rel_uri");
if( $res->is_collection ) {
# print "Checking " . $res-> get_uri()->as_string ."\n";
print "Traversing into directory: $filename\n";
my $dirname = $remote . $filename;
traverse( $dirname, $acceptConflicts, $aurl );
my $localDirName = $localDir . $dirname;
$localDirName =~ s/Shared\///g;
registerSeen( \%seen, $localDirName); # . $dirname
} else {
# Check files here.
print "Checking file: $remote$filename\n";
my $localFile = $localDir . $remote . $filename;
$localFile =~ s/Shared\///g;
registerSeen( \%seen, $localFile );
# $localFile =~ s/t1-\d+\//t1\//;
assertFile( $localFile, $res );
}
}
}
} else {
print "Propfind failed: " . $d->message() . "\n";
}
# Check the directory contents
my $localpath = localDir();
$localpath .= $remote if( $remote ne "/" );
$localpath =~ s/Shared\///g;
print "#### localpath = " . $localpath . "\n";
opendir(my $dh, $localpath ) || die;
# print Dumper( %seen );
while( readdir $dh ) {
next if( /^\.+$/ );
my $f = $localpath . fromFileName($_);
chomp $f;
assert( -e $f );
my $isHere = undef;
if( exists $seen{$f} ) {
$isHere = 1;
$seen{$f} = 2;
}
if( !$isHere && exists $seen{$f . "/"} ) {
$isHere = 1;
$seen{$f."/"} = 3;
}
$isHere = 1 if( $acceptConflicts && !$isHere && $f =~ /conflicted copy/ );
$isHere = 1 if( $f =~ /\.csync/ );
$isHere = 1 if( $f =~ /\.sync_/ );
assert( $isHere, "Filename local, but not remote: $f" );
}
# Check if there was something remote that we havent locally.
foreach my $f ( keys %seen ) {
assert( $seen{$f} > 1, "File on remote, but not locally: $f " . $seen{$f} );
}
# print Dumper %seen;
print "<================ Done $remote\n";
closedir $dh;
}
sub assertLocalAndRemoteDir( $$;$ )
{
my ($remote, $acceptConflicts, $aurl ) = @_;
traverse( $remote, $acceptConflicts, $aurl );
}
#
# the third parameter is an optional hash ref that can contain
# the keys user, passwd and url for alternative connection settings
#
sub glob_put( $$;$ )
{
my( $globber, $target, $optionsRef ) = @_;
my @puts = bsd_glob( $globber );
foreach my $llfile( @puts ) {
my $lfile = fromFileName($llfile);
if( $lfile =~ /.*\/(.+)$/g ) {
my $rfile = $1;
my $puturl = "$target"."$rfile";
if( -d $lfile ) {
$d->mkcol( $puturl );
} else {
$lfile = $llfile;
$puturl = $target;
print " *** Putting $lfile to $puturl\n";
# putToDirLWP( $lfile, $puturl );
put_to_dir($lfile, $puturl, $optionsRef);
# if( ! $d->put( -local=>$lfile, -url=> $puturl ) ) {
#print " ### FAILED to put: ". $d->message . '\n';
# s}
}
}
}
}
sub put_to_dir( $$;$ )
{
my ($file, $dir, $optionsRef) = @_;
$dir .="/" unless $dir =~ /\/$/;
my $targetUrl = testDirUrl();
if( $optionsRef && $optionsRef->{user} && $optionsRef->{passwd} ) {
setCredentials($d, $optionsRef->{user}, $optionsRef->{passwd});
if( $optionsRef->{url} ) {
$targetUrl = $optionsRef->{url};
}
}
$d->open($targetUrl . $dir);
my $filename = $file;
$filename =~ s/^.*\///;
$filename =~ s/#/%23/g; # poor man's URI encoder
my $puturl = $targetUrl . $dir. $filename;
print "put_to_dir puts to $puturl\n";
unless ($d->put( -local => $file, -url => $puturl )) {
print " ### FAILED to put a single file!\n";
}
}
# The HTTP DAV module often does a PROPFIND before it really PUTs. That
# is not neccessary if we know that the directory is really there.
# Use this function in this case:
sub putToDirLWP($$)
{
my ($file, $dir) = @_;
$dir .="/" unless $dir =~ /\/$/;
my $filename = $file;
my $basename = basename $filename;
$dir =~ s/^\.\///;
my $puturl = testDirUrl() . $dir. $basename;
# print "putToDir LWP puts $filename to $puturl\n";
die("Could not open $filename: $!") unless( open FILE, "$filename" );
binmode FILE, ":utf8";;
my $string = <FILE>;
close FILE;
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 });
$ua->agent( "ownCloudTest_$localDir");
my $req = PUT $puturl, Content_Type => 'application/octet-stream',
Content => $string;
$req->authorization_basic($user, $passwd);
my $response = $ua->request($req);
if ($response->is_success()) {
# print "OK: ", $response->content;
} else {
die( "HTTP PUT failed: " . $response->as_string );
}
}
# does a simple GET of a file in the testdir to a local file.
sub getToFileCurl( $$ )
{
my ($file, $localFile) = @_;
my $geturl = testDirUrl() . $file;
print "GETting $geturl to $localFile\n";
my @args = ("curl", "-k", "-u", "$user:$passwd", "$geturl", "-o", "$localFile");
system( @args );
}
# FIXME: This does not work because I can not get an authenticated GET request
# that writes its content to a file. Strange.
sub getToFileLWP( $$ )
{
my ($file, $localFile) = @_;
my $geturl = testDirUrl() . $file;
print "GETting $geturl to $localFile\n";
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 });
$ua->agent( "ownCloudTest_$localDir");
$ua->credentials( server(), "foo", $user, $passwd);
my $req = $ua->get($geturl, ":content_file" => $localFile);
# my $req = HTTP::Request->new( GET => $geturl, ':content_file' => $localFile);
# $req->authorization_basic("$user", "$passwd");
# my $response = $ua->request($req);
if ($req->is_success()) {
print "OK: ", $req->content;
} else {
die( "HTTP GET failed: " . $req->as_string );
}
}
sub createLocalFile( $$ )
{
my ($fname, $size) = @_;
$size = 1024 unless( $size );
my $md5 = Digest::MD5->new;
open(FILE, ">", $fname) or die "Can't open $fname for writing ($!)";
my $minimum = 32;
my $range = 96;
for (my $bytes = 0; $bytes < $size-1; $bytes += 4) {
my $rand = int(rand($range ** 4));
my $string = '';
for (1..4) {
$string .= chr($rand % $range + $minimum);
$rand = int($rand / $range);
}
print FILE $string;
$md5->add($string);
}
my $s = "\n";
print FILE $s;
$md5->add($s);
close FILE;
return $md5->hexdigest;
}
sub md5OfFile( $ )
{
my ($file) = @_;
open FILE, "$file";
my $ctx = Digest::MD5->new;
$ctx->addfile (*FILE);
my $hash = $ctx->hexdigest;
close (FILE);
return $hash;
}
sub moveRemoteFile($$;$)
{
my ($from, $to, $no_testdir) = @_;
setCredentials($d, $user, $passwd);
my $fromUrl = testDirUrl(). $from;
my $toUrl = testDirUrl() . $to;
if( $no_testdir ) {
$fromUrl = $from;
$toUrl = $to;
}
$d->move($fromUrl, $toUrl);
}
sub printInfo($)
{
my ($info) = @_;
my $tt = 6+length( $info );
print "#" x $tt;
printf( "\n# %2d. %s", $infoCnt, $info );
print "\n" unless $info =~ /\n$/;
print "#" x $tt;
print "\n";
$infoCnt++;
}
sub remoteFileProp($$)
{
my ($fromDir, $file) = @_;
my $fromUrl = testDirUrl() . $fromDir;
my $result;
if( my $r = $d->propfind( -url => $fromUrl, -depth => 1 ) ) {
if ( $r->is_collection ) {
# print "Collection\n";
foreach my $res ( $r->get_resourcelist->get_resources() ) {
my $filename = $res->get_property("rel_uri");
# print "OOOOOOOOOOOOOO $filename " . $res->get_property('id') . "\n";
if( $file eq $filename || $filename eq $file . "/" ) {
$result = $res;
}
}
} else {
# print "OOOOOOOOOOOOOOOOOOO " . $r->get_property("rel_uri");
$result = $r;
}
}
return $result;
}
sub remoteFileId($$)
{
my ($fromDir, $file) = @_;
my $id;
if( my $res = remoteFileProp($fromDir, $file) ) {
$id = $res->get_property('id') || "";
}
print "## ID of $file: $id\n";
return $id;
}
# Creates a read write share from the config file user 'share_user' to the
# config file user 'user'
# readWrite: permission flag. 31 for all permissions (read/write/create etc)
# and 1 for read only
sub createShare($$)
{
my ($dir, $readWrite) = @_;
my $dd = HTTP::DAV->new();
setCredentials($dd, $share_user, $share_passwd);
$dd->open( $owncloud);
# create a remote dir
my $url = $owncloud . $dir;
my $re = $dd->mkcol( $url );
if( $re == 0 ) {
print "Failed to create test dir $url\n";
}
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 } );
$ua->agent( "ownCloudTest_sharing");
# http://localhost/ocm/ocs/v1.php/apps/files_sharing/api/v1/shares
my $puturl = $ocs_url . "apps/files_sharing/api/v1/shares";
my $string = "path=$dir&shareType=0&shareWith=$user&publicUpload=false&permissions=$readWrite";
print ">>>>>>>>>> $puturl $string\n";
my $req = POST $puturl, Content => $string;
$req->authorization_basic($share_user, $share_passwd);
my $response = $ua->request($req);
my $id = 0;
if ($response->is_success()) {
# print "OK: ", $response->content;
print $response->decoded_content;
if( $response->decoded_content =~ /<id>(\d+)<\/id>/m) {
$id = $1;
}
} else {
die( "Create sharing failed: " . $response->as_string );
}
return $id;
}
sub removeShare($$)
{
my ($shareId, $dir) = @_;
my $dd = HTTP::DAV->new();
setCredentials($dd, $share_user, $share_passwd);
$dd->open( $owncloud);
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
$ua->agent( "ownCloudTest_sharing");
my $url = $ocs_url . "ocs/v1.php/apps/files_sharing/api/v1/shares/" . $shareId;
my $req = DELETE $url;
$req->authorization_basic($share_user, $share_passwd);
my $response = $ua->request($req);
if ($response->is_success()) {
print $response->decoded_content;
if( $response->decoded_content =~ /<status_code>(\d+)<\/status_code>/m) {
my $code = $1;
assert( $code == 100 );
}
} else {
die( "Create sharing failed: " . $response->as_string );
}
# remove the share dir
my $req = DELETE $owncloud . $dir;
$req->authorization_basic($share_user, $share_passwd);
my $response = $ua->request($req);
}
sub assert($;$)
{
unless( $_[0] ) {
print Carp::confess(@_);
exit(1);
}
}
#

View file

@ -1,8 +0,0 @@
user => "joe",
passwd => "secret",
url => "http://localhost/ocm/remote.php/webdav/",
ld_libpath => "/home/joe/owncloud/mirall-install/lib",
csync => "/home/joe/owncloud/mirall-install/bin/owncloudcmd",
ocs_url => "http://localhost/owncloud/ocs/v1.php/",
share_user => "jenny",
share_passwd => "also_secret"

View file

@ -1,206 +0,0 @@
#!/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 File::Copy;
use ownCloud::Test;
use strict;
print "Hello, this is t1, a tester for csync with ownCloud.\n";
initTesting();
print "Copy some files to the remote location\n";
createRemoteDir( "remoteToLocal1" );
createRemoteDir( "remoteToLocal1/rtl1" );
createRemoteDir( "remoteToLocal1/rtl1/rtl11" );
createRemoteDir( "remoteToLocal1/rtl2" );
createRemoteDir( "remoteToLocal1/rtl4" );
glob_put( 'toremote1/*', "remoteToLocal1/" );
glob_put( 'toremote1/rtl1/*', "remoteToLocal1/rtl1/" );
glob_put( 'toremote1/rtl1/rtl11/*', "remoteToLocal1/rtl1/rtl11/" );
glob_put( 'toremote1/rtl2/*', "remoteToLocal1/rtl2/" );
glob_put( 'toremote1/rtl4/*', "remoteToLocal1/rtl4/" );
# call csync, sync local t1 to remote t1
csync();
# Check if the files from toremote1 are now in t1/remoteToLocal1
# they should have taken the way via the ownCloud.
print "Assert the local file copy\n";
assertLocalDirs( 'toremote1', localDir().'remoteToLocal1' );
# Check if the synced files from ownCloud have the same timestamp as the local ones.
print "\nNow assert remote 'toremote1' with local " . localDir() . " :\n";
assertLocalAndRemoteDir( '', 0);
# remove a local file.
printInfo( "\nRemove a local file\n" );
unlink( localDir() . 'remoteToLocal1/rtl4/quitte.pdf' );
csync();
assertLocalAndRemoteDir( '', 0);
# add local files to a new dir1
printInfo( "Add some more files to local:");
my $locDir = localDir() . 'fromLocal1';
mkdir( $locDir );
assert( -d $locDir );
foreach my $file ( <./tolocal1/*> ) {
print "Copying $file to $locDir\n";
copy( $file, $locDir );
}
# Also add a file with symbols
my $symbolName = "a\%b#c\$d-e";
system( "echo \"my symbols\" >> $locDir/$symbolName" );
#Also on the server
put_to_dir( "$locDir/$symbolName", 'remoteToLocal1' );
csync( );
print "\nAssert local and remote dirs.\n";
assertLocalAndRemoteDir( '', 0);
assert( ! -e localDir().$symbolName );
# move a local file
printInfo( "Move a file locally." );
move( "$locDir/kramer.jpg", "$locDir/oldtimer.jpg" );
csync( );
assertLocalAndRemoteDir( '', 0);
# move a local directory.
printInfo( "Move a local directory." );
move( localDir() . 'remoteToLocal1/rtl1', localDir(). 'remoteToLocal1/rtlX');
csync();
assertLocalAndRemoteDir( '', 0);
# remove a local dir
printInfo( "Remove a local directory.");
localCleanup( 'remoteToLocal1/rtlX' );
csync();
assertLocalAndRemoteDir( '', 0);
assert( ! -e localDir().'remoteToLocal1/rtlX' );
# create twos false conflict, only the mtimes are changed, by content are equal.
printInfo( "Create two false conflict.");
put_to_dir( 'toremote1/kernelcrash.txt', 'remoteToLocal1' );
put_to_dir( 'toremote1/kraft_logo.gif', 'remoteToLocal1' );
# don't wait so mtime are likely the same on the client and the server.
system( "touch " . localDir() . "remoteToLocal1/kraft_logo.gif" );
# wait two second so the mtime are different
system( "sleep 2 && touch " . localDir() . "remoteToLocal1/kernelcrash.txt" );
csync( );
assertLocalAndRemoteDir( '', 0);
# The previous sync should have updated the etags, and this should NOT be a conflict
printInfo( "Update the file again");
my $f1 = localDir() . "remoteToLocal1/kernelcrash.txt";
my $s1 = 2136;
createLocalFile( $f1, $s1);
# stat the file
my @stat1 = stat $f1;
print "Updating File $f1 to $s1, size is $stat1[7]\n";
my $f2 = localDir() . "remoteToLocal1/kraft_logo.gif";
my $s2 = 2332;
createLocalFile( $f2, $s2);
# stat the file
my @stat2 = stat $f2;
print "Updating File $f2 to $s2, size is $stat2[7]\n";
system( "sleep 2 && touch " . localDir() . "remoteToLocal1/kernelcrash.txt" );
csync( );
assertLocalAndRemoteDir( '', 0);
# create a true conflict.
printInfo( "Create a conflict." );
system( "echo \"This is more server stuff\" >> /tmp/kernelcrash.txt" );
put_to_dir( '/tmp/kernelcrash.txt', 'remoteToLocal1' );
system( "sleep 2 && echo \"This is more client stuff\" >> " . localDir() . "remoteToLocal1/kernelcrash.txt" );
csync();
assertLocalAndRemoteDir( '', 1);
my $localMD5 = md5OfFile( localDir().'remoteToLocal1/kernelcrash.txt' );
my $realMD5 = md5OfFile( '/tmp/kernelcrash.txt' );
print "MD5 compare $localMD5 <-> $realMD5\n";
assert( $localMD5 eq $realMD5 );
assert( glob(localDir().'remoteToLocal1/kernelcrash*conflicted*copy*.txt' ) );
system("rm " . localDir().'remoteToLocal1/kernelcrash*conflicted*copy*.txt' );
# prepare test for issue 1329, rtlX need to be modified
# [https://github.comowncloud/client/issues/1329]
printInfo( "Add a local directory");
system("cp -r 'toremote1/rtl1/' '" . localDir(). "remoteToLocal1/rtlX'");
csync();
assertLocalAndRemoteDir( '', 0);
# remove a local dir (still for issue 1329)
printInfo( "Remove that directory.");
localCleanup( 'remoteToLocal1/rtlX' );
csync();
assertLocalAndRemoteDir( '', 0);
assert( ! -e localDir().'remoteToLocal1/rtlX' );
# add it back again (still for issue 1329)
printInfo( "Add back the local dir.");
system("cp -r 'toremote1/rtl1/' '" . localDir(). "remoteToLocal1/rtlX'");
assert( -e localDir().'remoteToLocal1/rtlX' );
assert( -e localDir().'remoteToLocal1/rtlX/rtl11/file.txt' );
csync();
assertLocalAndRemoteDir( '', 0);
assert( -e localDir().'remoteToLocal1/rtlX' );
assert( -e localDir().'remoteToLocal1/rtlX/rtl11/file.txt' );
printInfo( "Remove a directory on the server with new files on the client");
removeRemoteDir('remoteToLocal1/rtlX');
system("echo hello > " . localDir(). "remoteToLocal1/rtlX/rtl11/hello.txt");
csync();
assertLocalAndRemoteDir( '', 0);
# file.txt must be gone because the directory was removed on the server, but hello.txt must be there
# as it is a new file
assert( ! -e localDir().'remoteToLocal1/rtlX/rtl11/file.txt' );
assert( -e localDir().'remoteToLocal1/rtlX/rtl11/hello.txt' );
# ==================================================================
cleanup();
# --

View file

@ -1,220 +0,0 @@
#!/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 File::Copy;
use ownCloud::Test;
use strict;
sub getInode($)
{
my ($filename) = @_;
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
return $ino;
}
print "Hello, this is t2, a tester for remote renaming\n";
initTesting();
print "Copy some files to the remote location\n";
createRemoteDir( "remoteToLocal1" );
createRemoteDir( "remoteToLocal1/rtl1" );
createRemoteDir( "remoteToLocal1/rtl1/rtl11" );
createRemoteDir( "remoteToLocal1/rtl2" );
glob_put( 'toremote1/*', "remoteToLocal1/" );
glob_put( 'toremote1/rtl1/*', "remoteToLocal1/rtl1/" );
glob_put( 'testfiles/*', "remoteToLocal1/rtl1/rtl11/" );
glob_put( 'toremote1/rtl2/*', "remoteToLocal1/rtl2/" );
# call csync, sync local t1 to remote t1
printInfo("Initial sync, sync stuff down.");
csync();
# Check if the files from toremote1 are now in t1/remoteToLocal1
# they should have taken the way via the ownCloud.
print "Assert the local file copy\n";
assertLocalDirs( localDir().'remoteToLocal1', 'toremote1' );
# Check if the synced files from ownCloud have the same timestamp as the local ones.
print "\nNow assert remote 'toremote1' with local " . localDir() . " :\n";
assertLocalAndRemoteDir( 'remoteToLocal1', 0);
# Do some remote moves:
# First a simple file move.
printInfo("Simply move a file to another name.");
my $inode = getInode('remoteToLocal1/kernelcrash.txt');
moveRemoteFile( 'remoteToLocal1/kernelcrash.txt', 'remoteToLocal1/kernel.txt');
csync();
assertLocalAndRemoteDir( 'remoteToLocal1', 0);
my $inode2 = getInode( 'remoteToLocal1/kernel.txt');
assert( $inode == $inode2, "Inode has changed!");
printInfo("Move a file into a sub directory.");
# now move the file into a sub directory
moveRemoteFile( 'remoteToLocal1/kernel.txt', 'remoteToLocal1/rtl1/');
csync();
assertLocalAndRemoteDir( 'remoteToLocal1', 0);
$inode = getInode('remoteToLocal1/rtl1/kernel.txt');
assert( $inode == $inode2, "Inode has changed 2!");
printInfo("Move an existing directory.");
# move an existing directory
$inode = getInode('remoteToLocal1/rtl1');
moveRemoteFile( 'remoteToLocal1/rtl1', 'remoteToLocal1/movedRtl1');
csync();
assertLocalAndRemoteDir( 'remoteToLocal1', 0);
$inode = getInode('remoteToLocal1/movedRtl1');
assert( $inode == $inode2, "Inode has changed 3!");
printInfo( "Move a file in a directory and than move the dir." );
# move a file in a directory and than move the directory
moveRemoteFile('remoteToLocal1/movedRtl1/rtl11/zerofile.txt', 'remoteToLocal1/movedRtl1/rtl11/centofile.txt');
moveRemoteFile( 'remoteToLocal1/movedRtl1', 'remoteToLocal1/againRtl1');
csync();
assertLocalAndRemoteDir( 'remoteToLocal1', 0);
printInfo("Move a directory and than move a file within it.");
# move a directory and than move a file within the directory
moveRemoteFile( 'remoteToLocal1/againRtl1', 'remoteToLocal1/moved2Rtl1');
moveRemoteFile('remoteToLocal1/moved2Rtl1/rtl11/centofile.txt', 'remoteToLocal1/moved2Rtl1/tripofile.txt');
csync();
assertLocalAndRemoteDir( 'remoteToLocal1', 0);
printInfo("Rename file loally and remotely to a different name.");
# Rename a file locally and the same file remotely to another name.
move( localDir() . 'remoteToLocal1/moved2Rtl1/tripofile.txt', localDir() . 'remoteToLocal1/moved2Rtl1/meckafile.txt' );
moveRemoteFile( 'remoteToLocal1/moved2Rtl1/tripofile.txt', 'remoteToLocal1/moved2Rtl1/sofiafile.txt' );
csync();
assertLocalAndRemoteDir( 'remoteToLocal1', 0);
# Change a file remotely and than move the directory
printInfo( "Move a directory remotely with a changed file in it.");
my $md5 = createLocalFile( '/tmp/sofiafile.txt', 43 );
put_to_dir( '/tmp/sofiafile.txt', 'remoteToLocal1/moved2Rtl1' );
moveRemoteFile( 'remoteToLocal1/moved2Rtl1', 'remoteToLocal1/newDir');
# Now in remoteToLocal1/newDir/sofiafile.txt we should have content...
csync();
assertLocalAndRemoteDir( 'remoteToLocal1', 0);
my $newMd5 = md5OfFile( localDir().'remoteToLocal1/newDir/sofiafile.txt' );
print "MD5 compare $md5 <-> $newMd5\n";
assert( $md5 eq $newMd5 );
# Move a directory on remote but remove the dir locally
printInfo("Move a directory remotely, but remove the local one");
moveRemoteFile( 'remoteToLocal1/newDir', 'remoteToLocal1/newDir2');
system( "rm -rf " . localDir() . 'remoteToLocal1/newDir');
# move a file but create a file with the same name locally.
moveRemoteFile( 'remoteToLocal1/newDir2/sofiafile.txt', 'remoteToLocal1/constantinopel.txt' );
csync();
assertLocalAndRemoteDir( 'remoteToLocal1', 0);
# Move a file remotely and create one with the same name on the
# local repo.
printInfo("Move remotely and create a local file with same name");
moveRemoteFile('remoteToLocal1/rtl2/kb1.jpg', 'remoteToLocal1/rtl2/kb1moved.jpg');
move( localDir().'remoteToLocal1/rtl2/kb1.jpg', localDir().'remoteToLocal1/rtl2/kb1_local_gone.jpg');
csync();
assertLocalAndRemoteDir( 'remoteToLocal1', 0);
## make new directory remote
printInfo("Create a remote dir, put in a file and move it, but have a similar one locally.");
createRemoteDir('remoteToLocal1/rtl2/newRemoteDir');
my $firstMd5 = createLocalFile( '/tmp/donat12.txt', 4096 );
put_to_dir( '/tmp/donat12.txt', 'remoteToLocal1/rtl2/newRemoteDir/' );
moveRemoteFile('remoteToLocal1/rtl2/newRemoteDir/donat12.txt',
'remoteToLocal1/rtl2/newRemoteDir/donat.txt');
mkdir( localDir().'remoteToLocal1/rtl2/newRemoteDir' );
createLocalFile( localDir(). 'remoteToLocal1/rtl2/newRemoteDir/donat.txt', 8021 );
csync();
assertLocalAndRemoteDir( 'remoteToLocal1', 1);
printInfo("simulate a owncloud 5 update by removing all the fileid");
## simulate a owncloud 5 update by removing all the fileid
system( "sqlite3 " . localDir() . ".sync_*.db \"UPDATE metadata SET fileid='';\"");
#refresh the ids
csync();
assertLocalAndRemoteDir( 'remoteToLocal1', 1);
printInfo("Move a file from the server");
$inode = getInode('remoteToLocal1/rtl2/kb1_local_gone.jpg');
moveRemoteFile( 'remoteToLocal1/rtl2/kb1_local_gone.jpg', 'remoteToLocal1/rtl2/kb1_local_gone2.jpg');
#also create a new directory localy for the next test
mkdir( localDir().'superNewDir' );
createLocalFile(localDir(). 'superNewDir/f1', 1234 );
createLocalFile(localDir(). 'superNewDir/f2', 1324 );
my $superNewDirInode = getInode('superNewDir');
csync();
assertLocalAndRemoteDir( '', 1);
$inode2 = getInode('remoteToLocal1/rtl2/kb1_local_gone2.jpg');
assert( $inode == $inode2, "Inode has changed 3!");
printInfo("Move a newly created directory");
moveRemoteFile('superNewDir', 'superNewDirRenamed');
#also add new files in new directory
createLocalFile(localDir(). 'superNewDir/f3' , 2456 );
$inode = getInode('superNewDir/f3');
csync();
assertLocalAndRemoteDir( '', 1);
my $file = localDir() . 'superNewDir';
assert( ! -e $file );
$inode2 = getInode('superNewDirRenamed/f3');
assert( $inode == $inode2, "Inode of f3 changed");
$inode2 = getInode('superNewDirRenamed');
assert( $superNewDirInode == $inode2, "Inode of superNewDir changed");
cleanup();
# --

View file

@ -1,160 +0,0 @@
#!/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 Olivier Goffart <ogoffart@woboq.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 File::Copy;
use ownCloud::Test;
use strict;
print "Hello, this is t3, a tester for renaming directories\n";
initTesting();
printInfo( "Copy some files to the remote location\n" );
createRemoteDir( "remoteToLocal1" );
createRemoteDir( "remoteToLocal1/rtl1" );
createRemoteDir( "remoteToLocal1/rtl1/rtl11" );
createRemoteDir( "remoteToLocal1/rtl2" );
glob_put( 'toremote1/*', "remoteToLocal1/" );
glob_put( 'toremote1/rtl1/*', "remoteToLocal1/rtl1/" );
glob_put( 'testfiles/*', "remoteToLocal1/rtl1/rtl11/" );
glob_put( 'toremote1/rtl2/*', "remoteToLocal1/rtl2/" );
# call csync, sync local t1 to remote t1
csync();
# Check if the files from toremote1 are now in t1/remoteToLocal1
# they should have taken the way via the ownCloud.
printInfo( "Assert the local file copy\n" );
assertLocalDirs( localDir().'remoteToLocal1', 'toremote1' );
# Check if the synced files from ownCloud have the same timestamp as the local ones.
printInfo( "Now assert remote 'toremote1' with local " . localDir() );
assertLocalAndRemoteDir( 'remoteToLocal1', 0);
# Make a new directory, moves a sub directory into. Remove the parent directory.
# create a new file on the server in the directory that will be renamed
printInfo( "Create a new directory and move subdirs into." );
my $newfile_md5 = createLocalFile(localDir()."remoteToLocal1/rtl1/rtl11/newfile.dat", 123);
unlink( localDir() . 'remoteToLocal1/rtl1/rtl11/test.txt' );
mkdir( localDir() . 'newdir' );
move( localDir() . 'remoteToLocal1/rtl1', localDir() . 'newdir/rtl1' );
system( "rm -rf " . localDir() . 'remoteToLocal1' );
system( "echo \"my file\" >> /tmp/myfile.txt" );
put_to_dir( '/tmp/myfile.txt', 'remoteToLocal1/rtl1/rtl11' );
# Also add a file with symbols
my $symbolName = "a\%b#c\$d-e";
system( "echo \"my symbols\" >> /tmp/$symbolName" );
put_to_dir( "/tmp/$symbolName", 'remoteToLocal1/rtl1/rtl11' );
my $fileid = remoteFileId( 'remoteToLocal1/rtl1/', 'rtl11' );
my $fid2 = remoteFileId( 'remoteToLocal1/rtl1/', 'La ced' );
assert($fid2 eq "" or $fileid ne $fid2, "File IDs are equal" );
csync();
my $newFileId = remoteFileId( 'newdir/rtl1/', 'rtl11' );
my $newfid2 = remoteFileId( 'newdir/rtl1/', 'La ced' );
assert($newFileId eq "" or $newFileId ne $newfid2, "File IDs are equal" );
assert( $fileid eq $newFileId, "file ID mixup: 'newdir/rtl1/rtl11" );
assert( $fid2 eq $newfid2, "file ID mixup: 'newdir/La ced" );
assertLocalAndRemoteDir( 'newdir', 0);
assert( -e localDir().'newdir/rtl1/rtl11/newfile.dat' );
assert( -e localDir().'newdir/rtl1/rtl11/myfile.txt' );
assert( ! -e localDir().'newdir/rtl11/test.txt' );
# BUG! remoteToLocal1 is not deleted because changes were detected
# (even if the changed fileswere moved)
# assert( ! -e localDir().'remoteToLocal1' );
assert( ! -e localDir().'remoteToLocal1/rtl1' );
printInfo("Move file and create another one with the same name.");
move( localDir() . 'newdir/myfile.txt', localDir() . 'newdir/oldfile.txt' );
system( "echo \"super new\" >> " . localDir() . 'newdir/myfile.txt' );
#Move a file with symbols as well
move( localDir() . "newdir/$symbolName", localDir() . "newdir/$symbolName.new" );
#Add some files for the next test.
system( "echo \"un\" > " . localDir() . '1.txt' );
system( "echo \"deux\" > " . localDir() . '2.txt' );
system( "echo \"trois\" > " . localDir() . '3.txt' );
mkdir( localDir() . 'newdir2' );
csync();
assertLocalAndRemoteDir( 'newdir', 0);
printInfo("Rename a directory that was just changed");
# newdir was changed so it's etag is not yet saved in the database, but still it needs to be moved.
my $newdirId = remoteFileId( localDir(), 'newdir' );
my $newdir2Id = remoteFileId( localDir(), 'newdir2' );
move(localDir() . 'newdir' , localDir() . 'newdir3');
move(localDir() . 'newdir2' , localDir() . 'newdir4');
# FIXME: this test is currently failing
# see csync_update.c in _csyn_detect_update, the commen near the commented fs->inode != tmp->inode
# unlink( localDir() . '1.txt' );
# move( localDir() . '2.txt', localDir() . '1.txt' );
csync();
assertLocalAndRemoteDir( '', 0);
my $newdir3Id = remoteFileId( localDir(), 'newdir3' );
my $newdir4Id = remoteFileId( localDir(), 'newdir4' );
assert( $newdirId eq $newdir3Id, "newdir was not MOVE'd to newdir3?" );
assert( $newdir2Id eq $newdir4Id, "newdir2 was not MOVE'd to newdir4?" );
printInfo("Move a file and replace it by a new one");
move( localDir() . '1.txt', localDir() . '1_bis.txt' );
move( localDir() . '3.txt', localDir() . '3_bis.txt' );
system( "echo \"new file un\" > " . localDir() . '1.txt' );
system( "echo \"new file trois\" > " . localDir() . '3.txt' );
#also add special file with special character for next sync
#and file with special characters
createLocalFile(localDir(). 'hêllo%20th@re.txt' , 1208 );
csync();
assertLocalAndRemoteDir( '', 0);
printInfo("Move a file containing special character");
move(localDir(). 'hêllo%20th@re.txt', localDir(). 'hêllo%20th@re.doc');
csync();
assertLocalAndRemoteDir( '', 0);
cleanup();
# --

View file

@ -1,224 +0,0 @@
#!/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 Olivier Goffart <ogoffart@woboq.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 File::Copy;
use ownCloud::Test;
use strict;
sub getInode($)
{
my ($filename) = @_;
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
return $ino;
}
print "Hello, this is t4, a tester for A) files that cannot be stated and B) excluded files C) hard links\n";
# stat error occours on windsows when the file is busy for example
initTesting();
printInfo( "Copy some files to the remote location" );
mkdir( localDir() . 'test_stat' );
system( "echo foobar > " . localDir() . 'test_stat/file.txt' );
mkdir( localDir() . 'test_ignored' );
mkdir( localDir() . 'test_ignored/sub' );
system( "echo foobarfoo > " . localDir() . 'test_ignored/sub/file.txt' );
# call csync, sync local t1 to remote t1
csync();
# Check if the files from toremote1 are now in t1/remoteToLocal1
# they should have taken the way via the ownCloud.
print "Assert the local file copy\n";
assertLocalAndRemoteDir( '', 0 );
printInfo( "Make a file not statable" );
system( "echo foobar2 >> " . localDir() . 'test_stat/file.txt' );
#make the file not statable by changing the directory right
system( "chmod 400 " . localDir() . 'test_stat' );
csync();
# TODO: some check here.
printInfo("Add a file in a read only directory");
system( "echo \"Hello World\" >> /tmp/kernelcrash.txt" );
put_to_dir( '/tmp/kernelcrash.txt', 'test_stat' );
# Sync failed, can't download file to readonly dir
csync(1);
assert( ! -e localDir().'test_stat/kernelcrash' );
printInfo("Restore the original rights");
system( "chmod 700 " . localDir() . 'test_stat' );
system( "echo foobar3 >> " . localDir() . 'test_stat/file.txt' );
csync();
print "Check if everything is still the same\n";
assertLocalAndRemoteDir( '', 0 );
# TODO: Check that the file content is fine on the server and that there was no conflict
assert( -e localDir().'test_stat/file.txt' );
assert( -e localDir().'test_stat/kernelcrash.txt' );
my $localMD5 = md5OfFile( localDir().'test_stat/kernelcrash.txt' );
my $realMD5 = md5OfFile( '/tmp/kernelcrash.txt' );
print "MD5 compare $localMD5 <-> $realMD5\n";
assert( $localMD5 eq $realMD5 );
printInfo("Added a file that is on the ignore list");
# (*.directory is in the ignored list that needs cleanup)
# (it is names with conflicted copy) because i want the conflicft detection of assertLocalAndRemoteDir to work
system( "echo dir >> " . localDir() . 'test_stat/file_conflicted\ copy.directory' );
# this one should retain the directory
system( "echo foobarfoo > " . localDir() . 'test_ignored/sub/ignored_conflicted\ copy.part' );
csync();
# The file_conflicted\ copy.directory is seen as a conflict
assertLocalAndRemoteDir( '', 1 );
# TODO: check that the file_conflicted\ copy.directory is indeed NOT on the server
# TODO: check that test_ignored/sub/ignored_conflicted\ copy.part is NOT on the server
assert(-e localDir() . 'test_ignored/sub/ignored_conflicted copy.part');
printInfo("Remove a directory containing an ignored file that should not be removed\n");
remoteCleanup('test_ignored');
csync();
assert(-e localDir() . 'test_ignored/sub/ignored_conflicted copy.part');
#remove the file so next sync allow the directory to be removed
system( "rm " . localDir() . 'test_ignored/sub/ignored_conflicted\ copy.part' );
printInfo("Remove a directory containing a local file\n");
remoteCleanup('test_stat');
#Add an executable file for next test
system( "echo echo hello >> " . localDir() . 'echo.sh' );
chmod 0751, localDir() . 'echo.sh';
#and add a file in anotherdir for the next test
mkdir( localDir() . 'anotherdir' );
mkdir( localDir() . 'anotherdir/sub' );
system( "echo foobar > " . localDir() . 'anotherdir/file1.txt' );
system( "echo foobar > " . localDir() . 'anotherdir/sub/file2.txt' );
csync();
assertLocalAndRemoteDir( '', 0 );
open(my $fh, "<", localDir() . 'echo.sh');
my $perm = (stat $fh)[2] & 07777;
assert( $perm eq 0751, "permissions not kept" );
printInfo("Modify a file in the remote and check its permission\n");
system( "echo \"echo bonjour\" > /tmp/echo.sh" );
put_to_dir( '/tmp/echo.sh', "" );
csync();
assertLocalAndRemoteDir( '', 0 );
open(my $fh, "<", localDir() . 'echo.sh');
my $perm = (stat $fh)[2] & 07777;
assert( $perm eq 0751, "permissions not kept" );
printInfo("Remove a directory and make it a symlink instead\n");
system( "rm -rf " . localDir() . 'anotherdir' );
system( "ln -s /bin " . localDir() . 'anotherdir' );
# remember the fileid of the file on the server
my $oldfileid1 = remoteFileId( 'anotherdir/', 'file1.txt' );
my $oldfileid2 = remoteFileId( 'anotherdir/sub', 'file2.txt' );
csync();
#check that the files in ignored directory has NOT been removed
my $newfileid1 = remoteFileId( 'anotherdir/', 'file1.txt' );
my $newfileid2 = remoteFileId( 'anotherdir/sub', 'file2.txt' );
assert( $oldfileid1 eq $newfileid1, "File removed (file1.txt)" );
assert( $oldfileid2 eq $newfileid2, "File removed (file2.txt)" );
printInfo("Now remove the symlink\n");
system( "rm -f " . localDir() . 'anotherdir' );
csync();
assertLocalAndRemoteDir( '', 0 );
assert(! -e localDir(). 'anotherdir' );
printInfo("Test hardlinks\n");
#make a hard link
mkdir( localDir() . 'subdir' );
createLocalFile( localDir() .'subdir/original.data', 1568 );
system( "ln " . localDir() . 'subdir/original.data ' . localDir() . 'file.link');
csync();
assertLocalAndRemoteDir( '', 0 );
my $inode = getInode(localDir() . 'subdir/original.data');
my $inode2 = getInode(localDir() . 'file.link');
assert( $inode == $inode2, "Inode is not the same!");
printInfo("Modify hard link\n");
system( "echo 'another line' >> " . localDir() . 'file.link');
csync();
assertLocalAndRemoteDir( '', 0 );
my $inode1 = getInode(localDir() .'subdir/original.data');
$inode2 = getInode( localDir() .'file.link');
assert( $inode == $inode1, "Inode is not the same!");
assert( $inode == $inode2, "Inode is not the same!");
printInfo("Rename a hard link\n");
move( localDir() . 'subdir/original.data', localDir() . 'subdir/kernelcrash.txt' );
csync();
assertLocalAndRemoteDir( '', 0 );
$inode1 = getInode(localDir() .'subdir/kernelcrash.txt');
$inode2 = getInode(localDir() .'file.link');
assert( $inode == $inode1, "Inode is not the same!");
assert( $inode == $inode2, "Inode is not the same!");
printInfo("Modify a hard link on the server\n");
put_to_dir( '/tmp/kernelcrash.txt', 'subdir' );
csync();
assertLocalAndRemoteDir( '', 0 );
$inode1 = getInode(localDir() .'subdir/kernelcrash.txt');
$inode2 = getInode( localDir() .'file.link');
# only the first inode must change
print(" $inode $inode1 $inode2" );
assert( $inode != $inode1, "Inode did not change");
assert( $inode == $inode2, "Inode is not the same!");
cleanup();
# --

View file

@ -1,111 +0,0 @@
#!/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 File::Copy;
use ownCloud::Test;
use strict;
print "Hello, this is t5, a tester for syncing of files in Shares\n";
initTesting();
# Create empty test dirs.
csync();
my $share_dir = "share_source";
my $sharee = { user => configValue('share_user'),
passwd => configValue('share_passwd'),
url => server() };
# first remove a possibly left over share dir.
printInfo( "Remove possibly left over share dir" );
removeRemoteDir( $share_dir, $sharee );
printInfo( "Create a share." );
my $shareId = createShare( $share_dir, 31 );
print "Created share with id <$shareId>\n";
assert( $shareId > 0 );
if( $ENV{SERVER_VERSION} eq "owncloud6" ) {
print "This test does not make more sense for ownCloud6, leaving for good!\n\n";
exit;
}
# put a couple of files into the shared directory in the sharer account
glob_put( 'sharing/*', $share_dir, $sharee);
# Move the shared dir remotely into the test dir, otherwise the script
# has a hard time to find it.
moveRemoteFile( server() . $share_dir, localDir(), 1 );
# call csync, sync local t1 to remote t1
printInfo("Initial sync, sync stuff down.");
csync();
assertLocalAndRemoteDir( '', 0 );
# Local file to a read/write share should be synced up
printInfo("Put a file into the share.");
createLocalFile(localDir() . "$share_dir/foobar.txt", 8094 );
csync( );
assertLocalAndRemoteDir( '', 0 );
# now move the file locally and sync
printInfo("Move the file locally and sync.");
my $cmd = "mv " . localDir() . "$share_dir/foobar.txt ". localDir() . "$share_dir/moved_file.txt";
system( $cmd );
csync( );
assertLocalAndRemoteDir( '', 0 );
# now create aother directory and redo
printInfo("Create another directory and file");
my $cmd = "mkdir ". localDir() . "$share_dir/newDir";
system( $cmd );
createLocalFile( localDir() . "$share_dir/newDir/a_file.bin", 5321 );
csync( );
assertLocalAndRemoteDir( '', 0 );
# Remove the local file again
printInfo("Remove the local file again.");
unlink( localDir() . "$share_dir/newDir/a_file.bin" );
csync( );
assertLocalAndRemoteDir( '', 0 );
# Remove the local directory again
printInfo("Remove the local directory again.");
rmdir( localDir() . "$share_dir/newDir" );
csync( );
assertLocalAndRemoteDir( '', 0 );
printInfo("Remove a Share.");
removeShare($shareId, $share_dir);
cleanup();
# --

View file

@ -1,185 +0,0 @@
#!/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 File::Copy;
use ownCloud::Test;
use strict;
print "Hello, this is t6, a tester for csync with ownCloud.\n";
# Checking CURL is installed to avoid misleading errors later...
system(("curl", "--help", ">", "/dev/null"));
if ($? != 0) {
print "CURL is needed for this script, aborting with error\n";
exit 1;
}
initTesting();
sub createPostUpdateScript($)
{
my ($name) = @_;
my $srcFile = localDir().'BIG1.file';
my $cred = configValue("user") . ":" . configValue("passwd");
my $cmd = "curl -T $srcFile -u $cred --insecure " . testDirUrl().$name;
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 ($name,$num) = @_;
my $sql = "sqlite3 " . localDir() . ".sync_*.db \"SELECT md5 FROM metadata WHERE path='$name';\"";
open(my $fh, '-|', $sql) or die $!;
my $etag = <$fh>;
close $fh;
print "$num etag: $etag";
return $etag;
}
sub chunkFileTest( $$ )
{
my ($name, $size) = @_;
# Big file chunking
createLocalFile( localDir().$name, $size );
assert( -e localDir().$name );
my $bigMd5 = md5OfFile( localDir().$name );
csync();
my $newMd5 = md5OfFile( localDir().$name );
assert( $newMd5 eq $bigMd5, "Different MD5 sums!" );
# download
my $ctrlFile = "/tmp/file.download";
getToFileCurl( $name, $ctrlFile );
assert( -e $ctrlFile, "File does not exist!" );
# assert files
my $dlMd5 = md5OfFile( $ctrlFile );
assert( $dlMd5 eq $newMd5, "Different MD5 sums 2" );
unlink( $ctrlFile );
}
printInfo("Big file that needs chunking with default chunk size");
chunkFileTest( "BIG1.file", 23251233 );
printInfo("Update the existing file and trigger reupload");
# change the existing file again -> update
chunkFileTest( "BIG2.file", 21762122 );
printInfo("Cause a precondition failed error");
# Now overwrite the existing file to change it
createLocalFile( localDir()."BIG3.file", 21832 );
sleep(2);
csync();
createLocalFile( localDir().'BIG3.file', 34323 );
sleep(2);
# and create a post update script
my $script = createPostUpdateScript('BIG3.file');
$ENV{'OWNCLOUD_POST_UPDATE_SCRIPT'} = $script;
# Save the etag before the sync
my $firstETag = getETagFromJournal('BIG3.file', 'First');
sleep(2);
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('BIG3.file', 'Second');
# Now the result is that there is a conflict file because since 1.7
# the sync is stopped on preconditoin failed and done again.
my $seen = 0;
opendir(my $dh, localDir() );
while(readdir $dh) {
$seen = 1 if ( /BIG3.*conflicted copy.*\.file/ );
}
closedir $dh;
assert( $seen == 1, "No conflict file created on precondition failed!" );
unlink($script);
$ENV{'OWNCLOUD_POST_UPDATE_SCRIPT'} = "";
assertLocalAndRemoteDir( '', 1);
# Set a custom chunk size in environment.
my $ChunkSize = 1*1024*1024;
$ENV{'OWNCLOUD_CHUNK_SIZE'} = $ChunkSize;
printInfo("Big file exactly as big as one chunk size");
chunkFileTest( "oneChunkSize.bin", $ChunkSize);
printInfo("Big file exactly as big as one chunk size minus 1 byte");
chunkFileTest( "oneChunkSizeminusone.bin", $ChunkSize-1);
printInfo("Big file exactly as big as one chunk size plus 1 byte");
chunkFileTest( "oneChunkSizeplusone.bin", $ChunkSize+1);
printInfo("Big file exactly as big as 2*chunk size");
chunkFileTest( "twoChunkSize.bin", 2*$ChunkSize);
printInfo("Big file exactly as big as 2*chunk size minus 1 byte");
chunkFileTest( "twoChunkSizeminusone.bin", 2*$ChunkSize-1);
printInfo("Big file exactly as big as 2*chunk size plus 1 byte");
chunkFileTest( "twoChunkSizeplusone.bin", 2*$ChunkSize+1);
printInfo("Big file with many chunks");
chunkFileTest( "bigFileManyChunk.bin", 10*$ChunkSize);
printInfo("Big file with many chunks reuploaded twice (1)");
createLocalFile( "BIG4.file", 21762122 );
csync();
assertLocalAndRemoteDir( '', 1);
printInfo("Big file with many chunks reuploaded twice (2)");
createLocalFile( "BIG4.file", 21783424 );
csync();
assertLocalAndRemoteDir( '', 1);
# ==================================================================
cleanup();
# --

View file

@ -1,141 +0,0 @@
#!/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 Olivier Goffart <ogoffart@woboq.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 File::Copy;
use ownCloud::Test;
use strict;
print "Hello, this is t8, a tester for syncing of files on a case sensitive FS\n";
# The test is run on a 'normal' file system, but we tell pwncloud that it is case preserving anyway
$ENV{OWNCLOUD_TEST_CASE_PRESERVING} = "1";
# No parallelism for more deterministic action.
$ENV{OWNCLOUD_MAX_PARALLEL}="1";
initTesting();
printInfo( "Syncing two files with the same name that differ with case" );
#create some files localy
my $tmpdir = "/tmp/t8/";
mkdir($tmpdir);
createLocalFile( $tmpdir . "HELLO.dat", 100 );
createLocalFile( $tmpdir . "Hello.dat", 150 );
createLocalFile( $tmpdir . "Normal.dat", 110 );
createLocalFile( $tmpdir . "test.dat", 170 );
#put them in some directories
createRemoteDir( "dir" );
glob_put( "$tmpdir/*", "dir" );
# can't download these
csync(1);
# Check that only one of the two file was synced.
# The one that exist here is undefined, the current implementation will take the
# first one alphabetically, but the other one would also be fine. What's imporant
# is that there is only one.
assert( -e localDir() . 'dir/HELLO.dat' );
assert( !-e localDir() . 'dir/Hello.dat' );
printInfo( "Remove one file should remove it on the server and download the other one" );
unlink( localDir() . 'dir/HELLO.dat' );
csync();
assert( -e localDir() . 'dir/Hello.dat' );
assert( !-e localDir() . 'dir/HELLO.dat' );
assertLocalAndRemoteDir( '', 0);
printInfo( "Renaming one file to the same name as another one with different casing" );
moveRemoteFile( 'dir/Hello.dat', 'dir/NORMAL.dat');
moveRemoteFile( 'dir/test.dat', 'dir/TEST.dat');
# can't download these
csync(1);
# Hello -> NORMAL should not have do the move since the case conflict
assert( -e localDir() . 'dir/Hello.dat' );
assert( !-e localDir() . 'dir/NORMAL.dat' );
assert( -e localDir() . 'dir/Normal.dat' );
#test->TEST should have been worked.
assert( -e localDir() . 'dir/TEST.dat' );
assert( !-e localDir() . 'dir/test.dat' );
# undo the change that causes the sync fail
moveRemoteFile( 'dir/NORMAL.dat', 'dir/Hello.dat');
printInfo( "Another directory with the same name but different casing is created" );
createRemoteDir( "DIR" );
glob_put( "$tmpdir/HELLO.dat", "DIR" );
# can't download dirs
csync(1);
assert( !-e localDir() . 'DIR' );
printInfo( "Remove the old dir localy" );
system("rm -r " . localDir() . "dir");
csync();
# now DIR was fetched
assert( -e localDir() . 'DIR' );
assert( -e localDir() . 'DIR/HELLO.dat' );
assert( !-e localDir() . 'dir' );
# dir/NORMAL.dat is still on the server
printInfo( "Attempt downloading two clashing files in parallel" );
# Enable parallelism
$ENV{OWNCLOUD_MAX_PARALLEL}="2";
my $tmpdir2 = "/tmp/t8/parallel/";
mkdir($tmpdir2);
createLocalFile( $tmpdir2 . "FILE.dat", 23251233 );
createLocalFile( $tmpdir2 . "file.dat", 33 );
createRemoteDir( "parallel" );
glob_put( "$tmpdir2/*", "parallel" );
# again, can't download both
csync(1);
# only one file must exist
assert( (!-e localDir() . 'parallel/FILE.dat' ) or (!-e localDir() . 'parallel/file.dat') );
assert( (-e localDir() . 'parallel/FILE.dat' ) or (-e localDir() . 'parallel/file.dat') );
cleanup();
system("rm -r " . $tmpdir);

View file

@ -1,92 +0,0 @@
#!/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 File::Copy;
use ownCloud::Test;
use strict;
print "Hello, this is t9, a tester for content checksums.\n";
initTesting();
printInfo( "Add some files to local");
my $locDir = localDir();
copy( "testfiles/test.txt", "$locDir/test.txt");
copy( "testfiles/test.txt", "$locDir/test.eml");
csync( );
print "\nAssert local and remote dirs.\n";
assertLocalAndRemoteDir( '', 0);
# Get file properties before syncing again
my $txtpropbefore = remoteFileProp("", "test.txt");
my $emlpropbefore = remoteFileProp("", "test.eml");
assert($txtpropbefore);
assert($emlpropbefore);
printInfo( "Touch local files");
system( "sleep 1" );
system( "touch $locDir/test.txt" );
system( "touch $locDir/test.eml" );
csync( );
# Get file properties afterwards
my $txtpropafter = remoteFileProp("", "test.txt");
my $emlpropafter = remoteFileProp("", "test.eml");
assert($txtpropafter);
assert($emlpropafter);
# The txt file is uploaded normally, etag and mtime differ
assert($txtpropafter->get_property( "getetag" ) ne
$txtpropbefore->get_property( "getetag" ));
assert($txtpropafter->get_property( "getlastmodified" ) ne
$txtpropbefore->get_property( "getlastmodified" ));
# The eml was not uploaded, nothing differs
assert($emlpropafter->get_property( "getetag" ) eq
$emlpropbefore->get_property( "getetag" ));
assert($emlpropafter->get_property( "getlastmodified" ) eq
$emlpropbefore->get_property( "getlastmodified" ));
printInfo( "Change content of eml file (but not size)");
system( "sleep 1 && sed -i -e 's/in/IN/' $locDir/test.eml" );
csync( );
# Get file properties afterwards
my $emlpropchanged = remoteFileProp("", "test.eml");
assert($emlpropchanged);
assert($emlpropafter->get_property( "getetag" ) ne
$emlpropchanged->get_property( "getetag" ));
assert($emlpropafter->get_property( "getlastmodified" ) ne
$emlpropchanged->get_property( "getlastmodified" ));
# ==================================================================
cleanup();
# --

View file

@ -1,95 +0,0 @@
#!/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 Olivier Goffart <ogoffart@woboq.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 File::Copy;
use ownCloud::Test;
use strict;
print "Hello, this is t_recall, a tester for the recall feature\n";
initTesting();
printInfo( "Syncing two files with the same name that differ with case" );
#create some files
my $tmpdir = "/tmp/t_recall/";
mkdir($tmpdir);
createLocalFile( $tmpdir . "file1.dat", 100 );
createLocalFile( $tmpdir . "file2.dat", 150 );
createLocalFile( $tmpdir . "file3.dat", 110 );
createLocalFile( $tmpdir . "file4.dat", 170 );
#put them in some directories
createRemoteDir( "dir" );
glob_put( "$tmpdir/*", "dir" );
csync();
assertLocalAndRemoteDir( '', 0);
printInfo( "Testing with a .sys.admin#recall#" );
system("echo 'dir/file2.dat' > ". $tmpdir . ".sys.admin\#recall\#");
system("echo 'dir/file3.dat' >> ". $tmpdir . ".sys.admin\#recall\#");
system("echo 'nonexistant' >> ". $tmpdir . ".sys.admin\#recall\#");
system("echo '/tmp/t_recall/file4.dat' >> ". $tmpdir . ".sys.admin\#recall\#");
glob_put( "$tmpdir/.sys.admin\#recall\#", "" );
csync();
#test that the recall files have been created
assert( -e glob(localDir().'dir/file2_.sys.admin#recall#-*.dat' ) );
assert( -e glob(localDir().'dir/file3_.sys.admin#recall#-*.dat' ) );
# verify that the original files still exist
assert( -e glob(localDir().'dir/file2.dat' ) );
assert( -e glob(localDir().'dir/file3.dat' ) );
assert( !-e glob(localDir().'nonexistant*' ) );
assert( !-e glob('/tmp/t_recall/file4_.sys.admin#recall#-*.dat' ) );
assert( -e glob('/tmp/t_recall/file4.dat' ) );
#Remove the recall file
unlink(localDir() . ".sys.admin#recall#");
# 2 sync necessary for the recall to be uploaded
csync();
assertLocalAndRemoteDir( '', 0);
printInfo( "Testing with a dir/.sys.admin#recall#" );
system("echo 'file4.dat' > ". $tmpdir . ".sys.admin\#recall\#");
glob_put( "$tmpdir/.sys.admin\#recall\#", "dir" );
csync();
assert( -e glob(localDir().'dir/file4_.sys.admin#recall#-*.dat' ) );
cleanup();
system("rm -r " . $tmpdir);

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

View file

@ -1,11 +0,0 @@
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur

View file

@ -1 +0,0 @@
A nice document.

View file

@ -1,16 +0,0 @@
freitag@zora:~>
Message from syslogd@zora at Sep 20 21:35:41 ...
kernel:[ 6702.458047] general protection fault: 0000 [#1] PREEMPT SMP
Message from syslogd@zora at Sep 20 21:35:41 ...
kernel:[ 6702.458060] last sysfs file: /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:03/ATK0110:00/hwmon/hwmon0/temp1_label
Message from syslogd@zora at Sep 20 21:35:41 ...
kernel:[ 6702.458232] Stack:
Message from syslogd@zora at Sep 20 21:35:41 ...
kernel:[ 6702.458262] Call Trace:
Message from syslogd@zora at Sep 20 21:35:41 ...
kernel:[ 6702.458375] Code: 00 00 80 00 00 00 48 b9 00 00 00 00 80 ff ff ff 4e 8d 34 30 49 21 ce 48 8b 4c 24 38 49 8d 56 ff 48 3b 54 24 48 4c 0f 43 74 24 40 <48> 8b 11 48 85 d2 0f 84 d4 01 00 00 48 b9 fb 0f 00 00 00 c0 ff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

View file

@ -1 +0,0 @@
A new text.

View file

@ -1 +0,0 @@
hello Olivier

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB