summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-11 21:33:34 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-11 21:33:34 +0000
commit73d24ff28e1561fb000edce42965b439bc04f53b (patch)
tree929454750af7ae2a48a80fac592afe12b3b39b25 /rdiff-backup/testing
parentf6e83fa5b76594ab9dff64ee450087883c16b897 (diff)
downloadrdiff-backup-73d24ff28e1561fb000edce42965b439bc04f53b.tar.gz
Various final bug fixes for 0.7.4
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@79 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing')
-rw-r--r--rdiff-backup/testing/commontest.py15
-rw-r--r--rdiff-backup/testing/incrementtest.py74
-rw-r--r--rdiff-backup/testing/restoretest.py5
-rw-r--r--rdiff-backup/testing/robusttest.py2
-rw-r--r--rdiff-backup/testing/roottest.py2
5 files changed, 83 insertions, 15 deletions
diff --git a/rdiff-backup/testing/commontest.py b/rdiff-backup/testing/commontest.py
index b1a1dc6..40acc2d 100644
--- a/rdiff-backup/testing/commontest.py
+++ b/rdiff-backup/testing/commontest.py
@@ -127,7 +127,12 @@ def InternalRestore(mirror_local, dest_local, mirror_dir, dest_dir, time):
mirror_rp, dest_rp = SetConnections.InitRPs([mirror_dir, dest_dir],
remote_schema)
- _get_main().Restore(get_increment_rp(mirror_rp, time), dest_rp)
+ inc = get_increment_rp(mirror_rp, time)
+ if inc:
+ _get_main().Restore(get_increment_rp(mirror_rp, time), dest_rp)
+ else: # use alternate syntax
+ _get_main().restore_timestr = str(time)
+ _get_main().RestoreAsOf(mirror_rp, dest_rp)
_get_main().cleanup()
def get_increment_rp(mirror_rp, time):
@@ -135,11 +140,9 @@ def get_increment_rp(mirror_rp, time):
data_rp = mirror_rp.append("rdiff-backup-data")
for filename in data_rp.listdir():
rp = data_rp.append(filename)
- if (rp.isincfile() and rp.getincbase_str() == "increments" and
- Time.stringtotime(rp.getinctime()) == time):
- return rp
- assert None, ("No increments.XXX.dir found in directory "
- "%s with that time" % data_rp.path)
+ if rp.isincfile() and rp.getincbase_str() == "increments":
+ if Time.stringtotime(rp.getinctime()) == time: return rp
+ return None # Couldn't find appropriate increment
def _reset_connections(src_rp, dest_rp):
"""Reset some global connection information"""
diff --git a/rdiff-backup/testing/incrementtest.py b/rdiff-backup/testing/incrementtest.py
index e53e532..96d7811 100644
--- a/rdiff-backup/testing/incrementtest.py
+++ b/rdiff-backup/testing/incrementtest.py
@@ -1,12 +1,12 @@
import unittest, os
execfile("commontest.py")
-rbexec("increment.py")
+rbexec("main.py")
lc = Globals.local_connection
Globals.change_source_perms = 1
-Log.setverbosity(7)
+Log.setverbosity(4)
def getrp(ending):
return RPath(lc, "testfiles/various_file_types/" + ending)
@@ -162,4 +162,74 @@ class inctest(unittest.TestCase):
out2.delete()
out_gz.delete()
+class inctest2(unittest.TestCase):
+ """Like inctest but contains more elaborate tests"""
+ def testStatistics(self):
+ """Test the writing of statistics
+
+ The file sizes are approximate because the size of directories
+ could change with different file systems...
+
+ """
+ Globals.compression = 1
+ Myrm("testfiles/output")
+ InternalBackup(1, 1, "testfiles/stattest1", "testfiles/output")
+ InternalBackup(1, 1, "testfiles/stattest2", "testfiles/output")
+
+ inc_base = RPath(Globals.local_connection,
+ "testfiles/output/rdiff-backup-data/increments")
+
+ incs = Restore.get_inclist(inc_base.append("subdir").
+ append("directory_statistics"))
+ assert len(incs) == 1
+ subdir_stats = self.parse_statistics(incs[0])
+ assert subdir_stats.total_files == 2, subdir_stats.total_files
+ assert 350000 < subdir_stats.total_file_size < 450000, \
+ subdir_stats.total_file_size
+ assert subdir_stats.changed_files == 2, subdir_stats.changed_files
+ assert 350000 < subdir_stats.changed_file_size < 450000, \
+ subdir_stats.changed_file_size
+ assert 10 < subdir_stats.increment_file_size < 20000, \
+ subdir_stats.increment_file_size
+
+ incs = Restore.get_inclist(inc_base.append("directory_statistics"))
+ assert len(incs) == 1
+ root_stats = self.parse_statistics(incs[0])
+ assert root_stats.total_files == 6, root_stats.total_files
+ assert 650000 < root_stats.total_file_size < 750000, \
+ root_stats.total_file_size
+ assert root_stats.changed_files == 4, root_stats.changed_files
+ assert 550000 < root_stats.changed_file_size < 650000, \
+ root_stats.changed_file_size
+ assert 10 < root_stats.increment_file_size < 20000, \
+ root_stats.increment_file_size
+
+ def parse_statistics(self, statrp):
+ """Return StatObj from given statrp"""
+ assert statrp.isincfile() and statrp.getinctype() == "data"
+ s = StatObj()
+ fp = statrp.open("r")
+ for line in fp:
+ lsplit = line.split()
+ assert len(lsplit) == 2
+ field, num = lsplit[0], long(lsplit[1])
+ if field == "TotalFiles": s.total_files = num
+ elif field == "TotalFileSize": s.total_file_size = num
+ elif field == "ChangedFiles": s.changed_files = num
+ elif field == "ChangedFileSize": s.changed_file_size = num
+ elif field == "IncrementFileSize": s.increment_file_size = num
+ else: assert None, "Unrecognized field %s" % (field,)
+ assert not fp.close()
+ return s
+
+
+class StatObj:
+ """Just hold various statistics"""
+ total_files = 0
+ total_file_size = 0
+ changed_files = 0
+ changed_file_size = 0
+ increment_file_size = 0
+
+
if __name__ == '__main__': unittest.main()
diff --git a/rdiff-backup/testing/restoretest.py b/rdiff-backup/testing/restoretest.py
index 1a314eb..aaf84b8 100644
--- a/rdiff-backup/testing/restoretest.py
+++ b/rdiff-backup/testing/restoretest.py
@@ -74,13 +74,8 @@ class RestoreTest(unittest.TestCase):
assert inc.isincfile()
inctime = Time.stringtotime(inc.getinctime())
rid1 = RestoreIncrementData(basename, incbase, incs)
- rid2 = RestoreIncrementData(basename, incbase, incs)
rid1.sortincseq(inctime, mirror_time)
- rid2.sortincseq(inctime + 5, mirror_time)
assert rid1.inc_list, rid1.inc_list
- # Five seconds later shouldn't make a difference
- assert rid1.inc_list == rid2.inc_list, (rid1.inc_list,
- rid2.inc_list)
# oldest increment should be exactly inctime
ridtime = Time.stringtotime(rid1.inc_list[-1].getinctime())
assert ridtime == inctime, (ridtime, inctime)
diff --git a/rdiff-backup/testing/robusttest.py b/rdiff-backup/testing/robusttest.py
index 4f08e44..2a54952 100644
--- a/rdiff-backup/testing/robusttest.py
+++ b/rdiff-backup/testing/robusttest.py
@@ -76,7 +76,7 @@ class SaveStateTest(unittest.TestCase):
SaveState.record_last_file_action(last_rorp).execute()
sym_rp = RPath(Globals.local_connection,
- "testfiles/robust/last-file-mirrored.%s.snapshot" %
+ "testfiles/robust/last-file-mirrored.%s.data" %
Time.curtimestr)
assert sym_rp.issym()
assert sym_rp.readlink() == "increments/usr/local/bin/ls"
diff --git a/rdiff-backup/testing/roottest.py b/rdiff-backup/testing/roottest.py
index 29ea2be..3f60544 100644
--- a/rdiff-backup/testing/roottest.py
+++ b/rdiff-backup/testing/roottest.py
@@ -13,7 +13,7 @@ Globals.counter = 0
Log.setverbosity(4)
class RootTest(unittest.TestCase):
- dirlist1 = ["testfiles/root", "testfiles/noperms", "testfiles/increment4"]
+ dirlist1 = ["testfiles/root", "testfiles/various_file_types", "testfiles/increment4"]
dirlist2 = ["testfiles/increment4", "testfiles/root",
"testfiles/increment1"]
def testLocal1(self): BackupRestoreSeries(1, 1, self.dirlist1)