Hello community, here is the log from the commit of package python-raet for openSUSE:Factory checked in at 2014-10-23 14:21:02 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-raet (Old) and /work/SRC/openSUSE:Factory/.python-raet.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-raet" Changes: -------- --- /work/SRC/openSUSE:Factory/python-raet/python-raet.changes 2014-10-05 20:32:36.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-raet.new/python-raet.changes 2014-10-23 14:21:22.000000000 +0200 @@ -1,0 +2,11 @@ +Wed Oct 22 20:49:43 UTC 2014 - [email protected] + +- Updated to 0.3.6 + - Made default timeout for Messenger and Messengent transaction to be 0.0, that is, never + - Added timout parameter to RoadStack.transmit() so timeout can be set on a message transaction by transaction basis + - Added timeout to txMsgs deque triple for RoadStack that is, (msg, uid, timeout) + - Fixed bug in RoadKeep.loadRemoteRoleData() + - Added socket error handling for additional failure modes in Stack._handleOneTx for sending + - Fixed Python3 incompatabilities + +------------------------------------------------------------------- @@ -4 +15 @@ -- Major update to 3.2 +- Major update to 0.3.2 Old: ---- raet-0.3.2.tar.gz New: ---- raet-0.3.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-raet.spec ++++++ --- /var/tmp/diff_new_pack.4gwcfD/_old 2014-10-23 14:21:24.000000000 +0200 +++ /var/tmp/diff_new_pack.4gwcfD/_new 2014-10-23 14:21:24.000000000 +0200 @@ -16,7 +16,7 @@ # Name: python-raet -Version: 0.3.2 +Version: 0.3.6 Release: 0 License: Apache-2.0 Summary: Reliable Asynchronous Event Transport protocol ++++++ raet-0.3.2.tar.gz -> raet-0.3.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/PKG-INFO new/raet-0.3.6/PKG-INFO --- old/raet-0.3.2/PKG-INFO 2014-10-02 19:55:04.000000000 +0200 +++ new/raet-0.3.6/PKG-INFO 2014-10-09 20:25:22.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: raet -Version: 0.3.2 +Version: 0.3.6 Summary: Reliable Asynchronous Event Transport protocol Home-page: https://github.com/saltstack/raet Author: Samuel M. Smith diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/__metadata__.py new/raet-0.3.6/raet/__metadata__.py --- old/raet-0.3.2/raet/__metadata__.py 2014-10-02 19:51:05.000000000 +0200 +++ new/raet-0.3.6/raet/__metadata__.py 2014-10-09 20:19:22.000000000 +0200 @@ -2,7 +2,7 @@ Raet package metadata ''' -__version_info__ = (0, 3, 2) +__version_info__ = (0, 3, 6) __version__ = '{0}.{1}.{2}'.format(*__version_info__) __author__ = "Samuel M. Smith" __license__ = "Apache2" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/flo/behaving.py new/raet-0.3.6/raet/flo/behaving.py --- old/raet-0.3.2/raet/flo/behaving.py 2014-09-17 00:37:58.000000000 +0200 +++ new/raet-0.3.6/raet/flo/behaving.py 2014-10-09 19:25:23.000000000 +0200 @@ -471,7 +471,7 @@ stack = self.stack.value if stack and isinstance(stack, RoadStack): deid = self.destination.value - stack.transmit(msg=msg, duid=deid) + stack.transmit(msg=msg, uid=deid) class RaetRoadStackPrinter(deeding.Deed): @@ -643,7 +643,7 @@ stack = self.stack.value if stack and isinstance(stack, LaneStack): name = self.dest.value #destination yard name - stack.transmit(msg=msg, duid=stack.fetchUidByName(name)) + stack.transmit(msg=msg, uid=stack.fetchUidByName(name)) class RaetLaneStackPrinter(deeding.Deed): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/keeping.py new/raet-0.3.6/raet/keeping.py --- old/raet-0.3.2/raet/keeping.py 2014-09-17 00:37:58.000000000 +0200 +++ new/raet-0.3.6/raet/keeping.py 2014-10-06 20:01:16.000000000 +0200 @@ -167,6 +167,19 @@ data[field] = None return data + def scrubData(self, data, defaults): + ''' + Returns scrubbed copy of data that has the same field set as defaults + by either copying values for common fields or + adding fields with defaults + or leaving out extra fields + ''' + scrubbed = odict(defaults) + for key in scrubbed: + if key in data: + scrubbed[key] = data[key] + return scrubbed + def verifyLocalData(self, data, localFields=None): ''' Returns True if the fields in .LocalFields match the fields in data diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/lane/stacking.py new/raet-0.3.6/raet/lane/stacking.py --- old/raet-0.3.2/raet/lane/stacking.py 2014-09-17 00:37:58.000000000 +0200 +++ new/raet-0.3.6/raet/lane/stacking.py 2014-10-09 19:40:19.000000000 +0200 @@ -194,9 +194,9 @@ Take one message from .txMsgs deque and handle it Assumes there is a message on the deque ''' - body, duid = self.txMsgs.popleft() # duple (body dict, destination name) - self.message(body, duid) - console.verbose("{0} sending to {1}\n{2}\n".format(self.name, duid, body)) + body, uid = self.txMsgs.popleft() # duple (body dict, destination name) + self.message(body, uid=uid) + console.verbose("{0} sending to {1}\n{2}\n".format(self.name, uid, body)) def _handleOneTx(self, laters, blocks): ''' @@ -232,23 +232,23 @@ self.incStat("error_transmit_yard") raise - def message(self, body, duid): + def message(self, body, uid=None): ''' Sends message body to yard name and manages paging of long messages ''' - if duid is None: + if uid is None: if not self.remotes: emsg = "No yard to send to\n" console.terse(emsg) self.incStat("invalid_destination") return - duid = self.remotes.values()[0].name - if duid not in self.remotes: - emsg = "Invalid destination yard '{0}'\n".format(duid) + uid = self.remotes.values()[0].name + if uid not in self.remotes: + emsg = "Invalid destination yard '{0}'\n".format(uid) console.terse(emsg) self.incStat("invalid_destination") return - remote = self.remotes[duid] + remote = self.remotes[uid] data = odict(pk=self.Pk, sn=self.local.name, dn=remote.name, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/lane/test/test_stacking.py new/raet-0.3.6/raet/lane/test/test_stacking.py --- old/raet-0.3.2/raet/lane/test/test_stacking.py 2014-09-17 00:37:58.000000000 +0200 +++ new/raet-0.3.6/raet/lane/test/test_stacking.py 2014-10-09 19:43:03.000000000 +0200 @@ -200,9 +200,9 @@ Utility to send messages both ways ''' for msg in mains: - main.transmit(msg, duid=main.fetchUidByName(other.local.name)) + main.transmit(msg, uid=main.fetchUidByName(other.local.name)) for msg in others: - other.transmit(msg, duid=other.fetchUidByName(main.local.name)) + other.transmit(msg, uid=other.fetchUidByName(main.local.name)) self.serviceMainOther(main, other, duration=duration) @@ -682,9 +682,9 @@ self.assertEqual(other.nameRemotes['main'].rsid, 0) for msg in mains: - main.transmit(msg, duid=main.fetchUidByName(other.local.name)) + main.transmit(msg, uid=main.fetchUidByName(other.local.name)) for msg in others: - other.transmit(msg, duid=other.fetchUidByName(main.local.name)) + other.transmit(msg, uid=other.fetchUidByName(main.local.name)) self.assertEqual(len(main.txMsgs), 1) @@ -755,7 +755,7 @@ #send a new message from main and reap stale book from other for msg in mains: - main.transmit(msg, duid=main.fetchUidByName(other.local.name)) + main.transmit(msg, uid=main.fetchUidByName(other.local.name)) self.serviceMainOther(main, other, duration=1.0) @@ -782,9 +782,9 @@ other.rxMsgs.pop() for msg in mains: - main.transmit(msg, duid=main.fetchUidByName(other.local.name)) + main.transmit(msg, uid=main.fetchUidByName(other.local.name)) for msg in others: - other.transmit(msg, duid=other.fetchUidByName(main.local.name)) + other.transmit(msg, uid=other.fetchUidByName(main.local.name)) self.serviceOneAll(main, other) @@ -824,9 +824,9 @@ main.nameRemotes['other'].sid = mainSid other.nameRemotes['main'].sid = otherSid for msg in mains: - main.transmit(msg, duid=main.fetchUidByName(other.local.name)) + main.transmit(msg, uid=main.fetchUidByName(other.local.name)) for msg in others: - other.transmit(msg, duid=other.fetchUidByName(main.local.name)) + other.transmit(msg, uid=other.fetchUidByName(main.local.name)) self.serviceOneAll(main, other) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/lane/yarding.py new/raet-0.3.6/raet/lane/yarding.py --- old/raet-0.3.2/raet/lane/yarding.py 2014-09-17 00:37:59.000000000 +0200 +++ new/raet-0.3.6/raet/lane/yarding.py 2014-10-06 21:41:38.000000000 +0200 @@ -8,6 +8,10 @@ import socket import os import errno +import sys + +if sys.version_info > (3,): + long = int # Import ioflo libs from ioflo.base.odicting import odict @@ -151,7 +155,7 @@ Generates next book id number. ''' self.bid += 1 - if self.bid > 0xffffffffL: + if self.bid > long(0xffffffff): self.bid = 1 # rollover to 1 return self.bid diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/road/estating.py new/raet-0.3.6/raet/road/estating.py --- old/raet-0.3.2/raet/road/estating.py 2014-09-30 22:47:18.000000000 +0200 +++ new/raet-0.3.6/raet/road/estating.py 2014-10-09 19:41:19.000000000 +0200 @@ -8,6 +8,9 @@ import socket import uuid from collections import deque +import sys +if sys.version_info > (3,): + long = int # Import ioflo libs from ioflo.base.odicting import odict @@ -91,7 +94,7 @@ Generates next transaction id number. ''' self.tid += 1 - if self.tid > 0xffffffffL: + if self.tid > long(0xffffffff): self.tid = 1 # rollover to 1 return self.tid @@ -438,7 +441,7 @@ ''' while self.messages: body = self.messages.popleft() - self.stack.message(body=body, uid=self.uid) + self.stack.message(body, uid=self.uid) emsg = ("Stack {0}: Resent saved message with remote {1} at {2}" "\n".format(self.stack.name, index, self.name)) console.concise(emsg) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/road/keeping.py new/raet-0.3.6/raet/road/keeping.py --- old/raet-0.3.2/raet/road/keeping.py 2014-09-24 22:49:04.000000000 +0200 +++ new/raet-0.3.6/raet/road/keeping.py 2014-10-08 20:50:20.000000000 +0200 @@ -175,6 +175,7 @@ filepath = os.path.join(self.remoteroledirpath, "{0}.{1}.{2}".format('role', role, self.ext)) if not os.path.exists(filepath): + data.update(role=role) return data data.update(self.load(filepath)) return data diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/road/stacking.py new/raet-0.3.6/raet/road/stacking.py --- old/raet-0.3.2/raet/road/stacking.py 2014-09-24 22:48:57.000000000 +0200 +++ new/raet-0.3.6/raet/road/stacking.py 2014-10-09 19:50:08.000000000 +0200 @@ -776,16 +776,50 @@ rxPacket=packet) alivent.alive() - def message(self, body=None, uid=None, timeout=None): + def transmit(self, msg, uid=None, timeout=None): + ''' + Append duple (msg, uid) to .txMsgs deque + If msg is not mapping then raises exception + If uid is None then it will default to the first entry in .remotes + If timeout is None then it will use Messenger default + timeout of 0 means never timeout of message transaction + ''' + if not isinstance(msg, Mapping): + emsg = "Invalid msg, not a mapping {0}\n".format(msg) + console.terse(emsg) + self.incStat("invalid_transmit_body") + return + if uid is None: + if not self.remotes: + emsg = "No remote to send to\n" + console.terse(emsg) + self.incStat("invalid_destination") + return + uid = self.remotes.values()[0].uid + self.txMsgs.append((msg, uid, timeout)) + + def _handleOneTxMsg(self): + ''' + Take one message from .txMsgs deque and handle it + Assumes there is a message on the deque + ''' + # triple (body dict, destination uid, timout) + body, uid, timeout = self.txMsgs.popleft() + self.message(body, uid=uid, timeout=timeout) + console.verbose("{0} sending\n{1}\n".format(self.name, body)) + + def message(self, body, uid=None, timeout=None): ''' Initiate message transaction to remote at duid - If duid is None then create remote at ha + If uid is None then create remote at ha + If timeout is None then use Messenger default + If timeout is 0 then never timeout ''' remote = self.retrieveRemote(uid=uid) if not remote: emsg = "Invalid remote destination estate id '{0}'\n".format(uid) console.terse(emsg) - self.incStat('invalid_remote_eid') + self.incStat('invalid_remote_uid') return data = odict(hk=self.Hk, bk=self.Bk, fk=self.Fk, ck=self.Ck) messenger = transacting.Messenger(stack=self, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/road/test/test_joining.py new/raet-0.3.6/raet/road/test/test_joining.py --- old/raet-0.3.2/raet/road/test/test_joining.py 2014-09-24 22:49:09.000000000 +0200 +++ new/raet-0.3.6/raet/road/test/test_joining.py 2014-10-06 20:35:15.000000000 +0200 @@ -50,11 +50,10 @@ name='', ha=None, main=None, - auto=raeting.autoModes.never): + auto=raeting.autoModes.never, + role=None, + kind=None, ): ''' - name is local estate name (which is stack name property) - base is the base directory for the keep files - auto is the auto accept status mode () Creates odict and populates with data to setup road stack ''' @@ -63,6 +62,8 @@ data['ha'] = ha data['main'] = main data['auto'] = auto + data['role'] = role if role is not None else name + data['kind'] = kind data['dirpath'] = os.path.join(base, 'road', 'keep', name) signer = nacling.Signer() data['sighex'] = signer.keyhex @@ -78,7 +79,9 @@ uid=None, ha=None, main=None, - auto=None,): + auto=None, + role=None, + kind=None, ): ''' Creates stack and local estate from data with and overrides with parameters @@ -90,10 +93,12 @@ name=data['name'], uid=uid, ha=ha or data['ha'], + main=main if main is not None else data['main'], + role=role if role is not None else data['role'], sigkey=data['sighex'], prikey=data['prihex'], - auto=auto or data['auto'], - main=main or data['main'], + auto=auto if auto is not None else data['auto'], + kind=kind if kind is not None else data['kind'], dirpath=data['dirpath'],) return stack diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/road/test/test_packeting.py new/raet-0.3.6/raet/road/test/test_packeting.py --- old/raet-0.3.2/raet/road/test/test_packeting.py 2014-09-17 00:37:59.000000000 +0200 +++ new/raet-0.3.6/raet/road/test/test_packeting.py 2014-10-06 21:41:38.000000000 +0200 @@ -343,7 +343,7 @@ for packet in tray0.packets: tray1.parse(packet) - print tray1.data + print(tray1.data) self.assertDictEqual(tray1.data, {'sh': '', 'sp': 7530, 'dh': '127.0.0.1', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/road/test/test_presenting.py new/raet-0.3.6/raet/road/test/test_presenting.py --- old/raet-0.3.2/raet/road/test/test_presenting.py 2014-09-24 20:00:30.000000000 +0200 +++ new/raet-0.3.6/raet/road/test/test_presenting.py 2014-10-06 20:55:36.000000000 +0200 @@ -45,20 +45,25 @@ if os.path.exists(self.base): shutil.rmtree(self.base) - def createRoadData(self, name, base, auto=None): + def createRoadData(self, + base, + name='', + ha=None, + main=None, + auto=raeting.autoModes.never, + role=None, + kind=None, ): ''' Creates odict and populates with data to setup road stack - { - name: stack name local estate name - dirpath: dirpath for keep files - sighex: signing key - verhex: verify key - prihex: private key - pubhex: public key - } + ''' data = odict() data['name'] = name + data['ha'] = ha + data['main'] = main + data['auto'] = auto + data['role'] = role if role is not None else name + data['kind'] = kind data['dirpath'] = os.path.join(base, 'road', 'keep', name) signer = nacling.Signer() data['sighex'] = signer.keyhex @@ -66,32 +71,35 @@ privateer = nacling.Privateer() data['prihex'] = privateer.keyhex data['pubhex'] = privateer.pubhex - data['auto'] = auto return data - def createRoadStack(self, data, uid=None, main=None, auto=None, ha=None): + def createRoadStack(self, + data, + uid=None, + ha=None, + main=None, + auto=None, + role=None, + kind=None, ): ''' Creates stack and local estate from data with - local estate.uid = uid - stack.main = main - stack.auto = auto - stack.name = data['name'] - local estate.name = data['name'] - local estate.ha = ha + and overrides with parameters returns stack ''' - stack = stacking.RoadStack(name=data['name'], + stack = stacking.RoadStack(store=self.store, + name=data['name'], uid=uid, - ha=ha, + ha=ha or data['ha'], + main=main if main is not None else data['main'], + role=role if role is not None else data['role'], sigkey=data['sighex'], prikey=data['prihex'], auto=auto if auto is not None else data['auto'], - main=main, - dirpath=data['dirpath'], - store=self.store) + kind=kind if kind is not None else data['kind'], + dirpath=data['dirpath'],) return stack @@ -201,6 +209,85 @@ time.sleep(0.1) + def testJoinNameRoleDiffer(self): + ''' + Test join from other where name and role are different + ''' + console.terse("{0}\n".format(self.testJoinNameRoleDiffer.__doc__)) + + mainData = self.createRoadData(name='main_stack', + role='main', + base=self.base, + auto=raeting.autoModes.once) + keeping.clearAllKeep(mainData['dirpath']) + main = self.createRoadStack(data=mainData, + main=True, + auto=mainData['auto'], + ha=None) + + otherData = self.createRoadData(name='other_stack', + role='other', + base=self.base, + auto=raeting.autoModes.once) + keeping.clearAllKeep(otherData['dirpath']) + other = self.createRoadStack(data=otherData, + main=None, + ha=("", raeting.RAET_TEST_PORT)) + + self.assertNotEqual(main.local.name, main.local.role) + self.assertNotEqual(other.local.name, other.local.role) + self.assertIs(other.main, None) + self.assertIs(other.keep.auto, raeting.autoModes.once) + + console.terse("\nJoin Other to Main *********\n") + self.join(other, main) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, None) + self.assertIs(remote.alived, None) + + console.terse("\nAllow Other to Main *********\n") + self.allow(other, main) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, True) + self.assertIs(remote.alived, None) + + console.terse("\nAlive Other to Main *********\n") + self.alive(other, main) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, True) + self.assertIs(remote.alived, True) + + console.terse("\nAlive Main to Other *********\n") + self.alive(main, other) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, True) + self.assertIs(remote.alived, True) + + for stack in [main, other]: + stack.server.close() + stack.clearAllKeeps() + + def testJoinFromMain(self): ''' Test join,initiated by main @@ -218,13 +305,106 @@ otherData = self.createRoadData(name='other', base=self.base, - auto=raeting.autoModes.once) + auto=raeting.autoModes.never) + keeping.clearAllKeep(otherData['dirpath']) + other = self.createRoadStack(data=otherData, + main=None, + ha=("", raeting.RAET_TEST_PORT)) + + self.assertIs(other.keep.auto, raeting.autoModes.never) + self.assertIs(other.main, None) + + console.terse("\nJoin Main to Other *********\n") + self.join(main, other) # vacuous join fails because other not main + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 0) + self.assertEqual(len(stack.nameRemotes), 0) + + # now fix it so other can accept vacuous joins + other.main = True + other.keep.auto = raeting.autoModes.once + self.assertIs(other.main, True) + self.assertIs(other.keep.auto, raeting.autoModes.once) + + self.join(main, other) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, None) + self.assertIs(remote.alived, None) + + console.terse("\nAllow Main to Other *********\n") + self.allow(main, other) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, True) + self.assertIs(remote.alived, None) + + console.terse("\nAlive Main to other *********\n") + self.alive(main, other) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, True) + self.assertIs(remote.alived, True) + + console.terse("\nAlive Other to Main *********\n") + self.alive(other, main) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, True) + self.assertIs(remote.alived, True) + + + for stack in [main, other]: + stack.server.close() + stack.clearAllKeeps() + + def testJoinFromMainNameRoleDiffer(self): + ''' + Test join from main where name and role are different + ''' + console.terse("{0}\n".format(self.testJoinFromMainNameRoleDiffer.__doc__)) + + mainData = self.createRoadData(name='main_stack', + role='main', + base=self.base, + auto=raeting.autoModes.once) + keeping.clearAllKeep(mainData['dirpath']) + main = self.createRoadStack(data=mainData, + main=True, + auto=mainData['auto'], + ha=None) + + otherData = self.createRoadData(name='other_stack', + role='other', + base=self.base, + auto=raeting.autoModes.never) keeping.clearAllKeep(otherData['dirpath']) other = self.createRoadStack(data=otherData, main=None, - auto=raeting.autoModes.never, ha=("", raeting.RAET_TEST_PORT)) + self.assertNotEqual(main.local.name, main.local.role) + self.assertNotEqual(other.local.name, other.local.role) + self.assertIs(other.keep.auto, raeting.autoModes.never) + self.assertIs(other.main, None) + console.terse("\nJoin Main to Other *********\n") self.join(main, other) # vacuous join fails because other not main for stack in [main, other]: @@ -235,6 +415,9 @@ # now fix it so other can accept vacuous joins other.main = True other.keep.auto = raeting.autoModes.once + self.assertIs(other.main, True) + self.assertIs(other.keep.auto, raeting.autoModes.once) + self.join(main, other) for stack in [main, other]: @@ -279,6 +462,119 @@ self.assertIs(remote.allowed, True) self.assertIs(remote.alived, True) + for stack in [main, other]: + stack.server.close() + stack.clearAllKeeps() + + def testJoinFromMainKindChange(self): + ''' + Test allow from main where name changed from join + This reproduces what happens if name changed after successful join + and reboot + so joined is persisted so allow fails + ''' + console.terse("{0}\n".format(self.testJoinFromMainKindChange.__doc__)) + + mainData = self.createRoadData(name='main_stack', + role='main', + base=self.base, + auto=raeting.autoModes.once) + keeping.clearAllKeep(mainData['dirpath']) + main = self.createRoadStack(data=mainData, + main=True, + auto=mainData['auto'], + ha=None) + + otherData = self.createRoadData(name='other_stack', + role='other', + base=self.base, + auto=raeting.autoModes.once) + keeping.clearAllKeep(otherData['dirpath']) + other = self.createRoadStack(data=otherData, + main=True, + ha=("", raeting.RAET_TEST_PORT)) + + self.assertNotEqual(main.local.name, main.local.role) + self.assertNotEqual(other.local.name, other.local.role) + self.assertIs(other.main, True) + self.assertIs(other.keep.auto, raeting.autoModes.once) + + console.terse("\nJoin Main to Other *********\n") + self.join(main, other) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, None) + self.assertIs(remote.alived, None) + + # Change kind + other.kind = 1 + self.assertNotEqual(other.kind, otherData['kind']) + main.kind = 1 + self.assertNotEqual(main.kind, mainData['kind']) + + self.join(main, other) # fails because not same all and immutable road + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + + self.assertEqual(len(main.remotes), 0) + self.assertEqual(len(main.nameRemotes), 0) + + self.assertEqual(len(other.remotes), 1) + self.assertEqual(len(other.nameRemotes), 1) + remote = other.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, None) + self.assertIs(remote.alived, None) + + other.mutable = True + self.assertIs(other.mutable, True) + self.join(main, other) # fails because not same all and immutable road + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, None) + self.assertIs(remote.alived, None) + + console.terse("\nAllow Main to Other *********\n") + self.allow(main, other) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, True) + self.assertIs(remote.alived, None) + + console.terse("\nAlive Main to other *********\n") + self.alive(main, other) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, True) + self.assertIs(remote.alived, True) + + console.terse("\nAlive Other to Main *********\n") + self.alive(other, main) + for stack in [main, other]: + self.assertEqual(len(stack.transactions), 0) + self.assertEqual(len(stack.remotes), 1) + self.assertEqual(len(stack.nameRemotes), 1) + remote = stack.remotes.values()[0] + self.assertIs(remote.joined, True) + self.assertIs(remote.allowed, True) + self.assertIs(remote.alived, True) + for stack in [main, other]: stack.server.close() @@ -1835,16 +2131,21 @@ Unittest runner ''' tests = [] - names = ['testJoinFromMain', - 'testAliveDead', - 'testAliveDeadMultiple', - 'testAliveUnjoinedUnallowedBoth', - 'testCascadeBoth', - 'testManageOneSide', - 'testManageBothSides', - 'testManageMainRebootCascade', - 'testManageRebootCascadeBothSides', - 'testManageRebootCascadeBothSidesAlt', ] + names = [ + 'testJoinNameRoleDiffer', + 'testJoinFromMain', + 'testJoinFromMainNameRoleDiffer', + 'testJoinFromMainKindChange', + 'testAliveDead', + 'testAliveDeadMultiple', + 'testAliveUnjoinedUnallowedBoth', + 'testCascadeBoth', + 'testManageOneSide', + 'testManageBothSides', + 'testManageMainRebootCascade', + 'testManageRebootCascadeBothSides', + 'testManageRebootCascadeBothSidesAlt', + ] tests.extend(map(BasicTestCase, names)) @@ -1866,6 +2167,6 @@ #runAll() #run all unittests - runSome()#only run some + #runSome()#only run some - #runOne('testManageRebootCascadeBothSides') + runOne('testJoinFromMainKindChange') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/road/test/test_stacking.py new/raet-0.3.6/raet/road/test/test_stacking.py --- old/raet-0.3.2/raet/road/test/test_stacking.py 2014-09-17 00:37:59.000000000 +0200 +++ new/raet-0.3.6/raet/road/test/test_stacking.py 2014-10-09 19:33:24.000000000 +0200 @@ -3,6 +3,7 @@ Tests to try out stacking. Potentially ephemeral ''' +from __future__ import print_function # pylint: skip-file import sys if sys.version_info < (2, 7): @@ -243,7 +244,7 @@ console.terse("\nMessage: other to main *********\n") body = odict(what="This is a message to the main estate. How are you", extra="I am fine.") - self.other.txMsgs.append((body, self.other.remotes.values()[0].fuid)) + self.other.txMsgs.append((body, self.other.remotes.values()[0].fuid, None)) #self.other.message(body=body, deid=self.main.local.uid) self.service() @@ -255,7 +256,7 @@ console.terse("\nMessage: main to other *********\n") body = odict(what="This is a message to the other estate. Get to Work", extra="Fix the fence.") - self.main.txMsgs.append((body, self.main.remotes.values()[0].fuid)) + self.main.txMsgs.append((body, self.main.remotes.values()[0].fuid, None)) #self.main.message(body=body, deid=self.other.local.uid) self.service() @@ -596,7 +597,7 @@ console.terse("\nMessage transaction *********\n") body = odict(what="This is a message to the main estate. How are you", extra="I am fine.") - self.other.txMsgs.append((body, self.other.remotes.values()[0].fuid)) + self.other.txMsgs.append((body, self.other.remotes.values()[0].fuid, None)) self.timer.restart(duration=1.0) while not self.timer.expired: self.other.serviceAllTx() # transmit but leave receives in socket buffer @@ -622,14 +623,14 @@ self.assertEqual(len(self.main.transactions), 0) self.assertEqual(len(self.other.transactions), 0) - print "{0} Stats".format(self.main.name) + print("{0} Stats".format(self.main.name)) for key, val in self.main.stats.items(): - print " {0}={1}".format(key, val) - print - print "{0} Stats".format(self.other.name) + print(" {0}={1}".format(key, val)) + print() + print("{0} Stats".format(self.other.name)) for key, val in self.other.stats.items(): - print " {0}={1}".format(key, val) - print + print(" {0}={1}".format(key, val)) + print() self.assertTrue(self.other.stats.get('stale_correspondent_attempt') >= 1) self.assertTrue(self.other.stats.get('stale_correspondent_nack') >= 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/road/transacting.py new/raet-0.3.6/raet/road/transacting.py --- old/raet-0.3.2/raet/road/transacting.py 2014-09-30 23:08:29.000000000 +0200 +++ new/raet-0.3.6/raet/road/transacting.py 2014-10-09 19:59:16.000000000 +0200 @@ -658,7 +658,7 @@ kind == self.remote.kind) if not sameAll and not self.stack.mutable: - emsg = ("Joiner {0}. Attempt to change immutable road " + emsg = ("Joiner {0}. Attempt to change immutable road by " "'{1}'\n".format(self.stack.name, self.remote.name)) console.terse(emsg) @@ -1151,7 +1151,7 @@ kind == self.remote.kind) if not sameAll and not self.stack.mutable: - emsg = ("Joinent {0}. Attempt to change immutable road " + emsg = ("Joinent {0}. Attempt to change immutable road by " "'{1}'\n".format(self.stack.name, self.remote.name)) console.terse(emsg) @@ -2206,6 +2206,9 @@ elif kind==raeting.pcktKinds.reject: console.concise("Allowent {0}. Do Nack Reject {1} at {2}\n".format( self.stack.name, self.remote.name, self.stack.store.stamp)) + elif kind==raeting.pcktKinds.unjoined: + console.concise("Allowent {0}. Do Nack Unjoined {1} at {2}\n".format( + self.stack.name, self.remote.name, self.stack.store.stamp)) elif kind == raeting.pcktKinds.nack: console.terse("Allowent {0}. Do Nack of {1} at {2}\n".format( self.stack.name, self.remote.name, self.stack.store.stamp)) @@ -2583,7 +2586,7 @@ RAET protocol Messenger Initiator class Dual of Messengent Generic messages ''' - Timeout = 10.0 + Timeout = 0.0 RedoTimeoutMin = 1.0 # initial timeout RedoTimeoutMax = 3.0 # max timeout @@ -2815,7 +2818,7 @@ RAET protocol Messengent Correspondent class Dual of Messenger Generic Messages ''' - Timeout = 10.0 + Timeout = 0.0 RedoTimeoutMin = 1.0 # initial timeout RedoTimeoutMax = 3.0 # max timeout diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet/stacking.py new/raet-0.3.6/raet/stacking.py --- old/raet-0.3.2/raet/stacking.py 2014-09-17 00:37:59.000000000 +0200 +++ new/raet-0.3.6/raet/stacking.py 2014-10-09 19:45:14.000000000 +0200 @@ -9,6 +9,9 @@ import socket import os import errno +import sys +if sys.version_info > (3,): + long = int from collections import deque, Mapping try: @@ -136,7 +139,7 @@ Generates next unique id number for local or remotes. ''' self.puid += 1 - if self.puid > 0xffffffffL: + if self.puid > long(0xffffffff): self.puid = 1 # rollover to 1 return self.puid @@ -322,33 +325,33 @@ ''' pass - def transmit(self, msg, duid=None): + def transmit(self, msg, uid=None): ''' - Append duple (msg, duid) to .txMsgs deque + Append duple (msg, uid) to .txMsgs deque If msg is not mapping then raises exception - If duid is None then it will default to the first entry in .remotes + If uid is None then it will default to the first entry in .remotes ''' if not isinstance(msg, Mapping): emsg = "Invalid msg, not a mapping {0}\n".format(msg) console.terse(emsg) self.incStat("invalid_transmit_body") return - if duid is None: + if uid is None: if not self.remotes: emsg = "No remote to send to\n" console.terse(emsg) self.incStat("invalid_destination") return - duid = self.remotes.values()[0].uid - self.txMsgs.append((msg, duid)) + uid = self.remotes.values()[0].uid + self.txMsgs.append((msg, uid)) def _handleOneTxMsg(self): ''' Take one message from .txMsgs deque and handle it Assumes there is a message on the deque ''' - body, duid = self.txMsgs.popleft() # duple (body dict, destination uid - self.message(body, duid) + body, uid = self.txMsgs.popleft() # duple (body dict, destination uid + self.message(body, uid=uid) console.verbose("{0} sending\n{1}\n".format(self.name, body)) def serviceTxMsgs(self): @@ -365,9 +368,9 @@ if self.txMsgs: self._handleOneTxMsg() - def message(self, body, duid): + def message(self, body, uid=None): ''' - Sends message body remote at duid + Sends message body to remote at uid ''' pass @@ -399,8 +402,10 @@ try: self.server.send(tx, ta) except socket.error as ex: - if ex.errno == errno.EAGAIN or ex.errno == errno.EWOULDBLOCK: - #busy with last message save it for later + if (ex.errno in [errno.EAGAIN, errno.EWOULDBLOCK, + errno.ENETUNREACH, errno.ETIME, + errno.EHOSTUNREACH, errno.EHOSTDOWN]): + # problem sending such as busy with last message. save it for later laters.append((tx, ta)) blocks.append(ta) else: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/raet-0.3.2/raet.egg-info/PKG-INFO new/raet-0.3.6/raet.egg-info/PKG-INFO --- old/raet-0.3.2/raet.egg-info/PKG-INFO 2014-10-02 19:54:52.000000000 +0200 +++ new/raet-0.3.6/raet.egg-info/PKG-INFO 2014-10-09 20:25:12.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: raet -Version: 0.3.2 +Version: 0.3.6 Summary: Reliable Asynchronous Event Transport protocol Home-page: https://github.com/saltstack/raet Author: Samuel M. Smith -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
