From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: David Michael Barr <david.barr@cordelta.com>,
Jonathan Nieder <jrnieder@gmail.com>,
Sverre Rabbelier <srabbelier@gmail.com>,
avarab@gmail.com, Daniel Shahaf <d.s@daniel.shahaf.name>,
Bert Huijben <rhuijben@collab.net>,
Junio C Hamano <gitster@pobox.com>,
Eric Wong <normalperson@yhbt.net>,
Will Palmer <wpalmer@gmail.com>, Greg Stein <gstein@gmail.com>
Subject: [PATCH 9/9] Add a validation script
Date: Wed, 14 Jul 2010 01:36:16 +0200 [thread overview]
Message-ID: <1279064176-6645-10-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1279064176-6645-1-git-send-email-artagnon@gmail.com>
From: Will Palmer <wpalmer@gmail.com>
Add a validation script. Using an existing dump known to be correct
(possibly generated using `svnsync` and `svnadmin dump --deltas`), it
compares the outputs produced by `svnadmin load` when fed with this
dump and the dump from the program.
The arguments added are:
--svnadmin-dump=<file> existing "svnadmin dump"
--svndumpr-dump=<file> existing "svndumpr" dump
--repos=<url-or-path> SVN repos URL, or local repos
-r<revision> end revision to dump/cut
--ignore-existing regenerate svnadmin-dump even if
it already exists
--make run "make svndumpr" prior to svnrdump
generate as with the old parameter, but now
implied by default
validate as with the old parameter, but now
implied by default
The end result is that the only step technically needed to test
validation is:
./validate.sh --make --repos=/path/to/local/repos
Signed-off-by: Will Palmer <wpalmer@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
validate.sh | 226 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 226 insertions(+), 0 deletions(-)
create mode 100755 validate.sh
diff --git a/validate.sh b/validate.sh
new file mode 100755
index 0000000..6bdb427
--- /dev/null
+++ b/validate.sh
@@ -0,0 +1,226 @@
+#!/bin/sh
+usage(){
+ sed 's/..//' <<USAGE
+ Usage: validate.sh [--svnadmin-dump=<file>] [--svnrdump-dump=<file>]
+ [--repos=<url-or-path>] [-r<revision>]
+ [--ignore-existing-dump] [--make]
+ [generate] [validate]
+USAGE
+}
+
+svnadmin_dump=
+svnrdump_dump=
+repos_url=
+repos_path=
+end_rev=
+do_make=
+do_both=1
+do_generate=1
+do_validate=1
+do_ignore_existing_svnadmin_dump=
+while test "$#" -gt 0; do
+ case "$1" in
+ --svnadmin-dump=*)
+ svnadmin_dump="${1#*=}"
+ ;;
+ --svnrdump-dump=*)
+ svnrdump_dump="${1#*=}"
+ ;;
+ --ignore-existing|--ignore-existing-dump)
+ do_ignore_existing_svnadmin_dump=1
+ ;;
+ --repos=*)
+ repos_url="${1#*=}"
+ repos_protocol="${repos_url%://*}"
+ repos_path="${repos_url#file://}"
+ if test "$repos_protocol" = "$repos_path"; then
+ repos_protocol=
+ repos_url=
+ elif test ! "$repos_protocol" = 'file'; then
+ repos_path=
+ fi
+ ;;
+ -r*)
+ end_rev="${1#-r}"
+ ;;
+ --make)
+ do_make=1
+ ;;
+ generate)
+ do_generate=1
+ test -n "$do_both" && do_validate=
+ do_both=
+ ;;
+ validate)
+ do_validate=1
+ test -n "$do_both" && do_generate=
+ do_both=
+ ;;
+ -h|--help)
+ usage
+ exit
+ ;;
+ *)
+ echo "unknown option $1" >&2
+ usage >&2
+ exit 1
+ esac
+ shift
+done
+
+if test -z "$svnrdump_dump"; then
+ if test -z "$repos_url"; then
+ if test -n "$repos_path"; then
+ repos_url="file://$(readlink -f "$repos_path")"
+ if test $? -ne 0; then
+ echo "error: unable to derive repos url from path" >&2
+ echo "--svnrdump_dump=<file> or a local (file://) --repos=<url> is required" >&2
+ exit 1
+ fi
+ else
+ echo "--svnrdump_dump=<file> or a local (file://) --repos=<url> is required" >&2
+ exit 1
+ fi
+ fi
+fi
+
+svnadmin_dump_cut="t/svnadmin-$end_rev.dump"
+svnrdump_dump_cut="t/svnrdump-$end_rev.dump"
+mkdir t 2>/dev/null
+
+if test -z "$svnadmin_dump"; then
+ if test -z "$repos_path"; then
+ echo "--svnadmin_dump=<file> or a local (file://) --repos=<url> is required" >&2
+ usage >&2
+ exit 1
+ fi
+
+ svnadmin_dump="$svnadmin_dump_cut"
+ if test -z "$do_ignore_existing_svnadmin_dump" && test -r "$svnadmin_dump"; then
+ echo "Using existing $svnadmin_dump"
+ else
+ echo "Generating $svnadmin_dump ..."
+
+ r=
+ if test -n "$end_rev"; then
+ r="-r0:$end_rev"
+ else
+ r="-r0:HEAD"
+ fi
+
+ svnadmin dump --deltas $r "$repos_path" > "$svnadmin_dump"
+ if test $? -ne 0; then
+ echo "error: failed to create canonical dump for comparison" >&2
+ exit 1
+ fi
+ fi
+else
+ echo "Using specified $svnadmin_dump"
+fi
+
+if test -z "$svnrdump_dump"; then
+ svnrdump_dump="$svnrdump_dump_cut"
+
+ if test -n "$do_make"; then
+ make svnrdump > /dev/null;
+ if test $? -ne 0; then
+ echo "error: Make failed. Check the program." >&2
+ exit 1;
+ fi
+ fi
+
+ echo "Generating $svnrdump_dump ..."
+
+ r=
+ test -n "$end_rev" && r="-r0:$end_rev"
+
+ ./svnrdump -v $r "$repos_url" > "$svnrdump_dump"
+ if test $? -ne 0; then
+ echo "error: failed to create dump for validation" >&2
+ exit 1
+ fi
+else
+ echo "Using specified $svnrdump_dump"
+fi
+
+cut_dump(){
+ r="$1"
+ test -z "$r" && r=-1
+
+ gawk '
+ BEGIN {
+ max='"$r"'
+ hit_max=0
+ }
+ /^Revision-number: [0-9][0-9]*$/ {
+ rev=$2
+ if (rev == max) {
+ hit_max=1
+ } else if ( hit_max ) {
+ exit
+ }
+ }
+ { print $0 }
+ END {
+ if (max == -1 || hit_max) {
+ exit 0
+ }
+ exit 1
+ }'
+}
+
+if test ! "$svnadmin_dump" = "$svnadmin_dump_cut"; then
+ cut_dump "$end_rev" <"$svnadmin_dump" >"$svnadmin_dump_cut"
+ if test $? -ne 0; then
+ echo "error: failed to cut canonical dump $svnadmin_dump for comparison" >&2
+ exit 1
+ fi
+ echo "Successfully generated cut canonical dump $svnadmin_dump_cut for comparison" >&2
+fi
+
+echo "Comparing canonical and svnrdump-based dumps..."
+diff -au "$svnadmin_dump_cut" "$svnrdump_dump" > t/dump-diff.error
+gawk \
+ '$0 !~ "Prop-delta: true|Text-delta-base-|sha1|Text-copy-source-|^-$" && $0 ~ "^+|^-" { print; }' \
+ t/dump-diff.error >t/dump-diff-filtered.error;
+
+if test -n "$do_generate"; then
+ echo "Generating canonical import logs..."
+
+ rm -rf t/repo;
+ mkdir t/repo;
+ svnadmin create t/repo;
+
+ svnadmin load t/repo < "$svnadmin_dump_cut" \
+ 1>"$svnadmin_dump_cut.import.log" 2>"$svnadmin_dump_cut.import.error";
+ if test $? -ne 0; then
+ echo "error: Load $end_rev failed. See $svnadmin_dump_cut.import.* for details" >&2
+ exit 1
+ fi
+ echo "Successfully generated canonical repository for comparison."
+fi
+
+if test -n "$do_validate"; then
+ echo "Generating svnrdump-based import logs..."
+
+ log_prefix=t/svnrdump-$end_rev
+
+ rm -rf t/repo;
+ mkdir t/repo;
+ svnadmin create t/repo;
+
+ svnadmin load t/repo < "$svnrdump_dump" 1>"$log_prefix.import.log" 2>"$log_prefix.import.error";
+ if test $? -ne 0; then
+ echo "error: Load $end_rev failed. See $log_prefix.import.* for details" >&2
+ exit 1
+ fi
+ echo "Successfully loaded svnrdump-based repository for validation"
+
+ echo "Comparing canonical and svnrdump-based import logs..."
+ diff -au "$svnadmin_dump_cut.import.log" "$log_prefix.import.log" > t/import-diff.error;
+ if test $? -ne 0; then
+ echo "Validation failed. See t/import-diff.error for details." >&2
+ exit 1
+ fi
+ echo "Validation successful"
+fi
--
1.7.1
next prev parent reply other threads:[~2010-07-13 23:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-13 23:36 [PATCH 0/9] Get svnrdump merged into git.git Ramkumar Ramachandra
2010-07-13 23:36 ` [PATCH 1/9] Add LICENSE Ramkumar Ramachandra
2010-07-14 4:47 ` Daniel Shahaf
2010-07-14 11:23 ` Ramkumar Ramachandra
2010-07-13 23:36 ` [PATCH 2/9] Add skeleton SVN client and Makefile Ramkumar Ramachandra
2010-07-13 23:36 ` [PATCH 3/9] Add debug editor from Subversion trunk Ramkumar Ramachandra
2010-07-13 23:36 ` [PATCH 4/9] Drive the debug editor Ramkumar Ramachandra
2010-07-13 23:36 ` [PATCH 5/9] Dump the revprops at the start of every revision Ramkumar Ramachandra
2010-07-13 23:36 ` [PATCH 6/9] Implement directory-related functions Ramkumar Ramachandra
2010-07-13 23:36 ` [PATCH 7/9] Implement file-related functions Ramkumar Ramachandra
2010-07-13 23:36 ` [PATCH 8/9] Implement close_file Ramkumar Ramachandra
2010-07-13 23:36 ` Ramkumar Ramachandra [this message]
2010-07-13 23:58 ` [PATCH 0/9] Get svnrdump merged into git.git Ramkumar Ramachandra
2010-07-14 0:15 ` Jonathan Nieder
2010-07-14 0:22 ` Ramkumar Ramachandra
2010-07-14 0:28 ` Jonathan Nieder
2010-07-14 0:49 ` Ramkumar Ramachandra
2010-07-14 7:03 ` Stefan Sperling
2010-07-14 11:26 ` Ramkumar Ramachandra
2010-07-14 12:55 ` Stefan Sperling
2010-07-14 14:54 ` Junio C Hamano
2010-07-15 10:55 ` Ramkumar Ramachandra
[not found] ` <20100806175709.GA2683@burratino>
2010-08-06 18:37 ` [PATCH svnrdump-standalone] Sync with upstream Jonathan Nieder
2010-08-07 2:30 ` Jonathan Nieder
2010-08-07 2:47 ` Ramkumar Ramachandra
2010-08-07 2:51 ` Ramkumar Ramachandra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1279064176-6645-10-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=avarab@gmail.com \
--cc=d.s@daniel.shahaf.name \
--cc=david.barr@cordelta.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=gstein@gmail.com \
--cc=jrnieder@gmail.com \
--cc=normalperson@yhbt.net \
--cc=rhuijben@collab.net \
--cc=srabbelier@gmail.com \
--cc=wpalmer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).