summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-29 07:10:00 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-05-29 07:10:00 +0000
commit316b6ac203137fc5740d1181c941aab1178eeaae (patch)
tree807cecf179d75705f413b33d9bcdcf5572005582
parent85792f3b028aebac6e2681a0ce5ab60f9d91f1ed (diff)
downloadrdiff-backup-316b6ac203137fc5740d1181c941aab1178eeaae.tar.gz
Reexamined robust writing and statistics, passes test
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@111 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r--rdiff-backup/testing/finaltest.py5
-rw-r--r--rdiff-backup/testing/highleveltest.py2
-rw-r--r--rdiff-backup/testing/incrementtest.py59
-rw-r--r--rdiff-backup/testing/regressiontest.py2
-rw-r--r--rdiff-backup/testing/statisticstest.py51
-rw-r--r--rdiff-backup/testing/timetest.py1
6 files changed, 76 insertions, 44 deletions
diff --git a/rdiff-backup/testing/finaltest.py b/rdiff-backup/testing/finaltest.py
index bf293dc..96c9728 100644
--- a/rdiff-backup/testing/finaltest.py
+++ b/rdiff-backup/testing/finaltest.py
@@ -149,8 +149,9 @@ class PathSetter(unittest.TestCase):
# Make sure too many increment files not created
assert len(self.getinc_paths("nochange.",
"testfiles/output/rdiff-backup-data/increments")) == 0
- assert len(self.getinc_paths("",
- "testfiles/output/rdiff-backup-data/increments/nochange")) == 1
+ nochange_incs = len(self.getinc_paths("",
+ "testfiles/output/rdiff-backup-data/increments/nochange"))
+ assert nochange_incs == 1 or nochange_incs == 0, nochange_incs
def getinc_paths(self, basename, directory):
"""Return increment.______.dir paths"""
diff --git a/rdiff-backup/testing/highleveltest.py b/rdiff-backup/testing/highleveltest.py
index 3bd10c3..1b79b90 100644
--- a/rdiff-backup/testing/highleveltest.py
+++ b/rdiff-backup/testing/highleveltest.py
@@ -8,7 +8,7 @@ class RemoteMirrorTest(unittest.TestCase):
"""Test mirroring"""
def setUp(self):
"""Start server"""
- Log.setverbosity(7)
+ Log.setverbosity(5)
Globals.change_source_perms = 1
SetConnections.UpdateGlobal('checkpoint_interval', 3)
diff --git a/rdiff-backup/testing/incrementtest.py b/rdiff-backup/testing/incrementtest.py
index 8c75ff7..c9ea903 100644
--- a/rdiff-backup/testing/incrementtest.py
+++ b/rdiff-backup/testing/incrementtest.py
@@ -6,7 +6,7 @@ rbexec("main.py")
lc = Globals.local_connection
Globals.change_source_perms = 1
-Log.setverbosity(4)
+Log.setverbosity(5)
def getrp(ending):
return RPath(lc, "testfiles/various_file_types/" + ending)
@@ -191,32 +191,33 @@ class inctest2(unittest.TestCase):
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) == 2
- s1 = StatsObj().read_stats_from_rp(incs[0]) # initial mirror stats
- assert s1.SourceFiles == 2
- assert 400000 < s1.SourceFileSize < 420000
- self.stats_check_initial(s1)
-
- subdir_stats = StatsObj().read_stats_from_rp(incs[1]) # increment stats
- assert subdir_stats.SourceFiles == 2
- assert 400000 < subdir_stats.SourceFileSize < 420000
- assert subdir_stats.MirrorFiles == 2
- assert 400000 < subdir_stats.MirrorFileSize < 420000
- assert subdir_stats.NewFiles == subdir_stats.NewFileSize == 0
- assert subdir_stats.DeletedFiles == subdir_stats.DeletedFileSize == 0
- assert subdir_stats.ChangedFiles == 2
- assert 400000 < subdir_stats.ChangedSourceSize < 420000
- assert 400000 < subdir_stats.ChangedMirrorSize < 420000
- assert 10 < subdir_stats.IncrementFileSize < 20000
-
- incs = Restore.get_inclist(inc_base.append("directory_statistics"))
+ InternalBackup(1, 1, "testfiles/stattest2", "testfiles/output",
+ time.time()+1)
+
+ rbdir = RPath(Globals.local_connection,
+ "testfiles/output/rdiff-backup-data")
+
+ #incs = Restore.get_inclist(rbdir.append("subdir").
+ # append("directory_statistics"))
+ #assert len(incs) == 2
+ #s1 = StatsObj().read_stats_from_rp(incs[0]) # initial mirror stats
+ #assert s1.SourceFiles == 2
+ #assert 400000 < s1.SourceFileSize < 420000
+ #self.stats_check_initial(s1)
+
+ #subdir_stats = StatsObj().read_stats_from_rp(incs[1]) # increment stats
+ #assert subdir_stats.SourceFiles == 2
+ #assert 400000 < subdir_stats.SourceFileSize < 420000
+ #assert subdir_stats.MirrorFiles == 2
+ #assert 400000 < subdir_stats.MirrorFileSize < 420000
+ #assert subdir_stats.NewFiles == subdir_stats.NewFileSize == 0
+ #assert subdir_stats.DeletedFiles == subdir_stats.DeletedFileSize == 0
+ #assert subdir_stats.ChangedFiles == 2
+ #assert 400000 < subdir_stats.ChangedSourceSize < 420000
+ #assert 400000 < subdir_stats.ChangedMirrorSize < 420000
+ #assert 10 < subdir_stats.IncrementFileSize < 20000
+
+ incs = Restore.get_inclist(rbdir.append("session_statistics"))
assert len(incs) == 2
s2 = StatsObj().read_stats_from_rp(incs[0])
assert s2.SourceFiles == 7
@@ -224,7 +225,7 @@ class inctest2(unittest.TestCase):
self.stats_check_initial(s2)
root_stats = StatsObj().read_stats_from_rp(incs[1])
- assert root_stats.SourceFiles == 7
+ assert root_stats.SourceFiles == 7, root_stats.SourceFiles
assert 550000 < root_stats.SourceFileSize < 570000
assert root_stats.MirrorFiles == 7
assert 700000 < root_stats.MirrorFileSize < 750000
@@ -235,6 +236,6 @@ class inctest2(unittest.TestCase):
assert 3 <= root_stats.ChangedFiles <= 4, root_stats.ChangedFiles
assert 450000 < root_stats.ChangedSourceSize < 470000
assert 400000 < root_stats.ChangedMirrorSize < 420000
- assert 10 < subdir_stats.IncrementFileSize < 30000
+ assert 10 < root_stats.IncrementFileSize < 30000
if __name__ == '__main__': unittest.main()
diff --git a/rdiff-backup/testing/regressiontest.py b/rdiff-backup/testing/regressiontest.py
index 1a486d7..80a60d0 100644
--- a/rdiff-backup/testing/regressiontest.py
+++ b/rdiff-backup/testing/regressiontest.py
@@ -13,7 +13,7 @@ testfiles
Globals.set('change_source_perms', 1)
Globals.counter = 0
-Log.setverbosity(7)
+Log.setverbosity(3)
class Local:
"""This is just a place to put increments relative to the local
diff --git a/rdiff-backup/testing/statisticstest.py b/rdiff-backup/testing/statisticstest.py
index f18832d..ef714f1 100644
--- a/rdiff-backup/testing/statisticstest.py
+++ b/rdiff-backup/testing/statisticstest.py
@@ -8,6 +8,8 @@ class StatsObjTest(unittest.TestCase):
"""Set values of s's statistics"""
s.SourceFiles = 1
s.SourceFileSize = 2
+ s.MirrorFiles = 13
+ s.MirrorFileSize = 14
s.NewFiles = 3
s.NewFileSize = 4
s.DeletedFiles = 5
@@ -15,6 +17,7 @@ class StatsObjTest(unittest.TestCase):
s.ChangedFiles = 7
s.ChangedSourceSize = 8
s.ChangedMirrorSize = 9
+ s.IncrementFiles = 15
s.IncrementFileSize = 10
s.StartTime = 11
s.EndTime = 12
@@ -38,25 +41,51 @@ class StatsObjTest(unittest.TestCase):
self.set_obj(s)
stats_string = s.get_stats_string()
assert stats_string == \
-"""StartTime 11 (Wed Dec 31 16:00:11 1969)
-EndTime 12 (Wed Dec 31 16:00:12 1969)
-ElapsedTime 1 (1 second)
+"""StartTime 11.00 (Wed Dec 31 16:00:11 1969)
+EndTime 12.00 (Wed Dec 31 16:00:12 1969)
+ElapsedTime 1.00 (1 second)
SourceFiles 1
-SourceFileSize 2
+SourceFileSize 2 (2 bytes)
+MirrorFiles 13
+MirrorFileSize 14 (14 bytes)
NewFiles 3
-NewFileSize 4
+NewFileSize 4 (4 bytes)
DeletedFiles 5
-DeletedFileSize 6
+DeletedFileSize 6 (6 bytes)
ChangedFiles 7
-ChangedSourceSize 8
-ChangedMirrorSize 9
-IncrementFileSize 10
+ChangedSourceSize 8 (8 bytes)
+ChangedMirrorSize 9 (9 bytes)
+IncrementFiles 15
+IncrementFileSize 10 (10 bytes)
""", "'%s'" % stats_string
+ def test_line_string(self):
+ """Test conversion to a single line"""
+ s = StatsObj()
+ self.set_obj(s)
+ statline = s.get_stats_line(("sample", "index", "w", "new\nline"))
+ assert statline == "sample/index/w/new\\nline 1 2 13 14 " \
+ "3 4 5 6 7 8 9 15 10", repr(statline)
+
+ statline = s.get_stats_line(())
+ assert statline == ". 1 2 13 14 3 4 5 6 7 8 9 15 10"
+
+ def test_byte_summary(self):
+ """Test conversion of bytes to strings like 7.23MB"""
+ s = StatsObj()
+ f = s.get_byte_summary_string
+ assert f(1) == "1 byte"
+ assert f(234.34) == "234 bytes"
+ assert f(2048) == "2.00 KB"
+ assert f(3502243) == "3.34 MB"
+ assert f(314992230) == "300 MB"
+ assert f(36874871216) == "34.3 GB", f(36874871216)
+ assert f(3775986812573450) == "3434 TB"
+
def test_init_stats(self):
"""Test setting stat object from string"""
s = StatsObj()
- s.init_stats_from_string("NewFiles 3 hello there")
+ s.set_stats_from_string("NewFiles 3 hello there")
for attr in s.stat_attrs:
if attr == 'NewFiles': assert s.get_stat(attr) == 3
else: assert s.get_stat(attr) is None, (attr, s.__dict__[attr])
@@ -66,7 +95,7 @@ IncrementFileSize 10
assert not s1.stats_equal(s)
s2 = StatsObj()
- s2.init_stats_from_string(s1.get_stats_string())
+ s2.set_stats_from_string(s1.get_stats_string())
assert s1.stats_equal(s2)
def test_write_rp(self):
diff --git a/rdiff-backup/testing/timetest.py b/rdiff-backup/testing/timetest.py
index 7d8fd3a..d37862e 100644
--- a/rdiff-backup/testing/timetest.py
+++ b/rdiff-backup/testing/timetest.py
@@ -84,6 +84,7 @@ class TimeTest(unittest.TestCase):
assert Time.inttopretty(0) == "0 seconds"
assert Time.inttopretty(353) == "5 minutes 53 seconds"
assert Time.inttopretty(3661) == "1 hour 1 minute 1 second"
+ assert Time.inttopretty(353.234234) == "5 minutes 53.23 seconds"
def testGenericString(self):
"""Test genstrtotime, conversion of arbitrary string to time"""