summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2020-08-06 18:39:10 +0100
committerBen Hutchings <ben.hutchings@codethink.co.uk>2020-08-10 19:38:24 +0100
commit05925cc15a5905751d070c5c89af43e1b182f1f7 (patch)
tree544c8ab4b5b7f68a37ac2e318ed7091fcee0a97e /tests
parent0a03ee31ac71714e0fed217ad4f047f9ecc4e250 (diff)
downloadlorry-05925cc15a5905751d070c5c89af43e1b182f1f7.tar.gz
tests: Add test case for migration of old-style working repositories
Make sure migration of existing working directories to the A/B scheme works properly.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/migrate-oldstyle-repos.script42
-rwxr-xr-xtests/migrate-oldstyle-repos.setup56
-rw-r--r--tests/migrate-oldstyle-repos.stdout45
-rwxr-xr-xtests/migrate-oldstyle-repos.teardown21
4 files changed, 164 insertions, 0 deletions
diff --git a/tests/migrate-oldstyle-repos.script b/tests/migrate-oldstyle-repos.script
new file mode 100755
index 0000000..c6be1be
--- /dev/null
+++ b/tests/migrate-oldstyle-repos.script
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# Tests migration of old-style working repositories
+#
+# Copyright (C) 2012-2013, 2020 Codethink Limited
+#
+# 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; version 2 of the License.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+set -e
+set -o pipefail
+
+repo_name="migrate-test-repo"
+logfile="$DATADIR/$repo_name.log"
+workdir="$DATADIR/work-dir"
+repo="$DATADIR/$repo_name"
+
+normalize() {
+ sed -r -e '/hooks\/.*\.sample/d' \
+ -e "s/pack-[0-9a-z]+\.(idx|pack)$/pack-file/" \
+ -e "/\/objects\/info\/commit-graph$/d" \
+ -e "/\/objects\/pack\/pack-[0-9a-z]+\.bitmap$/d" \
+ -e "s|$DATADIR|DATADIR|g" "$@"
+}
+
+# update it
+"${SRCDIR}/test-lorry" --pull-only --log="$logfile" --working-area="$workdir" --bundle=never \
+ "$DATADIR/migrate-test-repo.lorry"
+
+find "$workdir/migrate-test-repo" | LC_ALL=C sort | normalize
+grep -H . "$workdir/migrate-test-repo/git"*"/lorry-update-count" | normalize
diff --git a/tests/migrate-oldstyle-repos.setup b/tests/migrate-oldstyle-repos.setup
new file mode 100755
index 0000000..eea87eb
--- /dev/null
+++ b/tests/migrate-oldstyle-repos.setup
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Tests migration of old-style working repositories
+#
+# Copyright (C) 2012-2013, 2020 Codethink Limited
+#
+# 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; version 2 of the License.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+set -e
+
+# create the repository
+repo="$DATADIR/migrate-test-repo"
+mkdir "$repo"
+cd "$repo"
+git init --quiet
+
+# add the test file
+echo "first line" > test.txt
+git add test.txt
+
+# make a commit
+git commit --quiet -m "first commit"
+
+# create the .lorry file for the repository
+cat <<EOF > $DATADIR/migrate-test-repo.lorry
+{
+ "migrate-test-repo": {
+ "type": "git",
+ "url": "file://$repo"
+ }
+}
+EOF
+
+# create the working directory
+workdir="$DATADIR/work-dir"
+test -d "$workdir" || mkdir "$workdir"
+
+# create old-style working repositories
+for work_repo in "$workdir/migrate-test-repo/git" \
+ "$workdir/migrate-test-repo/git-pre-update"; do
+ git init --bare "$work_repo"
+ git -C "$work_repo" fetch "$repo" '+refs/heads/*:refs/heads/*'
+ git -C "$work_repo" gc --aggressive
+done
diff --git a/tests/migrate-oldstyle-repos.stdout b/tests/migrate-oldstyle-repos.stdout
new file mode 100644
index 0000000..9402534
--- /dev/null
+++ b/tests/migrate-oldstyle-repos.stdout
@@ -0,0 +1,45 @@
+DATADIR/work-dir/migrate-test-repo
+DATADIR/work-dir/migrate-test-repo/git-a
+DATADIR/work-dir/migrate-test-repo/git-a/FETCH_HEAD
+DATADIR/work-dir/migrate-test-repo/git-a/HEAD
+DATADIR/work-dir/migrate-test-repo/git-a/branches
+DATADIR/work-dir/migrate-test-repo/git-a/config
+DATADIR/work-dir/migrate-test-repo/git-a/description
+DATADIR/work-dir/migrate-test-repo/git-a/hooks
+DATADIR/work-dir/migrate-test-repo/git-a/info
+DATADIR/work-dir/migrate-test-repo/git-a/info/exclude
+DATADIR/work-dir/migrate-test-repo/git-a/info/refs
+DATADIR/work-dir/migrate-test-repo/git-a/lorry-update-count
+DATADIR/work-dir/migrate-test-repo/git-a/objects
+DATADIR/work-dir/migrate-test-repo/git-a/objects/info
+DATADIR/work-dir/migrate-test-repo/git-a/objects/info/packs
+DATADIR/work-dir/migrate-test-repo/git-a/objects/pack
+DATADIR/work-dir/migrate-test-repo/git-a/objects/pack/pack-file
+DATADIR/work-dir/migrate-test-repo/git-a/objects/pack/pack-file
+DATADIR/work-dir/migrate-test-repo/git-a/packed-refs
+DATADIR/work-dir/migrate-test-repo/git-a/refs
+DATADIR/work-dir/migrate-test-repo/git-a/refs/heads
+DATADIR/work-dir/migrate-test-repo/git-a/refs/tags
+DATADIR/work-dir/migrate-test-repo/git-b
+DATADIR/work-dir/migrate-test-repo/git-b/FETCH_HEAD
+DATADIR/work-dir/migrate-test-repo/git-b/HEAD
+DATADIR/work-dir/migrate-test-repo/git-b/branches
+DATADIR/work-dir/migrate-test-repo/git-b/config
+DATADIR/work-dir/migrate-test-repo/git-b/description
+DATADIR/work-dir/migrate-test-repo/git-b/hooks
+DATADIR/work-dir/migrate-test-repo/git-b/info
+DATADIR/work-dir/migrate-test-repo/git-b/info/exclude
+DATADIR/work-dir/migrate-test-repo/git-b/info/refs
+DATADIR/work-dir/migrate-test-repo/git-b/lorry-update-count
+DATADIR/work-dir/migrate-test-repo/git-b/objects
+DATADIR/work-dir/migrate-test-repo/git-b/objects/info
+DATADIR/work-dir/migrate-test-repo/git-b/objects/info/packs
+DATADIR/work-dir/migrate-test-repo/git-b/objects/pack
+DATADIR/work-dir/migrate-test-repo/git-b/objects/pack/pack-file
+DATADIR/work-dir/migrate-test-repo/git-b/objects/pack/pack-file
+DATADIR/work-dir/migrate-test-repo/git-b/packed-refs
+DATADIR/work-dir/migrate-test-repo/git-b/refs
+DATADIR/work-dir/migrate-test-repo/git-b/refs/heads
+DATADIR/work-dir/migrate-test-repo/git-b/refs/tags
+DATADIR/work-dir/migrate-test-repo/git-a/lorry-update-count:1
+DATADIR/work-dir/migrate-test-repo/git-b/lorry-update-count:2
diff --git a/tests/migrate-oldstyle-repos.teardown b/tests/migrate-oldstyle-repos.teardown
new file mode 100755
index 0000000..19d1cb1
--- /dev/null
+++ b/tests/migrate-oldstyle-repos.teardown
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Tests migration of old-style working repositories
+#
+# Copyright (C) 2020 Codethink Limited
+#
+# 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; version 2 of the License.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+rm -r "$DATADIR/migrate-test-repo.log" "$DATADIR/work-dir"