def t22(HOME): pretty = '%s t22' % __file__ print(pretty) ave.config.create_default(HOME.path) path = os.path.join(HOME.path, '.ave', 'config', 'broker.json') with open(path, 'w') as f: json.dump({'logging': False}, f) sock, port = find_free_port() b = Broker(socket=sock, authkeys={'admin': 'key'}, home=HOME.path) b.start() r = RemoteBroker(('', port), home=HOME.path) try: r.stop() print('FAIL %s: stop() did not fail' % pretty) b.join() return False except Exception, e: if 'not authorized to make this call' not in str(e): print('FAIL %s: wrong error message: %s' % (pretty, str(e))) b.terminate() b.join() return False
def t1(factory): pretty = '%s t1' % __file__ print(pretty) sock, port = find_free_port() sock.shutdown(socket.SHUT_RDWR) sock.close() for i in range(10): try: broker = Broker(('',port), home=factory.HOME.path) broker.start() remote = RemoteBroker(('',port), 5, 'admin_key', factory.HOME.path) remote.stop(__async__=True) broker.join() except Exception, e: print('FAIL %s: stopping broker %d failed: %s' % (pretty,i,str(e))) return False
def t23(HOME): pretty = '%s t23' % __file__ print(pretty) ave.config.create_default(HOME.path) path = os.path.join(HOME.path, '.ave', 'config', 'broker.json') with open(path, 'w') as f: json.dump({'logging': False}, f) sock, port = find_free_port() b = Broker(socket=sock, authkeys={'admin': 'key'}, home=HOME.path) b.start() r = RemoteBroker(('', port), authkey='key', home=HOME.path) try: r.stop() except ConnectionClosed: pass # good except Exception, e: print('FAIL %s: admin authkey not accepted: %s' % (pretty, str(e))) b.terminate() b.join() return False