def test_fle(): now = time.time() init = Initial(timestamp=now, src="10.0.0.1:32000", dst="10.0.0.2:3888", server_id=1, election_addr="10.0.0.1:3888") notif = Notification(timestamp=now, src="10.0.0.1:32000", dst="10.0.0.2:3888", state=PeerState.LOOKING, leader=4, zxid=0x100, peer_epoch=0x1, election_epoch=0x1, version=2, config="config") output = StringIO() printer = Printer(colors=False, output=output) printer.add(init) printer.add(notif) # wait for the messages to be consumed while not printer.empty: time.sleep(0.0001) # stop it printer.stop() while not printer.stopped: time.sleep(0.0001) assert str(init) in output.getvalue() assert str(notif) in output.getvalue()
def test_zab(): now = time.time() request = Request( timestamp=now, src="10.0.0.3:2889", dst="10.0.0.4:58566", ptype=PacketType.REQUEST, zxid=-1, length=100, session_id=0xdeadbeef, cxid=90000, req_type=OpCodes.CREATE, ) proposal = Proposal( timestamp=now, src="10.0.0.3:2889", dst="10.0.0.4:58566", ptype=PacketType.PROPOSAL, zxid=0x100, length=100, session_id=0xdeadbeef, cxid=90000, txn_zxid=0x100, txn_time=now, txn_type=OpCodes.CREATE, ) output = StringIO() printer = Printer(colors=False, output=output) printer.add(request) printer.add(proposal) # consume all messages while not printer.empty: time.sleep(0.0001) # stop it printer.stop() while not printer.stopped: time.sleep(0.0001) assert str(request) in output.getvalue() assert str(proposal) in output.getvalue()
def test_zab(): now = time.time() request = Request( timestamp=now, src="10.0.0.3:2889", dst="10.0.0.4:58566", ptype=PacketType.REQUEST, zxid=-1, length=100, session_id=0xDEADBEEF, cxid=90000, req_type=OpCodes.CREATE, ) proposal = Proposal( timestamp=now, src="10.0.0.3:2889", dst="10.0.0.4:58566", ptype=PacketType.PROPOSAL, zxid=0x100, length=100, session_id=0xDEADBEEF, cxid=90000, txn_zxid=0x100, txn_time=now, txn_type=OpCodes.CREATE, ) output = StringIO() printer = Printer(colors=False, output=output) printer.add(request) printer.add(proposal) # consume all messages while not printer.empty: time.sleep(0.0001) # stop it printer.stop() while not printer.stopped: time.sleep(0.0001) assert str(request) in output.getvalue() assert str(proposal) in output.getvalue()
def test_fle(): now = time.time() init = Initial( timestamp=now, src="10.0.0.1:32000", dst="10.0.0.2:3888", server_id=1, election_addr="10.0.0.1:3888" ) notif = Notification( timestamp=now, src="10.0.0.1:32000", dst="10.0.0.2:3888", state=PeerState.LOOKING, leader=4, zxid=0x100, peer_epoch=0x1, election_epoch=0x1, version=2, config="config" ) output = StringIO() printer = Printer(colors=False, output=output) printer.add(init) printer.add(notif) # wait for the messages to be consumed while not printer.empty: time.sleep(0.0001) # stop it printer.stop() while not printer.stopped: time.sleep(0.0001) assert str(init) in output.getvalue() assert str(notif) in output.getvalue()