]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/test/check_magicfolder_smoke.py
add Bob leaving to smoke-tests
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / test / check_magicfolder_smoke.py
index 52933bf9c82a78befc023c5540c5cee847f35a15..05a4dd55e93703a25a39c4d802653c9c9407fe70 100644 (file)
@@ -42,13 +42,14 @@ from os import mkdir, listdir, unlink
 tahoe_base = abspath(curdir)
 data_base = join(tahoe_base, 'smoke_magicfolder')
 tahoe_bin = join(tahoe_base, 'bin', 'tahoe')
+python = sys.executable
 
 if not exists(data_base):
     print("Creating", data_base)
     mkdir(data_base)
 
 if not exists(tahoe_bin):
-    raise RuntimeError("Can't find 'tahoe' binary at '{}'".format(tahoe_bin))
+    raise RuntimeError("Can't find 'tahoe' binary at %r" % (tahoe_bin,))
 
 if 'kill' in sys.argv:
     print("Killing the grid")
@@ -56,7 +57,7 @@ if 'kill' in sys.argv:
         print("killing", d)
         subprocess.call(
             [
-                tahoe_bin, 'stop', join(data_base, d),
+                python, tahoe_bin, 'stop', join(data_base, d),
             ]
         )
     sys.exit(0)
@@ -64,7 +65,7 @@ if 'kill' in sys.argv:
 if not exists(join(data_base, 'introducer')):
     subprocess.check_call(
         [
-            tahoe_bin, 'create-introducer', join(data_base, 'introducer'),
+            python, tahoe_bin, 'create-introducer', join(data_base, 'introducer'),
         ]
     )
 with open(join(data_base, 'introducer', 'tahoe.cfg'), 'w') as f:
@@ -76,7 +77,7 @@ web.port = 4560
 
 subprocess.check_call(
     [
-        tahoe_bin, 'start', join(data_base, 'introducer'),
+        python, tahoe_bin, 'start', join(data_base, 'introducer'),
     ]
 )
 
@@ -91,8 +92,8 @@ for x in range(5):
     if not exists(data_dir):
         subprocess.check_call(
             [
-                tahoe_bin, 'create-node',
-                '--nickname', 'node{}'.format(x),
+                python, tahoe_bin, 'create-node',
+                '--nickname', 'node%d' % (x,),
                 '--introducer', furl,
                 data_dir,
             ]
@@ -100,21 +101,21 @@ for x in range(5):
         with open(join(data_dir, 'tahoe.cfg'), 'w') as f:
             f.write('''
 [node]
-nickname = node{node_id}
+nickname = node%(node_id)s
 web.port =
 web.static = public_html
-tub.location = localhost:{tub_port}
+tub.location = localhost:%(tub_port)d
 
 [client]
 # Which services should this client connect to?
-introducer.furl = {furl}
+introducer.furl = %(furl)s
 shares.needed = 2
 shares.happy = 3
 shares.total = 4
-'''.format(node_id=x, furl=furl, tub_port=(9900 + x)))
+''' % {'node_id':x, 'furl':furl, 'tub_port':(9900 + x)})
     subprocess.check_call(
         [
-            tahoe_bin, 'start', data_dir,
+            python, tahoe_bin, 'start', data_dir,
         ]
     )
 
@@ -125,13 +126,13 @@ do_invites = False
 node_id = 0
 for name in ['alice', 'bob']:
     data_dir = join(data_base, name)
-    magic_dir = join(data_base, '{}-magic'.format(name))
+    magic_dir = join(data_base, '%s-magic' % (name,))
     mkdir(magic_dir)
     if not exists(data_dir):
         do_invites = True
         subprocess.check_call(
             [
-                tahoe_bin, 'create-node',
+                python, tahoe_bin, 'create-node',
                 '--no-storage',
                 '--nickname', name,
                 '--introducer', furl,
@@ -141,20 +142,20 @@ for name in ['alice', 'bob']:
         with open(join(data_dir, 'tahoe.cfg'), 'w') as f:
             f.write('''
 [node]
-nickname = {name}
-web.port = tcp:998{node_id}:interface=localhost
+nickname = %(name)s
+web.port = tcp:998%(node_id)d:interface=localhost
 web.static = public_html
 
 [client]
 # Which services should this client connect to?
-introducer.furl = {furl}
+introducer.furl = %(furl)s
 shares.needed = 2
 shares.happy = 3
 shares.total = 4
-'''.format(name=name, node_id=node_id, furl=furl, magic_dir=magic_dir))
+''' % {'name':name, 'node_id':node_id, 'furl':furl})
     subprocess.check_call(
         [
-            tahoe_bin, 'start', data_dir,
+            python, tahoe_bin, 'start', data_dir,
         ]
     )
     node_id += 1
