]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
WIP fixups for smoketest for deletes
authormeejah <meejah@meejah.ca>
Tue, 20 Oct 2015 18:40:55 +0000 (12:40 -0600)
committermeejah <meejah@meejah.ca>
Mon, 26 Oct 2015 14:07:23 +0000 (08:07 -0600)
src/allmydata/test/check_magicfolder_smoke.py

index 909639660292f6586270e3573d498250d1f62ebe..52933bf9c82a78befc023c5540c5cee847f35a15 100644 (file)
@@ -211,8 +211,8 @@ if True:
 # give storage nodes a chance to connect properly? I'm not entirely
 # sure what's up here, but I get "UnrecoverableFileError" on the
 # first_file upload from Alice "very often" otherwise
-print("waiting a second")
-time.sleep(1)
+print("waiting 3 seconds")
+time.sleep(3)
 
 if True:
     # alice writes a file; bob should get it
@@ -248,12 +248,11 @@ if True:
                 print("  file contents still mismatched")
         time.sleep(1)
 
-# deletes do not yet work
-if False:
-    # bob deletes alice's "first_file"; alice should also delete it
+if True:
+    # alice deletes 'first_file'
     alice_foo = join(data_base, 'alice-magic', 'first_file')
     bob_foo = join(data_base, 'bob-magic', 'first_file')
-    unlink(bob_foo)
+    unlink(alice_foo)
 
     print("Waiting for '%s' to disappear" % (bob_foo,))
     while True:
@@ -262,31 +261,21 @@ if False:
             break
         time.sleep(1)
 
-if True:
-    # re-write 'second_file'
-    alice_foo = join(data_base, 'alice-magic', 'second_file')
-    bob_foo = join(data_base, 'bob-magic', 'second_file')
-    gold_content = "line one\nsecond line\n"
-
-    with open(bob_foo, 'w') as f:
-        f.write(gold_content)
-
-    print("Waiting for:", alice_foo)
+    # XXX this doesn't work; shouldn't a .tmp file appear on bob's side?
+    bob_tmp = bob_foo + '.tmp'
+    print("Waiting for '%s' to appear" % (bob_tmp,))
     while True:
-        if exists(alice_foo):
-            print("  found", alice_foo)
-            with open(alice_foo, 'r') as f:
-                content = f.read()
-                if content == gold_content:
-                    break
-                print("  file contents still mismatched:\n")
+        if exists(bob_tmp):
+            print("  appeared", bob_tmp)
+            break
         time.sleep(1)
 
 if True:
-    # restore 'first_file' but with different contents
-    alice_foo = join(data_base, 'alice-magic', 'first_file')
-    bob_foo = join(data_base, 'bob-magic', 'first_file')
-    gold_content = "see it again for the first time\n"
+    # bob writes new content to 'second_file'; alice should get it
+    # get it.
+    alice_foo = join(data_base, 'alice-magic', 'second_file')
+    bob_foo = join(data_base, 'bob-magic', 'second_file')
+    gold_content = "line one\nsecond line\n"
 
     with open(bob_foo, 'w') as f:
         f.write(gold_content)
@@ -300,10 +289,9 @@ if True:
                 if content == gold_content:
                     break
                 print("  file contents still mismatched:\n")
+                print(content)
         time.sleep(1)
 
-
-
 if True:
     # bob creates a sub-directory and adds a file to it
     alice_dir = join(data_base, 'alice-magic', 'subdir')
@@ -339,6 +327,37 @@ if True:
             break
         time.sleep(0.1)
 
+# XXX restore the file not working (but, unit-tests work; what's wrong with them?)
+# NOTE: only not-works if it's alice restoring the file!
+if True:
+    # restore 'first_file' but with different contents
+    print("re-writing 'first_file'")
+    assert not exists(join(data_base, 'bob-magic', 'first_file'))
+    assert not exists(join(data_base, 'alice-magic', 'first_file'))
+    alice_foo = join(data_base, 'alice-magic', 'first_file')
+    bob_foo = join(data_base, 'bob-magic', 'first_file')
+    if True:
+        # if we don't swap around, it works fine
+        alice_foo, bob_foo = bob_foo, alice_foo
+    gold_content = "see it again for the first time\n"
+
+    with open(bob_foo, 'w') as f:
+        f.write(gold_content)
+
+    print("Waiting for:", alice_foo)
+    while True:
+        if exists(alice_foo):
+            print("  found", alice_foo)
+            with open(alice_foo, 'r') as f:
+                content = f.read()
+                if content == gold_content:
+                    break
+                print("  file contents still mismatched: %d bytes:\n" % (len(content),))
+                print(content)
+        else:
+            print("   {} not there yet".format(alice_foo))
+        time.sleep(1)
+
 # XXX test .backup (delete a file)
 
 # port david's clock.advance stuff