mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-12 04:18:28 +00:00
(some) fixes for smoke_magicfolder
This commit is contained in:
@ -39,9 +39,14 @@ import subprocess
|
|||||||
from os.path import join, abspath, curdir, exists
|
from os.path import join, abspath, curdir, exists
|
||||||
from os import mkdir, listdir, unlink
|
from os import mkdir, listdir, unlink
|
||||||
|
|
||||||
|
is_windows = (sys.platform == 'win32')
|
||||||
|
|
||||||
tahoe_base = abspath(curdir)
|
tahoe_base = abspath(curdir)
|
||||||
data_base = join(tahoe_base, 'smoke_magicfolder')
|
data_base = join(tahoe_base, 'smoke_magicfolder')
|
||||||
tahoe_bin = join(tahoe_base, 'bin', 'tahoe')
|
if is_windows:
|
||||||
|
tahoe_bin = join(tahoe_base, 'venv', 'Scripts', 'tahoe.exe')
|
||||||
|
else:
|
||||||
|
tahoe_bin = join(tahoe_base, 'bin', 'tahoe')
|
||||||
python = sys.executable
|
python = sys.executable
|
||||||
|
|
||||||
if not exists(data_base):
|
if not exists(data_base):
|
||||||
@ -57,7 +62,7 @@ if 'kill' in sys.argv:
|
|||||||
print("killing", d)
|
print("killing", d)
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'stop', join(data_base, d),
|
tahoe_bin, 'stop', join(data_base, d),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@ -65,7 +70,7 @@ if 'kill' in sys.argv:
|
|||||||
if not exists(join(data_base, 'introducer')):
|
if not exists(join(data_base, 'introducer')):
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'create-introducer', join(data_base, 'introducer'),
|
tahoe_bin, 'create-introducer', join(data_base, 'introducer'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
with open(join(data_base, 'introducer', 'tahoe.cfg'), 'w') as f:
|
with open(join(data_base, 'introducer', 'tahoe.cfg'), 'w') as f:
|
||||||
@ -75,11 +80,19 @@ nickname = introducer0
|
|||||||
web.port = 4560
|
web.port = 4560
|
||||||
''')
|
''')
|
||||||
|
|
||||||
subprocess.check_call(
|
if not is_windows:
|
||||||
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'start', join(data_base, 'introducer'),
|
tahoe_bin, 'start', join(data_base, 'introducer'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
intro = subprocess.Popen(
|
||||||
|
[
|
||||||
|
tahoe_bin, 'start', join(data_base, 'introducer'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
furl_fname = join(data_base, 'introducer', 'private', 'introducer.furl')
|
furl_fname = join(data_base, 'introducer', 'private', 'introducer.furl')
|
||||||
while not exists(furl_fname):
|
while not exists(furl_fname):
|
||||||
@ -87,12 +100,13 @@ while not exists(furl_fname):
|
|||||||
furl = open(furl_fname, 'r').read()
|
furl = open(furl_fname, 'r').read()
|
||||||
print("FURL", furl)
|
print("FURL", furl)
|
||||||
|
|
||||||
|
nodes = []
|
||||||
for x in range(5):
|
for x in range(5):
|
||||||
data_dir = join(data_base, 'node%d' % x)
|
data_dir = join(data_base, 'node%d' % x)
|
||||||
if not exists(data_dir):
|
if not exists(data_dir):
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'create-node',
|
tahoe_bin, 'create-node',
|
||||||
'--nickname', 'node%d' % (x,),
|
'--nickname', 'node%d' % (x,),
|
||||||
'--introducer', furl,
|
'--introducer', furl,
|
||||||
data_dir,
|
data_dir,
|
||||||
@ -113,29 +127,38 @@ shares.needed = 2
|
|||||||
shares.happy = 3
|
shares.happy = 3
|
||||||
shares.total = 4
|
shares.total = 4
|
||||||
''' % {'node_id':x, 'furl':furl, 'tub_port':(9900 + x)})
|
''' % {'node_id':x, 'furl':furl, 'tub_port':(9900 + x)})
|
||||||
|
if not is_windows:
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'start', data_dir,
|
tahoe_bin, 'start', data_dir,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
node = subprocess.Popen(
|
||||||
|
[
|
||||||
|
tahoe_bin, 'start', data_dir,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
nodes.append(node)
|
||||||
|
|
||||||
|
|
||||||
# alice and bob clients
|
# alice and bob clients
|
||||||
do_invites = False
|
do_invites = False
|
||||||
node_id = 0
|
node_id = 0
|
||||||
|
clients = []
|
||||||
for name in ['alice', 'bob']:
|
for name in ['alice', 'bob']:
|
||||||
data_dir = join(data_base, name)
|
data_dir = join(data_base, name)
|
||||||
magic_dir = join(data_base, '%s-magic' % (name,))
|
magic_dir = join(data_base, '%s-magic' % (name,))
|
||||||
try:
|
try:
|
||||||
mkdir(magic_dir)
|
mkdir(magic_dir)
|
||||||
except OSError:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
if not exists(data_dir):
|
if not exists(data_dir):
|
||||||
do_invites = True
|
do_invites = True
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'create-node',
|
tahoe_bin, 'create-node',
|
||||||
'--no-storage',
|
'--no-storage',
|
||||||
'--nickname', name,
|
'--nickname', name,
|
||||||
'--introducer', furl,
|
'--introducer', furl,
|
||||||
@ -156,30 +179,41 @@ shares.needed = 2
|
|||||||
shares.happy = 3
|
shares.happy = 3
|
||||||
shares.total = 4
|
shares.total = 4
|
||||||
''' % {'name':name, 'node_id':node_id, 'furl':furl})
|
''' % {'name':name, 'node_id':node_id, 'furl':furl})
|
||||||
|
if not is_windows:
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'start', data_dir,
|
tahoe_bin, 'start', data_dir,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
time.sleep(5)
|
||||||
|
x = subprocess.Popen(
|
||||||
|
[
|
||||||
|
tahoe_bin, 'start', data_dir,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
clients.append(x)
|
||||||
node_id += 1
|
node_id += 1
|
||||||
|
|
||||||
# okay, now we have alice + bob (alice, bob)
|
# okay, now we have alice + bob (alice, bob)
|
||||||
# now we have alice create a magic-folder, and invite bob to it
|
# now we have alice create a magic-folder, and invite bob to it
|
||||||
|
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
if do_invites:
|
if do_invites:
|
||||||
data_dir = join(data_base, 'alice')
|
data_dir = join(data_base, 'alice')
|
||||||
# alice creates her folder, invites bob
|
# alice creates her folder, invites bob
|
||||||
print("Alice creates a magic-folder")
|
print("Alice creates a magic-folder")
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'magic-folder', 'create', '--basedir', data_dir, 'magik:', 'alice',
|
tahoe_bin, 'magic-folder', 'create', '--basedir', data_dir, 'magik:', 'alice',
|
||||||
join(data_base, 'alice-magic'),
|
join(data_base, 'alice-magic'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
print("Alice invites Bob")
|
print("Alice invites Bob")
|
||||||
invite = subprocess.check_output(
|
invite = subprocess.check_output(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'magic-folder', 'invite', '--basedir', data_dir, 'magik:', 'bob',
|
tahoe_bin, 'magic-folder', 'invite', '--basedir', data_dir, 'magik:', 'bob',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
print(" invite:", invite)
|
print(" invite:", invite)
|
||||||
@ -189,23 +223,40 @@ if do_invites:
|
|||||||
data_dir = join(data_base, 'bob')
|
data_dir = join(data_base, 'bob')
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'magic-folder', 'join', '--basedir', data_dir, invite,
|
tahoe_bin, 'magic-folder', 'join', '--basedir', data_dir, invite,
|
||||||
join(data_base, 'bob-magic'),
|
join(data_base, 'bob-magic'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
print("Bob has joined.")
|
print("Bob has joined.")
|
||||||
|
|
||||||
print("Restarting alice + bob clients")
|
print("Restarting alice + bob clients")
|
||||||
|
if not is_windows:
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'restart', '--basedir', join(data_base, 'alice'),
|
tahoe_bin, 'restart', '--basedir', join(data_base, 'alice'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'restart', '--basedir', join(data_base, 'bob'),
|
tahoe_bin, 'restart', '--basedir', join(data_base, 'bob'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
for x in clients:
|
||||||
|
x.terminate()
|
||||||
|
clients = []
|
||||||
|
a = subprocess.Popen(
|
||||||
|
[
|
||||||
|
tahoe_bin, 'start', '--basedir', join(data_base, 'alice'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
b = subprocess.Popen(
|
||||||
|
[
|
||||||
|
tahoe_bin, 'start', '--basedir', join(data_base, 'bob'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
clients.append(a)
|
||||||
|
clients.append(b)
|
||||||
|
|
||||||
if True:
|
if True:
|
||||||
for name in ['alice', 'bob']:
|
for name in ['alice', 'bob']:
|
||||||
@ -367,7 +418,7 @@ if True:
|
|||||||
data_dir = join(data_base, 'bob')
|
data_dir = join(data_base, 'bob')
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[
|
[
|
||||||
python, tahoe_bin, 'magic-folder', 'leave', '--basedir', data_dir,
|
tahoe_bin, 'magic-folder', 'leave', '--basedir', data_dir,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user