def setUp(self): self.store = storing.Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) if sys.platform == 'win32': self.tempDirpath = tempfile.mktemp(prefix="raet", suffix="base", dir=TEMPDIR) else: self.tempDirpath = tempfile.mkdtemp(prefix="raet", suffix="base", dir=TEMPDIR) self.baseDirpath = os.path.join(self.tempDirpath, 'lane', 'keep') # main stack self.main = stacking.LaneStack(name='main', uid=1, lanename='cherry', sockdirpath=self.baseDirpath) #other stack self.other = stacking.LaneStack(name='other', uid=1, lanename='cherry', sockdirpath=self.baseDirpath)
def setUp(self): self.store = storing.Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) self.mainDirpath = tempfile.mkdtemp(prefix="salt", suffix='main', dir='/tmp') opts = self.createOpts(self.mainDirpath, openMode=True, autoAccept=True) self.mainSafe = salting.SaltSafe(opts=opts) self.otherDirpath = tempfile.mkdtemp(prefix="salt", suffix='other', dir='/tmp') opts = self.createOpts(self.otherDirpath, openMode=True, autoAccept=True) self.otherSafe = salting.SaltSafe(opts=opts) self.baseDirpath = tempfile.mkdtemp(prefix="raet", suffix="base", dir='/tmp')
def setUp(self): self.store = storing.Store(stamp=0.0) dirpathBase='/tmp/raet/' #main stack mainName = "main" mainDirpath = os.path.join(dirpathBase, 'road', 'keep', mainName) signer = nacling.Signer() mainSignKeyHex = signer.keyhex privateer = nacling.Privateer() mainPriKeyHex = privateer.keyhex #other stack otherName = "other" otherDirpath = os.path.join(dirpathBase, 'road', 'keep', otherName) signer = nacling.Signer() otherSignKeyHex = signer.keyhex privateer = nacling.Privateer() otherPriKeyHex = privateer.keyhex keeping.clearAllKeepSafe(mainDirpath) keeping.clearAllKeepSafe(otherDirpath) local = estating.LocalEstate(eid=1, name=mainName, sigkey=mainSignKeyHex, prikey=mainPriKeyHex,) self.main = stacking.RoadStack(name=mainName, local=local, auto=True, main=True, dirpath=mainDirpath, store=self.store) local = estating.LocalEstate(eid=0, name=otherName, ha=("", raeting.RAET_TEST_PORT), sigkey=otherSignKeyHex, prikey=otherPriKeyHex,) self.other = stacking.RoadStack(name=otherName, local=local, dirpath=otherDirpath, store=self.store) self.timer = StoreTimer(store=self.store, duration=1.0)
def setUp(self): self.store = storing.Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) self.baseDirpath = tempfile.mkdtemp(prefix="raet", suffix="base", dir=TEMPDIR) stacking.RoadStack.Bk = raeting.bodyKinds.json #main stack mainName = "main" mainDirpath = os.path.join(self.baseDirpath, 'road', 'keep', mainName) signer = nacling.Signer() mainSignKeyHex = signer.keyhex privateer = nacling.Privateer() mainPriKeyHex = privateer.keyhex #other stack otherName = "other" otherDirpath = os.path.join(self.baseDirpath, 'road', 'keep', otherName) signer = nacling.Signer() otherSignKeyHex = signer.keyhex privateer = nacling.Privateer() otherPriKeyHex = privateer.keyhex keeping.clearAllKeep(mainDirpath) keeping.clearAllKeep(otherDirpath) self.main = stacking.RoadStack( store=self.store, name=mainName, main=True, auto=raeting.autoModes.once, sigkey=mainSignKeyHex, prikey=mainPriKeyHex, dirpath=mainDirpath, ) self.other = stacking.RoadStack( store=self.store, name=otherName, auto=raeting.autoModes.once, ha=("", raeting.RAET_TEST_PORT), sigkey=otherSignKeyHex, prikey=otherPriKeyHex, dirpath=otherDirpath, )
def setUp(self): self.store = storing.Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) self.saltDirpath = tempfile.mkdtemp(prefix="salt", suffix="main", dir='/tmp') pkiDirpath = os.path.join(self.saltDirpath, 'pki') if not os.path.exists(pkiDirpath): os.makedirs(pkiDirpath) acceptedDirpath = os.path.join(pkiDirpath, 'accepted') if not os.path.exists(acceptedDirpath): os.makedirs(acceptedDirpath) pendingDirpath = os.path.join(pkiDirpath, 'pending') if not os.path.exists(pendingDirpath): os.makedirs(pendingDirpath) rejectedDirpath = os.path.join(pkiDirpath, 'rejected') if not os.path.exists(rejectedDirpath): os.makedirs(rejectedDirpath) self.localFilepath = os.path.join(pkiDirpath, 'local.key') if os.path.exists(self.localFilepath): mode = os.stat(self.localFilepath).st_mode os.chmod(self.localFilepath, mode | stat.S_IWUSR | stat.S_IWUSR) self.cacheDirpath = os.path.join(self.saltDirpath, 'cache') self.sockDirpath = os.path.join(self.saltDirpath, 'sock') self.opts = dict( __role='master', id='master', pki_dir=pkiDirpath, sock_dir=self.sockDirpath, cachedir=self.cacheDirpath, open_mode=False, auto_accept=True, transport='raet', ) self.mainKeeper = RaetKey(opts=self.opts) self.baseDirpath = tempfile.mkdtemp(prefix="salt", suffix="base", dir='/tmp')
def setUp(self): self.store = storing.Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) self.baseDirpath = os.path.join( tempfile.mkdtemp(prefix="raet", suffix="base", dir='/tmp'), 'lane', 'keep') # main stack self.main = stacking.LaneStack(name='main', yid=1, localname='main', lanename='cherry', basedirpath=self.baseDirpath, sockdirpath=self.baseDirpath) #other stack self.other = stacking.LaneStack(name='other', yid=1, localname='other', lanename='cherry', basedirpath=self.baseDirpath, sockdirpath=self.baseDirpath)
def setUp(self): self.store = storing.Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0)
def setUp(self): self.store = storing.Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) self.base = tempfile.mkdtemp(prefix="raet", suffix="base", dir='/tmp')
def setUp(self): self.store = storing.Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) self.dirpathBase = tempfile.mkdtemp(prefix="raet", suffix="base", dir='/tmp') stacking.RoadStack.Bk = raeting.bodyKinds.json #main stack mainName = "main" mainDirpath = os.path.join(self.dirpathBase, 'road', 'keep', mainName) signer = nacling.Signer() mainSignKeyHex = signer.keyhex mainVerKeyHex = signer.verhex privateer = nacling.Privateer() mainPriKeyHex = privateer.keyhex mainPubKeyHex = privateer.pubhex #other stack otherName = "other" otherDirpath = os.path.join(self.dirpathBase, 'road', 'keep', otherName) signer = nacling.Signer() otherSignKeyHex = signer.keyhex otherVerKeyHex = signer.verhex privateer = nacling.Privateer() otherPriKeyHex = privateer.keyhex otherPubKeyHex = privateer.pubhex keeping.clearAllKeepSafe(mainDirpath) keeping.clearAllKeepSafe(otherDirpath) local = estating.LocalEstate( eid=1, name=mainName, sigkey=mainSignKeyHex, prikey=mainPriKeyHex, ) self.main = stacking.RoadStack(name=mainName, local=local, auto=True, main=True, dirpath=mainDirpath, store=self.store) remote1 = estating.RemoteEstate( stack=self.main, eid=2, name=otherName, ha=("127.0.0.1", raeting.RAET_TEST_PORT), verkey=otherVerKeyHex, pubkey=otherPubKeyHex, period=self.main.period, offset=self.main.offset, ) self.main.addRemote(remote1) local = estating.LocalEstate( eid=2, name=otherName, ha=("", raeting.RAET_TEST_PORT), sigkey=otherSignKeyHex, prikey=otherPriKeyHex, ) self.other = stacking.RoadStack(name=otherName, local=local, dirpath=otherDirpath, store=self.store) remote0 = estating.RemoteEstate( stack=self.other, eid=1, name=mainName, ha=('127.0.0.1', raeting.RAET_PORT), verkey=mainVerKeyHex, pubkey=mainPubKeyHex, period=self.other.period, offset=self.other.offset, ) self.other.addRemote(remote0) remote0.publee = nacling.Publican(key=remote1.privee.pubhex) remote1.publee = nacling.Publican(key=remote0.privee.pubhex) stuff = [] for i in range(300): stuff.append(str(i).rjust(4, " ")) self.stuff = "".join(stuff) self.data = odict(hk=raeting.headKinds.raet)
def test(preClearMaster=True, preClearMinion=True, postClearMaster=True, postClearMinion=True): ''' initially master on port 7530 with eid of 1 minion on port 7531 with eid of 0 eventually master eid of 1 minion eid of 2 ''' console.reinit(verbosity=console.Wordage.concise) store = storing.Store(stamp=0.0) #master stack masterName = "master" signer = nacling.Signer() masterSignKeyHex = signer.keyhex privateer = nacling.Privateer() masterPriKeyHex = privateer.keyhex masterDirpath = os.path.join('/tmp/raet/road', 'keep', masterName) #minion0 stack minionName0 = "minion0" signer = nacling.Signer() minionSignKeyHex = signer.keyhex privateer = nacling.Privateer() minionPriKeyHex = privateer.keyhex m0Dirpath = os.path.join('/tmp/raet/road', 'keep', minionName0) if preClearMaster: keeping.clearAllKeepSafe(masterDirpath) if preClearMinion: keeping.clearAllKeepSafe(m0Dirpath) local = estating.LocalEstate( eid=1, name=masterName, sigkey=masterSignKeyHex, prikey=masterPriKeyHex, ) stack0 = stacking.RoadStack(name=masterName, local=local, auto=True, store=store, main=True, dirpath=masterDirpath) local = estating.LocalEstate( eid=0, name=minionName0, ha=("", raeting.RAET_TEST_PORT), sigkey=minionSignKeyHex, prikey=minionPriKeyHex, ) stack1 = stacking.RoadStack(name=minionName0, local=local, store=store, dirpath=m0Dirpath) print "\n********* Join Forever Transaction **********" #transacting.Joiner.Timeout = 0 # make join go on forever stack1.join(timeout=0.0) # make join go on forever timer = StoreTimer(store=store, duration=30.0) while (stack1.transactions or stack0.transactions) and not timer.expired: stack1.serviceAll() if timer.elapsed > 20.0: stack0.serviceAll() store.advanceStamp(0.1) for remote in stack0.remotes.values(): print "{0} Remote Estate {1} joined= {2}".format( stack0.name, remote.eid, remote.joined) for remote in stack1.remotes.values(): print "{0} Remote Estate {1} joined= {2}".format( stack1.name, remote.eid, remote.joined) print "{0} Stats".format(stack0.name) for key, val in stack0.stats.items(): print " {0}={1}".format(key, val) print print "{0} Stats".format(stack1.name) for key, val in stack1.stats.items(): print " {0}={1}".format(key, val) print print "\n********* Join Default Timeout Transaction **********" stack1.join(timeout=None) timer.restart() while (stack1.transactions or stack0.transactions) and not timer.expired: stack1.serviceAll() if timer.elapsed > 20.0: stack0.serviceAll() store.advanceStamp(0.1) for remote in stack0.remotes.values(): print "{0} Remote Estate {1} joined= {2}".format( stack0.name, remote.eid, remote.joined) for remote in stack1.remotes.values(): print "{0} Remote Estate {1} joined= {2}".format( stack1.name, remote.eid, remote.joined) print "{0} Stats".format(stack0.name) for key, val in stack0.stats.items(): print " {0}={1}".format(key, val) print print "{0} Stats".format(stack1.name) for key, val in stack1.stats.items(): print " {0}={1}".format(key, val) print for uid in stack0.remotes: stack0.removeRemote(uid) for uid in stack1.remotes: stack1.removeRemote(uid) if postClearMaster: keeping.clearAllKeepSafe(masterDirpath) if postClearMinion: keeping.clearAllKeepSafe(m0Dirpath) print "Road {0}".format(stack0.name) print stack0.keep.loadLocalData() print stack0.keep.loadAllRemoteData() print "Safe {0}".format(stack0.name) print stack0.safe.loadLocalData() print stack0.safe.loadAllRemoteData() print print "Road {0}".format(stack1.name) print stack1.keep.loadLocalData() print stack1.keep.loadAllRemoteData() print "Safe {0}".format(stack1.name) print stack1.safe.loadLocalData() print stack1.safe.loadAllRemoteData() print print "\n********* Join Default Timeout Transaction After Clear Keeps **********" stack1.join(timeout=None) timer.restart() while (stack1.transactions or stack0.transactions) and not timer.expired: stack1.serviceAll() if timer.elapsed > 20.0: stack0.serviceAll() store.advanceStamp(0.1) for remote in stack0.remotes.values(): print "{0} Remote Estate {1} joined= {2}".format( stack0.name, remote.eid, remote.joined) for remote in stack1.remotes.values(): print "{0} Remote Estate {1} joined= {2}".format( stack1.name, remote.eid, remote.joined) print "{0} Stats".format(stack0.name) for key, val in stack0.stats.items(): print " {0}={1}".format(key, val) print print "{0} Stats".format(stack1.name) for key, val in stack1.stats.items(): print " {0}={1}".format(key, val) print print "\n********* Join Forever Timeout Transaction After Clear Keeps**********" stack1.join(timeout=0.0) timer.restart() while (stack1.transactions or stack0.transactions) and not timer.expired: stack1.serviceAll() if timer.elapsed > 20.0: stack0.serviceAll() store.advanceStamp(0.1) for remote in stack0.remotes.values(): print "{0} Remote Estate {1} joined= {2}".format( stack0.name, remote.eid, remote.joined) for remote in stack1.remotes.values(): print "{0} Remote Estate {1} joined= {2}".format( stack1.name, remote.eid, remote.joined) print "{0} Stats".format(stack0.name) for key, val in stack0.stats.items(): print " {0}={1}".format(key, val) print print "{0} Stats".format(stack1.name) for key, val in stack1.stats.items(): print " {0}={1}".format(key, val) print stack0.server.close() stack1.server.close() if postClearMaster: keeping.clearAllKeepSafe(masterDirpath) if postClearMinion: keeping.clearAllKeepSafe(m0Dirpath)
def setUp(self): self.store = storing.Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) self.port = 4506 self.opts = dict(master_port=self.port)
def setUp(self): self.store = storing.Store(stamp=0.0) self.timer = StoreTimer(store=self.store, duration=1.0) self.tempDirpath = tempfile.mkdtemp(prefix="salt", suffix='keep', dir='/tmp')