@@ -168,14 +169,14 @@ if do_invites:
     print("Alice creates a magic-folder")
     subprocess.check_call(
         [
-            tahoe_bin, 'magic-folder', 'create', '--basedir', data_dir, 'magik:', 'alice',
+            python, tahoe_bin, 'magic-folder', 'create', '--basedir', data_dir, 'magik:', 'alice',
             join(data_base, 'alice-magic'),
         ]
     )
     print("Alice invites Bob")
     invite = subprocess.check_output(
         [
-            tahoe_bin, 'magic-folder', 'invite', '--basedir', data_dir, 'magik:', 'bob',
+            python, tahoe_bin, 'magic-folder', 'invite', '--basedir', data_dir, 'magik:', 'bob',
         ]
     )
     print("  invite:", invite)
@@ -185,7 +186,7 @@ if do_invites:
     data_dir = join(data_base, 'bob')
     subprocess.check_call(
         [
-            tahoe_bin, 'magic-folder', 'join', '--basedir', data_dir, invite,
+            python, tahoe_bin, 'magic-folder', 'join', '--basedir', data_dir, invite,
             join(data_base, 'bob-magic'),
         ]
     )
@@ -194,19 +195,19 @@ if do_invites:
     print("Restarting alice + bob clients")
     subprocess.check_call(
         [
-            tahoe_bin, 'restart', '--basedir', join(data_base, 'alice'),
+            python, tahoe_bin, 'restart', '--basedir', join(data_base, 'alice'),
         ]
     )
     subprocess.check_call(
         [
-            tahoe_bin, 'restart', '--basedir', join(data_base, 'bob'),
+            python, tahoe_bin, 'restart', '--basedir', join(data_base, 'bob'),
         ]
     )
 
 if True:
     for name in ['alice', 'bob']:
         with open(join(data_base, name, 'private', 'magic_folder_dircap'), 'r') as f:
-            print("dircap {}: {}".format(name, f.read().strip()))
+            print("dircap %s: %s" % (name, f.read().strip()))
 
 # give storage nodes a chance to connect properly? I'm not entirely
 # sure what's up here, but I get "UnrecoverableFileError" on the
@@ -261,8 +262,7 @@ if True:
             break
         time.sleep(1)
 
-    # XXX this doesn't work; shouldn't a .tmp file appear on bob's side?
-    bob_tmp = bob_foo + '.tmp'
+    bob_tmp = bob_foo + '.backup'
     print("Waiting for '%s' to appear" % (bob_tmp,))
     while True:
         if exists(bob_tmp):
@@ -355,9 +355,20 @@ if True:
                 print("  file contents still mismatched: %d bytes:\n" % (len(content),))
                 print(content)
         else:
-            print("   {} not there yet".format(alice_foo))
+            print("   %r not there yet" % (alice_foo,))
         time.sleep(1)
 
+if True:
+    # bob leaves
+    print 'bob leaves'
+    data_dir = join(data_base, 'bob')
+    subprocess.check_call(
+        [
+            python, tahoe_bin, 'magic-folder', 'leave', '--basedir', data_dir,
+        ]
+    )
+
+
 # XXX test .backup (delete a file)
 
 # port david's clock.advance stuff