chiark / gitweb /
check server runs after upgrade
authorRichard Kettlewell <rjk@greenend.org.uk>
Wed, 21 Nov 2007 19:20:15 +0000 (19:20 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Wed, 21 Nov 2007 19:20:15 +0000 (19:20 +0000)
tests/dbversion.py
tests/dtest.py
tests/files.py

index 945d7ad..37e3b46 100755 (executable)
@@ -31,6 +31,7 @@ def test():
     time.sleep(2)
     dtest.stop_daemon()
     # Revert to default configuration
+    print "Checking daemon won't start with an old database"
     dtest.copyfile(configsave, config)
     dtest.start_daemon()
     time.sleep(2)
@@ -55,6 +56,10 @@ def test():
     if rc != 0:
         print "disorder-dbupgrade: FAILED: exit code %s" % rc
         sys.exit(1)
+    print "Testing daemon after upgrade..."
+    dtest.start_daemon()
+    time.sleep(2)
+    assert dtest.check_files() == 0
 
 if __name__ == '__main__':
     dtest.run()
index 26fca75..00c5ead 100644 (file)
@@ -253,6 +253,33 @@ Recursively delete directory D"""
         else:
             os.remove(d)
 
+def check_files():
+    c = disorder.client()
+    failures = 0
+    for d in dirs_by_dir:
+        xdirs = dirs_by_dir[d]
+        dirs = c.directories(d)
+        xdirs.sort()
+        dirs.sort()
+        if dirs != xdirs:
+            print
+            print "directory: %s" % d
+            print "expected:  %s" % xdirs
+            print "got:       %s" % dirs
+            failures += 1
+    for d in files_by_dir:
+        xfiles = files_by_dir[d]
+        files = c.files(d)
+        xfiles.sort()
+        files.sort()
+        if files != xfiles:
+            print
+            print "directory: %s" % d
+            print "expected:  %s" % xfiles
+            print "got:       %s" % files
+            failures += 1
+    return failures
+
 # -----------------------------------------------------------------------------
 # Common setup
 
index 89375a6..24d4ea4 100755 (executable)
@@ -23,34 +23,8 @@ import dtest,time,disorder,sys
 def test():
     """Check that the file listing comes out right"""
     dtest.start_daemon()
-    time.sleep(5)                       # give rescan a chance
-    c = disorder.client()
-    failures = 0
-    for d in dtest.dirs_by_dir:
-        xdirs = dtest.dirs_by_dir[d]
-        dirs = c.directories(d)
-        xdirs.sort()
-        dirs.sort()
-        if dirs != xdirs:
-            print
-            print "directory: %s" % d
-            print "expected:  %s" % xdirs
-            print "got:       %s" % dirs
-            failures += 1
-    for d in dtest.files_by_dir:
-        xfiles = dtest.files_by_dir[d]
-        files = c.files(d)
-        xfiles.sort()
-        files.sort()
-        if files != xfiles:
-            print
-            print "directory: %s" % d
-            print "expected:  %s" % xfiles
-            print "got:       %s" % files
-            failures += 1
-    if failures:
-        print
-        sys.exit(1)
+    time.sleep(2)                       # give rescan a chance
+    assert dtest.check_files() == 0
 
 if __name__ == '__main__':
     dtest.run()