mò Sã¸Ec@s²dkZdkZdkZdkZdklZdklZlZl Z l Z l Z l Z l Z lZlZlZlZlZlZlZlZlZdklZlZdeifd„ƒYZdeeie i eie i e i e i e ie ieieieieieieieieifd„ƒYZ deieifd „ƒYZ!d efd „ƒYZ"d „Z#d „Z$d„Z%d„Z&e'djoei(ƒndS(N(s POSException(sStorageTestBases BasicStoragesTransactionalUndoStoragesVersionStoragesTransactionalUndoVersionStoragesPackableStoragesSynchronizationsConflictResolutionsHistoryStoragesIteratorStorages CorruptionsRevisionStoragesPersistentStorages MTStoragesReadOnlyStoragesRecoveryStorage(sMinPOs zodb_pickletBaseFileStorageTestscBs#tZd„Zd„Zd„ZRS(NcKstiid||_dS(NsFileStorageTests.fs(tZODBt FileStoragetkwargstselft_storage(RR((t9/data/zmath/zope/lib/python/ZODB/tests/testFileStorage.pytopenscCs|iddƒdS(Ntcreatei(RR(R((RtsetUp!scCs|iiƒ|iiƒdS(N(RRtclosetcleanup(R((RttearDown$s (t__name__t __module__RR R (((RRs  tFileStorageTestscBs€tZd„Zd„Zd„Zed„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „ZRS(NcCs‚dd}y|id|ƒWntij onX|idƒy|id|ƒWntij onX|idƒdS(NtXiø$tusers%expect long user field to raise errort description(tsRt_dostoret POSExceptiont StorageErrortfail(RR((RtcheckLongMetadata<s  cCs*dkl}|i|iii|ƒdS(N(sfsIndex(t ZODB.fsIndextfsIndexRt assertEqualRt_indext __class__(RR((Rtcheck_use_fsIndexKs cCs—dk}tddƒ}|i|ƒ}|iƒ}|d}t |ƒ}||d<|i dƒ|i ƒ|i |dƒ}|i|ƒ|iƒ|S(NsFileStorageTests.fs.indexsr+btindexii(tcPickletpickleRtft UnpicklertptloadtdataRtdicttnewindextseekttruncatetPicklertdumpR (RRR"R!R&R$R(((Rtconvert_index_to_dictRs         c Cs3dkl}xtdƒD]}|iƒqWt|iiƒ}|ii ƒ|i ƒ}|i t||ƒƒ|i ƒ}|i t|tƒƒ|id|ƒ|i t|ii|ƒƒt|iiƒ}|i||ƒ|ii ƒ|i ƒ}|o|i t|tƒƒn|i t||ƒƒdS(N(sfsIndexi t read_only(RRtrangetiRRR'RRtoldindex_as_dictR R-t old_indextassert_t isinstancet new_indexRR.tnewindex_as_dictRt current_index( RR.R7R0R6R2RR5R1((Rtcheck_conversion_to_fsIndexfs&       cCs|idtƒdS(NR.(RR8tTrue(R((Rt$check_conversion_to_fsIndex_readonly‡sc Cs=dkl}dkl}xtdƒD]}|iƒq'Wt|i i i ƒ}||i i _ t iƒ|i iƒ|iƒ|it|i i |ƒƒ|it|i i i |ƒƒt|i i i ƒ}|it|ƒt|ƒƒxJ|D]B}||}||}|it|iƒƒt|iƒƒƒqóWdS(N(sfsIndex(sOOBTreei (RRtBTrees.OOBTreetOOBTreeR/R0RRR'RRt_datat data_dictt transactiontcommitR RR3R4t new_data_dictRtlentktold_treetnew_treetlisttitems( RR<R0RARERRDR>RC((Rt3check_conversion_from_dict_to_btree_data_in_fsIndexŒs&        cCs_xtdƒD]}|iƒq W|iiƒtidƒ|iƒ|i |ii dƒdS(Ni sFileStorageTests.fs.indexi( R/R0RRRR tostremoveRRt_saved(RR0((Rt#check_save_after_load_with_no_index¯s    c Cs dk}dkl} dkl}||iƒ}|i ƒ} d| i ƒd= %r(tlasttidtfstiteratorttxnR‚t ValueError(R˜RšR—((RtcheckIncreasingTidsŠs   cCsLdk}dkl}|iƒd|}||i|ƒd |dfŒS(N(s TimeStampi<i(Rmtpersistent.TimeStampt TimeStamptminutesRatgmtime(RŸRžRaRm((Rt timestamp’s  cCsdS(sª >>> from ZODB.FileStorage import FileStorage >>> from ZODB.DB import DB >>> import transaction >>> from zope.testing.loggingsupport import InstalledHandler Arrange to capture log messages -- they're an important part of this test! >>> handler = InstalledHandler('ZODB.FileStorage') Create a new file storage. >>> st = FileStorage('temp.fs', create=True) >>> db = DB(st) >>> db.close() First check the normal case: transactions are recorded with increasing tids, and time doesn't run backwards. >>> st = FileStorage('temp.fs') >>> db = DB(st) >>> conn = db.open() >>> conn.root()['xyz'] = 1 >>> transaction.get().commit() >>> checkIncreasingTids(st) >>> db.close() >>> st.cleanup() # remove .fs, .index, etc files >>> handler.records # i.e., no log messages [] Now force the database to have transaction records with tids from the future. >>> st = FileStorage('temp.fs', create=True) >>> st._ts = timestamp(15) # 15 minutes in the future >>> db = DB(st) >>> db.close() >>> st = FileStorage('temp.fs') # this should log a warning >>> db = DB(st) >>> conn = db.open() >>> conn.root()['xyz'] = 1 >>> transaction.get().commit() >>> checkIncreasingTids(st) >>> db.close() >>> st.cleanup() >>> [record.levelname for record in handler.records] ['WARNING'] >>> handler.clear() And one more time, with transaction records far in the future. We expect to log a critical error then, as a time so far in the future probably indicates a real problem with the system. Shorter spans may be due to clock drift. >>> st = FileStorage('temp.fs', create=True) >>> st._ts = timestamp(60) # an hour in the future >>> db = DB(st) >>> db.close() >>> st = FileStorage('temp.fs') # this should log a critical error >>> db = DB(st) >>> conn = db.open() >>> conn.root()['xyz'] = 1 >>> transaction.get().commit() >>> checkIncreasingTids(st) >>> db.close() >>> st.cleanup() >>> [record.levelname for record in handler.records] ['CRITICAL'] >>> handler.clear() >>> handler.uninstall() N((((RttestTimeTravelOnOpen™sLcCsidkl}tiƒ}x6ttitt gD]}|i ti |dƒƒq/W|i |i ƒƒ|S(N(sdoctesttcheck(t zope.testingtdoctesttunittestt TestSuitetsuiteRt CorruptiontFileStorageCorruptTestsR‰RŒtklasstaddTestt makeSuitet DocTestSuite(R¥R¨R«((Rt test_suiteçs  t__main__()RIR¦R?tZODB.FileStorageRRt ZODB.teststStorageTestBaset BasicStoragetTransactionalUndoStoragetVersionStoragetTransactionalUndoVersionStoragetPackableStoragetSynchronizationtConflictResolutiontHistoryStoragetIteratorStorageR©tRevisionStoragetPersistentStoraget MTStoragetReadOnlyStoragetRecoveryStoragetZODB.tests.StorageTestBaseR~R“RtPackableUndoStoragetSynchronizedStoragetConflictResolvingStoraget!ConflictResolvingTransUndoStoragetExtendedIteratorStorageRR‰RŒRœR¡R¢R¯R tmain(R¦R´R¸R¯R‰RºR¿R½RµR“R»R©R¹R¡RR¶R¼R¾RRRœRR~R?RÀR¢RÁR·R³RIRŒ((Rt?s    g vÿ<   N