3 # Cumulus: Efficient Filesystem Backup to the Cloud
4 # Copyright (C) 2012 The Cumulus Developers
5 # See the AUTHORS file for a list of contributors.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 # Perform a simple Cumulus integration test: create a sample file tree, create
22 # a backup, modify the files, create a new backup, then try restoring and
23 # compare with the original state.
25 # Directory containing test scripts
26 TEST_DIR="$(readlink -f "$(dirname "$0")")"
28 # Directory containing Cumulus binaries
29 BIN_DIR="$(readlink -f "$TEST_DIR/..")"
31 # Directory where temporary files used for the tests can be stored.
32 TMP_DIR="$(readlink -f "$(mktemp -d cumulus-tests.XXXXXX)")"
34 # Command to use for running memory leak tests.
35 VALGRIND="valgrind --tool=memcheck --leak-check=full --log-file=$TMP_DIR/valgrind.log"
39 echo "================================================================"
43 log_action "Starting tests: BIN_DIR=$BIN_DIR TMP_DIR=$TMP_DIR"
45 log_action "Initializing local database..."
46 LOCALDB="$TMP_DIR/database"
48 sqlite3 -init "$BIN_DIR/schema.sql" "$LOCALDB/localdb.sqlite" ".exit"
50 log_action "Creating test file system tree..."
53 cp "$BIN_DIR"/*.cc "$BIN_DIR"/*.h "$TREE"
54 cp -a "$BIN_DIR/python" "$TREE"
55 "$TEST_DIR"/digest_tree "$TREE" >"$TMP_DIR/digest.1"
57 log_action "Running initial backup..."
59 BACKUP_DIR="$TMP_DIR/backups"
61 "$BIN_DIR"/cumulus --dest="$BACKUP_DIR" --localdb="$LOCALDB" \
62 --scheme=test -v "$TREE"
64 log_action "Modifying files..."
66 cp -a "$BIN_DIR/third_party" "$TREE"
67 "$TEST_DIR"/digest_tree "$TREE" >"$TMP_DIR/digest.2"
69 log_action "Running second backup..."
71 BACKUP_DIR="$TMP_DIR/backups"
73 $VALGRIND "$BIN_DIR"/cumulus --dest="$BACKUP_DIR" --localdb="$LOCALDB" \
74 --scheme=test -v "$TREE"
76 log_action "Restoring snapshots"
77 export LBS_GPG_PASSPHRASE=""
78 snapshots=$("$BIN_DIR"/cumulus-util --store="$BACKUP_DIR" list-snapshots)
79 echo "Available snapshots:" $snapshots
81 for s in $snapshots; do
83 dest="$TMP_DIR/restore-$i"
85 "$BIN_DIR"/cumulus-util --store="$BACKUP_DIR" restore-snapshot $s "$dest"