def magic_folder(reactor, alice_invite, alice, bob, temp_dir, request): print("pairing magic-folder") bob_dir = join(temp_dir, 'bob') proto = _CollectOutputProtocol() _tahoe_runner_optional_coverage(proto, reactor, request, [ 'magic-folder', 'join', '--poll-interval', '1', '--basedir', bob_dir, alice_invite, join(temp_dir, 'magic-bob'), ]) pytest_twisted.blockon(proto.done) # before magic-folder works, we have to stop and restart (this is # crappy for the tests -- can we fix it in magic-folder?) try: print("Sending TERM to Bob") bob.transport.signalProcess('TERM') pytest_twisted.blockon(bob.transport.exited) except ProcessExitedAlready: pass magic_text = 'Completed initial Magic Folder scan successfully' pytest_twisted.blockon(_run_node(reactor, bob_dir, request, magic_text)) await_client_ready(bob) return (join(temp_dir, 'magic-alice'), join(temp_dir, 'magic-bob'))
def tor_introducer(reactor, temp_dir, flog_gatherer, request): config = ''' [node] nickname = introducer_tor web.port = 4561 log_gatherer.furl = {log_furl} '''.format(log_furl=flog_gatherer) intro_dir = join(temp_dir, 'introducer_tor') print("making introducer", intro_dir) if not exists(intro_dir): mkdir(intro_dir) done_proto = _ProcessExitedProtocol() _tahoe_runner_optional_coverage( done_proto, reactor, request, ( 'create-introducer', '--tor-control-port', 'tcp:localhost:8010', '--listen=tor', intro_dir, ), ) pytest_twisted.blockon(done_proto.done) # over-write the config file with our stuff with open(join(intro_dir, 'tahoe.cfg'), 'w') as f: f.write(config) # on windows, "tahoe start" means: run forever in the foreground, # but on linux it means daemonize. "tahoe run" is consistent # between platforms. protocol = _MagicTextProtocol('introducer running') transport = _tahoe_runner_optional_coverage( protocol, reactor, request, ( 'run', intro_dir, ), ) def cleanup(): try: transport.signalProcess('TERM') pytest_twisted.blockon(protocol.exited) except ProcessExitedAlready: pass request.addfinalizer(cleanup) pytest_twisted.blockon(protocol.magic_seen) return transport
def alice_invite(reactor, alice, temp_dir, request): node_dir = join(temp_dir, 'alice') with start_action(action_type=u"integration:alice:magic_folder:create"): # FIXME XXX by the time we see "client running" in the logs, the # storage servers aren't "really" ready to roll yet (uploads fairly # consistently fail if we don't hack in this pause...) proto = _CollectOutputProtocol() _tahoe_runner_optional_coverage(proto, reactor, request, [ 'magic-folder', 'create', '--poll-interval', '2', '--basedir', node_dir, 'magik:', 'alice', join(temp_dir, 'magic-alice'), ]) pytest_twisted.blockon(proto.done) with start_action( action_type=u"integration:alice:magic_folder:invite") as a: proto = _CollectOutputProtocol() _tahoe_runner_optional_coverage(proto, reactor, request, [ 'magic-folder', 'invite', '--basedir', node_dir, 'magik:', 'bob', ]) pytest_twisted.blockon(proto.done) invite = proto.output.getvalue() a.add_success_fields(invite=invite) with start_action(action_type=u"integration:alice:magic_folder:restart"): # before magic-folder works, we have to stop and restart (this is # crappy for the tests -- can we fix it in magic-folder?) try: alice.transport.signalProcess('TERM') pytest_twisted.blockon(alice.transport.exited) except ProcessExitedAlready: pass with start_action( action_type=u"integration:alice:magic_folder:magic-text"): magic_text = 'Completed initial Magic Folder scan successfully' pytest_twisted.blockon( _run_node(reactor, node_dir, request, magic_text)) await_client_ready(alice) return invite
def introducer(reactor, temp_dir, flog_gatherer, request): config = ''' [node] nickname = introducer0 web.port = 4560 log_gatherer.furl = {log_furl} '''.format(log_furl=flog_gatherer) intro_dir = join(temp_dir, 'introducer') print("making introducer", intro_dir) if not exists(intro_dir): mkdir(intro_dir) done_proto = _ProcessExitedProtocol() _tahoe_runner_optional_coverage( done_proto, reactor, request, ( 'create-introducer', '--listen=tcp', '--hostname=localhost', intro_dir, ), ) pytest_twisted.blockon(done_proto.done) # over-write the config file with our stuff with open(join(intro_dir, 'tahoe.cfg'), 'w') as f: f.write(config) # on windows, "tahoe start" means: run forever in the foreground, # but on linux it means daemonize. "tahoe run" is consistent # between platforms. protocol = _MagicTextProtocol('introducer running') transport = _tahoe_runner_optional_coverage( protocol, reactor, request, ( 'run', intro_dir, ), ) request.addfinalizer( partial(_cleanup_tahoe_process, transport, protocol.exited)) pytest_twisted.blockon(protocol.magic_seen) return TahoeProcess(transport, intro_dir)