dump user md5sum file and use it for test
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 10 Oct 2011 20:26:36 +0000 (22:26 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 10 Oct 2011 20:26:36 +0000 (22:26 +0200)
README
test.sh
user-md5sum.pl [new file with mode: 0755]

diff --git a/README b/README
index 478e424..5facca8 100644 (file)
--- a/README
+++ b/README
@@ -22,6 +22,9 @@ remove-user.sh
 test.sh
        - excercise rsync server to test basic operation and deduplication
 
+FULL=1 ./user-md5sum.pl u2001 | md5sum -c
+       - generates md5sum file for user with optional full paths for easy scrubing
+
 
 Installation on Debian:
 
diff --git a/test.sh b/test.sh
index 829c9a6..9781631 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -16,6 +16,7 @@ pull() {
 
 sudo ./remove-user.sh test@example.com
 sudo ./remove-user.sh test2@example.com
+base_dir=`pwd`
 
 RSYNC_LOGIN=`sudo ./create-user.sh test@example.com secret 500k`
 RSYNC_LOGIN2=`sudo ./create-user.sh test2@example.com secret 20k`
@@ -111,8 +112,6 @@ cp $pending .sync/pending/
 push .sync -rv
 
 
-fi # skip tests
-
 ps ax > perms-test
 chmod 400 perms-test
 push -va perms-test
@@ -120,3 +119,13 @@ push -va perms-test
 sudo sh -xc "ls -al ~$RSYNC_LOGIN/localhost/"
 
 pull
+
+
+fi # skip tests
+
+
+find /test/s1/2001/ -type f | grep -v '/\.' | xargs md5sum | sort > /tmp/test/1
+FULL=1 $base_dir/user-md5sum.pl u2001 | sort > /tmp/test/2
+
+diff /tmp/test/1 /tmp/test/2 && echo "OK - md5 database consistant with filesystem"
+
diff --git a/user-md5sum.pl b/user-md5sum.pl
new file mode 100755 (executable)
index 0000000..e120037
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use TokyoCabinet;
+use Data::Dump qw(dump);
+
+my $user = shift @ARGV || die "usage: $0 u2001\n";
+
+my $dir = (getpwnam($user))[7];
+
+die $! unless -d $dir;
+
+my $path = "$dir/.md5";
+
+die $! unless -r $path;
+
+my %h;
+tie %h, "TokyoCabinet::HDB", $path || die $!;
+
+while( my($k,$v) = each(%h) ) {
+       $k = "$dir/$k" if $ENV{FULL};
+       print "$v  $k\n";
+}
+