New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
00-basic.t in vendors/t/fcm-backup-svn-repos – NEMO

source: vendors/t/fcm-backup-svn-repos/00-basic.t @ 10669

Last change on this file since 10669 was 10669, checked in by nicolasmartin, 5 years ago

Import latest FCM release from Github into the repository for testing

File size: 4.0 KB
Line 
1#!/bin/bash
2#-------------------------------------------------------------------------------
3# (C) British Crown Copyright 2006-17 Met Office.
4#
5# This file is part of FCM, tools for managing and building source code.
6#
7# FCM 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 3 of the License, or
10# (at your option) any later version.
11#
12# FCM 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.
16#
17# You should have received a copy of the GNU General Public License
18# along with FCM. If not, see <http://www.gnu.org/licenses/>.
19#-------------------------------------------------------------------------------
20# Basic tests for "fcm-backup-svn-repos".
21#-------------------------------------------------------------------------------
22. $(dirname $0)/test_header
23#-------------------------------------------------------------------------------
24if ! which svnadmin 1>/dev/null 2>/dev/null; then
25    skip_all 'svnadmin not available'
26fi
27tests 32
28#-------------------------------------------------------------------------------
29set -e
30mkdir -p etc srv/svn var/svn/{backups,cache,dumps}
31# Configuration
32export FCM_CONF_PATH="$PWD/etc"
33cat >etc/admin.cfg <<__CONF__
34svn_backup_dir=$PWD/var/svn/backups
35svn_dump_dir=$PWD/var/svn/dumps
36svn_live_dir=$PWD/srv/svn
37__CONF__
38# Create some repositories and populate them
39# Repository 1
40svnadmin create srv/svn/bar
41svn co -q file://$PWD/srv/svn/bar
42echo 'A man walks into a bar.' >bar/walk
43echo 'Barley drink.' >bar/barley
44svn add -q bar/*
45svn ci -q -m'test 1' bar
46svnadmin dump srv/svn/bar -r 1 --incremental --deltas -q \
47        | gzip >var/svn/dumps/bar-1.gz
48# Repository 2
49svnadmin create srv/svn/foo
50svn co -q file://$PWD/srv/svn/foo
51echo 'Food is yummy.' >foo/food
52svn add -q foo/*
53svn ci -q -m'test 1' foo
54svnadmin dump srv/svn/foo -r 1 --incremental --deltas -q \
55    | gzip >var/svn/dumps/foo-1.gz
56rm -fr bar foo
57set +e
58
59run_tests() {
60    local TEST_KEY=$1
61    run_pass "$TEST_KEY" "$FCM_HOME/sbin/fcm-backup-svn-repos"
62    for NAME in bar foo; do
63        file_test "$TEST_KEY-$NAME" var/svn/backups/$NAME.tgz
64        tar -xzf var/svn/backups/$NAME.tgz
65        svnlook youngest srv/svn/$NAME >"$TEST_KEY-$NAME.youngest.orig"
66        svnlook youngest $NAME >"$TEST_KEY-$NAME.youngest"
67        file_cmp "$TEST_KEY-$NAME.youngest" \
68            "$TEST_KEY-$NAME.youngest" "$TEST_KEY-$NAME.youngest.orig"
69        rm -fr $NAME
70        for REV in $(seq 1 $(<"$TEST_KEY-$NAME.youngest")); do
71            run_fail "$TEST_KEY-dumps-$NAME-$REV" ls var/svn/dumps/$NAME-$REV.gz
72        done
73    done
74}
75#-------------------------------------------------------------------------------
76run_tests "$TEST_KEY_BASE-1-1"
77run_tests "$TEST_KEY_BASE-1-2" # Re-run test
78#-------------------------------------------------------------------------------
79# Add more stuffs to repository 1
80svn co -q file://$PWD/srv/svn/bar
81for REV in {2..9}; do
82    echo "$REV men walk into a bar." >bar/walk
83    svn ci -m"test: $REV" bar/walk
84    svnadmin dump srv/svn/bar -r $REV --incremental --deltas -q \
85            | gzip >var/svn/dumps/bar-$REV.gz
86done
87# Add more stuffs to a copy of repository 1, to generate some more dumps To
88# prove that command will not housekeep dumps that are newer than the backed up
89# youngest.
90svnadmin hotcopy srv/svn/bar var/svn/cache/bar
91svn relocate file://$PWD/srv/svn/bar file://$PWD/var/svn/cache/bar bar
92for REV in {10..12}; do
93    echo "$REV men walk into a bar." >bar/walk
94    svn ci -m"test: $REV" bar/walk
95    svnadmin dump var/svn/cache/bar -r $REV --incremental --deltas -q \
96            | gzip >var/svn/dumps/bar-$REV.gz
97done
98run_tests "$TEST_KEY_BASE-2-1"
99for REV in {10..12}; do
100    file_test "$TEST_KEY_BASE-2-1-dumps-bar-$REV" var/svn/dumps/bar-$REV.gz
101done
102#-------------------------------------------------------------------------------
103exit
Note: See TracBrowser for help on using the repository browser.