def setUp(self) : self.homeDirMaster = get_new_environment_path() self.homeDirClient = get_new_environment_path() self.dbenvMaster = db.DBEnv() self.dbenvClient = db.DBEnv() # Must use "DB_THREAD" because the Replication Manager will # be executed in other threads but will use the same environment. # http://forums.oracle.com/forums/thread.jspa?threadID=645788&tstart=0 self.dbenvMaster.open(self.homeDirMaster, db.DB_CREATE | db.DB_INIT_TXN | db.DB_INIT_LOG | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_INIT_REP | db.DB_RECOVER | db.DB_THREAD, 0666) self.dbenvClient.open(self.homeDirClient, db.DB_CREATE | db.DB_INIT_TXN | db.DB_INIT_LOG | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_INIT_REP | db.DB_RECOVER | db.DB_THREAD, 0666) self.confirmed_master=self.client_startupdone=False def confirmed_master(a,b,c) : if b==db.DB_EVENT_REP_MASTER : self.confirmed_master=True def client_startupdone(a,b,c) : if b==db.DB_EVENT_REP_STARTUPDONE : self.client_startupdone=True self.dbenvMaster.set_event_notify(confirmed_master) self.dbenvClient.set_event_notify(client_startupdone) #self.dbenvMaster.set_verbose(db.DB_VERB_REPLICATION, True) #self.dbenvMaster.set_verbose(db.DB_VERB_FILEOPS_ALL, True) #self.dbenvClient.set_verbose(db.DB_VERB_REPLICATION, True) #self.dbenvClient.set_verbose(db.DB_VERB_FILEOPS_ALL, True) self.dbMaster = self.dbClient = None
def setUp(self): if self.useEnv: self.homeDir = get_new_environment_path() try: self.env = db.DBEnv() self.env.set_lg_max(1024 * 1024) self.env.set_tx_max(30) self.env.set_tx_timestamp(int(time.time())) self.env.set_flags(self.envsetflags, 1) self.env.open(self.homeDir, self.envflags | db.DB_CREATE) self.filename = "test" # Yes, a bare except is intended, since we're re-raising the exc. except: test_support.rmtree(self.homeDir) raise else: self.env = None self.filename = get_new_database_path() # create and open the DB self.d = db.DB(self.env) self.d.set_flags(self.dbsetflags) if self.dbname: self.d.open(self.filename, self.dbname, self.dbtype, self.dbopenflags | db.DB_CREATE, self.dbmode) else: self.d.open( self.filename, # try out keyword args mode=self.dbmode, dbtype=self.dbtype, flags=self.dbopenflags | db.DB_CREATE) self.populateDB()
def setUp(self): if self.useEnv: self.homeDir = get_new_environment_path() try: self.env = db.DBEnv() self.env.set_lg_max(1048576) self.env.set_tx_max(30) self._t = int(time.time()) self.env.set_tx_timestamp(self._t) self.env.set_flags(self.envsetflags, 1) self.env.open(self.homeDir, self.envflags | db.DB_CREATE) self.filename = 'test' except: test_support.rmtree(self.homeDir) raise else: self.env = None self.filename = get_new_database_path() self.d = db.DB(self.env) if not self.useEnv: self.d.set_cachesize(*self.cachesize) cachesize = self.d.get_cachesize() self.assertEqual(cachesize[0], self.cachesize[0]) self.assertEqual(cachesize[2], self.cachesize[2]) self.assertEqual(125, int(100.0 * cachesize[1] / self.cachesize[1])) self.d.set_flags(self.dbsetflags) if self.dbname: self.d.open(self.filename, self.dbname, self.dbtype, self.dbopenflags | db.DB_CREATE, self.dbmode) else: self.d.open(self.filename, mode=self.dbmode, dbtype=self.dbtype, flags=self.dbopenflags | db.DB_CREATE) if not self.useEnv: self.assertRaises(db.DBInvalidArgError, self.d.set_cachesize, *self.cachesize) self.populateDB() return
def setUp(self): import sys if sys.version_info[0] >= 3: from test_all import do_proxy_db_py3k self._flag_proxy_db_py3k = do_proxy_db_py3k(False) self.testHomeDir = get_new_environment_path() self.tdb = dbtables.bsdTableDB(filename='tabletest.db', dbhome=self.testHomeDir, create=1)
def setUp(self): self.filename = self.__class__.__name__ + '.db' self.homeDir = get_new_environment_path() self.env = db.DBEnv() self.env.open( self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_THREAD | self.envFlags)
def test02_WithSource(self): """ A Recno file that is given a "backing source file" is essentially a simple ASCII file. Normally each record is delimited by \n and so is just a line in the file, but you can set a different record delimiter if needed. """ homeDir = get_new_environment_path() self.homeDir = homeDir source = os.path.join(homeDir, "test_recno.txt") if not os.path.isdir(homeDir): os.mkdir(homeDir) f = open(source, "w") # create the file f.close() d = db.DB() # This is the default value, just checking if both int d.set_re_delim(0x0A) d.set_re_delim("\n") # and char can be used... d.set_re_source(source) d.open(self.filename, db.DB_RECNO, db.DB_CREATE) data = "The quick brown fox jumped over the lazy dog".split() for datum in data: d.append(datum) d.sync() d.close() # get the text from the backing source f = open(source, "r") text = f.read() f.close() text = text.strip() if verbose: print text print data print text.split("\n") self.assertEqual(text.split("\n"), data) # open as a DB again d = db.DB() d.set_re_source(source) d.open(self.filename, db.DB_RECNO) d[3] = "reddish-brown" d[8] = "comatose" d.sync() d.close() f = open(source, "r") text = f.read() f.close() text = text.strip() if verbose: print text print text.split("\n") self.assertEqual(text.split("\n"), "The quick reddish-brown fox jumped over the comatose dog".split())
def setUp(self): self.int_32_max = 4294967296L self.homeDir = get_new_environment_path() self.filename = 'test' self.dbenv = db.DBEnv() self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL, 438) self.d = db.DB(self.dbenv) self.d.open(self.filename, db.DB_BTREE, db.DB_CREATE, 438)
def setUp(self): self.int_32_max = 0x100000000 self.homeDir = get_new_environment_path() self.filename = "test" self.dbenv = db.DBEnv() self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL, 0666) self.d = db.DB(self.dbenv) self.d.open(self.filename, db.DB_BTREE, db.DB_CREATE, 0666)
def setUp(self): if verbose: dbutils._deadlock_VerboseFile = sys.stdout self.homeDir = get_new_environment_path() self.env = db.DBEnv() self.setEnvOpts() self.env.open(self.homeDir, self.envflags | db.DB_CREATE) self.filename = self.__class__.__name__ + '.db' self.d = db.DB(self.env) if self.dbsetflags: self.d.set_flags(self.dbsetflags) self.d.open(self.filename, self.dbtype, self.dbopenflags | db.DB_CREATE)
def setUp(self): self.homeDirMaster = get_new_environment_path() self.homeDirClient = get_new_environment_path() self.dbenvMaster = db.DBEnv() self.dbenvClient = db.DBEnv() self.dbenvMaster.open(self.homeDirMaster, db.DB_CREATE | db.DB_INIT_TXN | db.DB_INIT_LOG | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_INIT_REP | db.DB_RECOVER | db.DB_THREAD, 438) self.dbenvClient.open(self.homeDirClient, db.DB_CREATE | db.DB_INIT_TXN | db.DB_INIT_LOG | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_INIT_REP | db.DB_RECOVER | db.DB_THREAD, 438) self.confirmed_master = self.client_startupdone = False def confirmed_master(a, b, c): if b == db.DB_EVENT_REP_MASTER: self.confirmed_master = True def client_startupdone(a, b, c): if b == db.DB_EVENT_REP_STARTUPDONE: self.client_startupdone = True self.dbenvMaster.set_event_notify(confirmed_master) self.dbenvClient.set_event_notify(client_startupdone) self.dbMaster = self.dbClient = None return
def setUp(self): self.homeDir = get_new_environment_path() self.env = db.DBEnv() self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL) self.primary_db = db.DB(self.env) self.primary_db.open(self.db_name, 'primary', db.DB_BTREE, db.DB_CREATE) self.secondary_db = db.DB(self.env) self.secondary_db.set_flags(db.DB_DUP) self.secondary_db.open(self.db_name, 'secondary', db.DB_BTREE, db.DB_CREATE) self.primary_db.associate(self.secondary_db, lambda key, data: data) self.primary_db.put('salad', 'eggs') self.primary_db.put('spam', 'ham') self.primary_db.put('omelet', 'eggs')
def test02_WithSource(self): """ A Recno file that is given a "backing source file" is essentially a simple ASCII file. Normally each record is delimited by and so is just a line in the file, but you can set a different record delimiter if needed. """ homeDir = get_new_environment_path() self.homeDir = homeDir source = os.path.join(homeDir, 'test_recno.txt') if not os.path.isdir(homeDir): os.mkdir(homeDir) f = open(source, 'w') f.close() d = db.DB() d.set_re_delim(10) d.set_re_delim('\n') d.set_re_source(source) d.open(self.filename, db.DB_RECNO, db.DB_CREATE) data = 'The quick brown fox jumped over the lazy dog'.split() for datum in data: d.append(datum) d.sync() d.close() f = open(source, 'r') text = f.read() f.close() text = text.strip() if verbose: print text print data print text.split('\n') self.assertEqual(text.split('\n'), data) d = db.DB() d.set_re_source(source) d.open(self.filename, db.DB_RECNO) d[3] = 'reddish-brown' d[8] = 'comatose' d.sync() d.close() f = open(source, 'r') text = f.read() f.close() text = text.strip() if verbose: print text print text.split('\n') self.assertEqual(text.split('\n'), 'The quick reddish-brown fox jumped over the comatose dog'.split())
def setUp(self): if self.useEnv: self.homeDir=get_new_environment_path() try: self.env = db.DBEnv() self.env.set_lg_max(1024*1024) self.env.set_tx_max(30) self._t = int(time.time()) self.env.set_tx_timestamp(self._t) self.env.set_flags(self.envsetflags, 1) self.env.open(self.homeDir, self.envflags | db.DB_CREATE) self.filename = "test" # Yes, a bare except is intended, since we're re-raising the exc. except: test_support.rmtree(self.homeDir) raise else: self.env = None self.filename = get_new_database_path() # create and open the DB self.d = db.DB(self.env) if not self.useEnv : if db.version() >= (4, 2) : self.d.set_cachesize(*self.cachesize) cachesize = self.d.get_cachesize() self.assertEqual(cachesize[0], self.cachesize[0]) self.assertEqual(cachesize[2], self.cachesize[2]) # Berkeley DB expands the cache 25% accounting overhead, # if the cache is small. self.assertEqual(125, int(100.0*cachesize[1]/self.cachesize[1])) self.d.set_flags(self.dbsetflags) if self.dbname: self.d.open(self.filename, self.dbname, self.dbtype, self.dbopenflags|db.DB_CREATE, self.dbmode) else: self.d.open(self.filename, # try out keyword args mode = self.dbmode, dbtype = self.dbtype, flags = self.dbopenflags|db.DB_CREATE) if not self.useEnv: self.assertRaises(db.DBInvalidArgError, self.d.set_cachesize, *self.cachesize) self.populateDB()
def setUp(self): self.db_path_1 = get_new_database_path() self.db_path_2 = get_new_database_path() self.db_env_path = get_new_environment_path()
def setUp(self): self.homeDir = get_new_environment_path() self.filename = "test"
def setUp(self): self.homeDir = get_new_environment_path()
def setUp(self): self.filename = get_new_database_path() self.homeDir = get_new_environment_path()
def setUp(self): self.homeDir = get_new_environment_path() self.env = db.DBEnv()
def test02_WithSource(self): """ A Recno file that is given a "backing source file" is essentially a simple ASCII file. Normally each record is delimited by \n and so is just a line in the file, but you can set a different record delimiter if needed. """ homeDir = get_new_environment_path() self.homeDir = homeDir source = os.path.join(homeDir, 'test_recno.txt') if not os.path.isdir(homeDir): os.mkdir(homeDir) f = open(source, 'w') # create the file f.close() d = db.DB() # This is the default value, just checking if both int d.set_re_delim(0x0A) d.set_re_delim('\n') # and char can be used... d.set_re_source(source) d.open(self.filename, db.DB_RECNO, db.DB_CREATE) data = "The quick brown fox jumped over the lazy dog".split() for datum in data: d.append(datum) d.sync() d.close() # get the text from the backing source f = open(source, 'r') text = f.read() f.close() text = text.strip() if verbose: print text print data print text.split('\n') self.assertEqual(text.split('\n'), data) # open as a DB again d = db.DB() d.set_re_source(source) d.open(self.filename, db.DB_RECNO) d[3] = 'reddish-brown' d[8] = 'comatose' d.sync() d.close() f = open(source, 'r') text = f.read() f.close() text = text.strip() if verbose: print text print text.split('\n') self.assertEqual( text.split('\n'), "The quick reddish-brown fox jumped over the comatose dog".split())
def setUp(self): self.homeDir = get_new_environment_path() self.env = db.DBEnv() self.env.open(self.homeDir, db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_CREATE)
def setUp(self) : self.homeDir = get_new_environment_path() DBShelveTestCase.setUp(self)
def setUp(self): self.homeDir = get_new_environment_path() DBShelveTestCase.setUp(self)
def setUp(self): self.filename = self.__class__.__name__ + ".db" self.homeDir = get_new_environment_path() self.env = db.DBEnv() self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
def setUp(self): self.homeDir = get_new_environment_path() self.env = db.DBEnv() self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOG | db.DB_INIT_TXN) self.db = db.DB(self.env)
def setUp(self): self.filename = self.__class__.__name__ + '.db' self.homeDir = get_new_environment_path() self.env = db.DBEnv() self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
def setUp(self): self.filename = self.__class__.__name__ + '.db' self.homeDir = get_new_environment_path()
def setUp(self): self.homeDir = get_new_environment_path() self.filename = "test" return self._create_env(must_open_db=True)
def setUp(self) : self.homeDir = get_new_environment_path() self.filename = "test" return self._create_env(must_open_db=True)