def t5(factory): pretty = '%s t5' % __file__ print(pretty) handover = factory.make_master('master') avail_1 = handover.list_available() # make some allocations c1 = RemoteBroker(handover.address, home=factory.HOME.path) h1, w1 = c1.get_resources({'type': 'handset'}, {'type': 'workspace'}) avail_2 = handover.list_available() c2 = RemoteBroker(handover.address, home=factory.HOME.path) h2, r2 = c2.get_resources({'type': 'handset'}, {'type': 'relay'}) avail_3 = handover.list_available() adoption, config, fdtx_path = handover.begin_handover() session = RemoteSession(h2.address, h2.authkey) try: session.crash() # kill the second session during the handover except ConnectionClosed: pass takeover = factory.make_takeover('master', adoption, config, fdtx_path) handover.end_handover(1) result = takeover.list_available() if len(result) != len(avail_2): print('FAIL %s: wrong avail: %s != %s' % (pretty, result, avail_2)) return False return True
def t3(HOME, master, forwarder): pretty = '%s t3' % __file__ print(pretty) # get local and remote resources h1 = forwarder.get_resources({'type': 'handset', 'pretty': 'mary'}) h2 = forwarder.get_resources({'type': 'handset', 'pretty': 'mary'}) # crash the remote session r2 = RemoteSession(h2.address, h2.authkey, timeout=h2.timeout) try: r2.crash() except ConnectionClosed: pass # good except Exception, e: print('FAIL %s: unexpected exception: %s' % (pretty, str(e))) return False
def t7(HOME, master, forwarder_a, forwarder_b): pretty = '%s t7' % __file__ print(pretty) # get local and remote resources h1 = forwarder_b.get_resources({'type': 'handset', 'pretty': 'jane'}) h2 = forwarder_b.get_resources({'type': 'handset', 'pretty': 'jane'}) h3 = forwarder_b.get_resources({'type': 'handset', 'pretty': 'jane'}) # crash the last session in the chain r3 = RemoteSession(h3.address, h3.authkey, timeout=h3.timeout) try: r3.crash() except ConnectionClosed: pass # good except Exception, e: print('FAIL %s: unexpected exception: %s' % (pretty, str(e))) return False
def t13(factory): pretty = '%s t13' % __file__ print(pretty) handover = factory.make_master('master') # make some sessions c1 = RemoteBroker(handover.address, home=factory.HOME.path) h1, w1 = c1.get_resources({'type': 'handset'}, {'type': 'workspace'}) avail_2 = handover.list_available() c2 = RemoteBroker(handover.address, home=factory.HOME.path) h2, r2 = c2.get_resources({'type': 'handset'}, {'type': 'relay'}) avail_3 = handover.list_available() adoption, config, fdtx_path = handover.begin_handover() takeover = factory.make_takeover('master', adoption, config, fdtx_path) handover.end_handover(1) # crash the sessions session = RemoteSession(h1.address, h1.authkey) try: session.crash() except ConnectionClosed: pass session = RemoteSession(h2.address, h2.authkey) try: session.crash() except ConnectionClosed: pass for i in range(10): # wait until only one session remains, then close it authkeys = handover.get_session_authkeys() if len(authkeys) == 1: break time.sleep(0.3) # check that the handover sends its exit message when the last session is # closed try: handover.close_session(authkeys[0]) except Exit, e: if str(e) != 'broker restarted. please reconnect': print('FAIL %s: wrong exit message: %s' % (pretty, str(e))) return False