m &Ec@sNdkZdkZeiiddy dkZWn)ej odeids cCs||i|(R RH((RR<scCs|ii|dS(N(R R0tuncatalogObjecttuid(R RJ((Rt uncatMessages(RRRRR3R<RK(((RRUs   RGcBs&tZddZdZdZRS(NicCs |iidd|_|iidd|_|iidd|_t||_t i |id|_ |djot |i|i |_ n|iidd|_tt||_|iidd}y#titi|d |_WnnXdS( NtfromRR#R t is message-idR(i (R;R>RAR R"R#R tstrR$R?R@R)t modify_doctmaptreverseR%tlenR&R(ttimetmktimetrfc822t parsedate(R R;ROR(((RRs #cCs&t|}|iti|dS(NR(tlistRCtlRQR?tjoin(R RCRX((RRQs  cCsdS(N((R ((RRs(RRRRQR(((RRGs  tBuildEnvcBs)tZdZdZdZdZRS(s build environment cOs}tii||||tii||d|_ |i t dd|i dt tf|i dttfdS(Nisdispatcher.logtastreads=%d searchiterations=%ds updateiterations=%d maxfiles=%d(tunittesttTestCaseRR tfunctargstkwt dispatchert Dispatchert init_phasetsetlogR tlognt numThreadstsearchIterationstupdateIterationstmaxFiles(R R^R_R`((RRs  cCs)d|_|iddd||fdS(NitfuncTestEnvironment(R RcRaR_R`(R R_R`((RtbuildTestEnvironments cCs|i}tii|pti|ntid|t d|}dt GHt t |}dGH|id|dGHti}|it d|iGdGHd GH|i|dS( Ns rm -f %s/*s%s/Data_orig.fss2parsing and reading mailbox file %s....please waitswriting Catalog to ZODBtcatalogsCreating keywords fileis files readsInitalization complete(R tth_setuptenvtostpathtexiststdataDirtmakedirstsystemRtzodbtmboxRRittcRR)tKeywordsR`tbuildR,t th_teardown(R RrRiRuR`RnRw((RRjs    (RRRRRkRj(((RRZs   t testSearchescBstZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdddZdZdZRS(s test searches cOsOtii||||tii||d|_ |i t dddS(Nisdispatcher.logR[( R\R]RR R^R_R`RaRbRcRdR (R R^R_R`((RRs cCstidtiidptidntidtdjp tdtddd|_ h|_ |i |_ t i}|i|i |_ |idd |id ttf|id ttfdS( Nsrm -fr data/works data/works$cp %s/Data_orig.fs data/work/Data.fsis%Error while replicating original datasdata/work/Data.fsR t-iPstreads=%d searchiterations=%ds updateiterations=%d maxfiles=%d(RoRtRpRqRsRrtAssertionErrorRR Rutthreadst zodb_sizetinit_zodb_sizeR)RxR`treloadReRfRgRhRi(R R`((RtsetUps $   cCsC|id|i|id|i|`d|_|_dS(Ntbeforesafter (R t log_zodb_sizeRRRuRDRl(R ((RttearDownscCs|id||fdS(Ns-Size of ZODB (data/work/Data.fs) %s test : %s(R ReRCtn(R RCR((RRscCs|itiddS(Nsdata/work/Data.fsi(R t size2sizeRotstat(R ((RRscCsxdk}|djo d|Sn|ddjodd|dSn|dddjodd|ddSndS(Nf1024.0s %8.3lf Bytess %8.3lf KBf1.0s %8.3lf MB(tmathR(R RR((RRs  cCs$|idd|dfhfdS(s benchmark FulltextIndex tfuncFulltextIndexRfN(R RaR`(R R_R`((RttestFulltextIndex(s cGs[|i\}}|i}x)|iD]}|ihd|<}q(W|i |dS(s benchmark FulltextIndex R$N( R t get_catalogtcatR+RmRnR)R`t searchResultstresRz(R R_RRR+R`Rn((RR.s  cCs$|idd|dfhfdS(s benchmark field indextfuncFieldIndexRfN(R RaR`(R R_R`((RttestFieldIndex?s cGs|i\}}|i}xmtdtD]\}|i hd|<}x;|D]3}||i jpt d|i||i fqSWq.W|i|dS(s benchmark FieldIndex iR&s %s should have size %d but is %sN(R RRR+RmRntrangeRgR9RRR5R&R}R%Rz(R R_R9RRR+RnR5((RREs 5cCs$|idd|dfhfdS(s benchmark Keyword indextfuncKeywordIndexRfN(R RaR`(R R_R`((RttestKeywordIndexYs cGs[|i\}}|i}x)|iD]}|ihd|<}q(W|i |dS(s benchmark KeywordIndex R#N( R RRR+RmRnR)R`RRRz(R R_RRR+R`Rn((RR_s  cCs$|idd|dfhfdS(s benchmark field range indextfuncFieldRangeIndexRfN(R RaR`(R R_R`((RttestFieldRangeIndexps c Gs"|i\}}|i}g}xCttD]5}t i dd}|d} |i|| fq1WxttD]}x|ihd||<dd<D]f}|i} ||d| jo| ||djp-td|i||d||d| fqWqwW|i|d S( s benchmark FieldRangeIndex ii'iR&t length_usages range:min:maxis)Filesize of %s is out of range (%d,%d) %dN(R RRR+RmRntrgRRgR9trandomtrandintRHRR=RR5R&tsizeR}R%Rz( R R_R5R9RHRR+RRnRR((RRvs     & _cCs$|idd|dfhfdS(s benchmark Keyword range indextfuncKeywordRangeIndexRfN(R RaR`(R R_R`((RttestKeywordRangeIndexs c Gs|i\}}g}xLtt|iD]5}t i dd}|d} |i || fq.W|i}g}xYtt|iD]B}|i |ihd|i|<d||<dd<qW|i|dS( s' benchmark Keyword & IndexRange search ii'iR)R&Rs range:min:maxN(R RRR+RRRRR)R9RRRHRR=RmRntresultsRRz( R R_R9RHRRR+RRnR((RRs  @cCs$|idd|d||fdS(s3 benchmark concurrent catalog/uncatalog operations t testUpdatest funcUpdatesRfN(R RaR`R_(R R_R`((RRs cOsd} }|i\}} |i|d}|i }t i }|i } x#tt|D]} |idt|d} || }||}yE|i||idddjotitidnWn#tiij o| d} nXyH|i|||idddjotitidnWqftiij o|d}qfXqfWytiWnnX|i | d|d| dS( s3 benchmark concurrent catalog/uncatalog operations it numUpdatesiRf0.10000000000000001t cat_conflictstuncat_conflictsN(!RRR RRR+tsetupUpdatesMethodR`tmsgstkeysRtRandomtrdgenRmRnRRRR9RR5tmidRtuncatalog_objectRARRRStsleepRt POSExceptiont ConflictErrortcatalog_objectRz(R R_R`RRRRRRR9R+RnRR5R((RRs>         cCsd}h}tittd}|i}xe|o]||joPt |}|ii dd}|o|||<|d}n|i}q3W|S(s this method prepares a datastructure for the updates test. we are reading the first n mails from the primary mailbox. they are used for the update test iR5s message-idiN(R9R>R6R7R RvR8R:R;RRGRRARDR(R RRR8RR9R>R;((RRs   cCs*|idd|dtdfhfdS(s" test reindexing of existing data ttestReindexingtfuncReindexingRfiN(R RaR`Rv(R R_R`((RRs cCs-|idd|dtddfhfdS(s8 test reindexing of existing data but with modificationsRRRfiiN(R RaR`Rv(R R_R`((RttestReindexingAndModify s idic Cs%d} |i\}} |i} tit |d}d}|i } x| o||jot| |}| iido| id}n|i } qQy|i||tiWn| d} nX|i } |d}|ddjo |GHqQqQW|i| d| dS(s" test reindexing of existing data iR5s message-idiidRN(RR RRR+RmRnR6R7R RvR8R9R:R;tnumfilesRGRORR>thas_keyRRFRRRz( R RvRRORR9R8RRR+RRnR;((RRs0     cCs*|idd|dtdfhfdS(s testing incremental indexing ttestIncrementalIndexingRRfiN(R RaR`tmbox2(R R_R`((RR:s cCsB|iii}|i}|di}|di}||fS(s return a catalog object RlN( R RuR R R RR0RR+(R R+RR R((RR@s    (RRRRRRRRRRRRRRRRRRRRRRRRRRR(((RR{s2                 0   ' cCs%dGHHd|GHd|GHd|GHdS(NsUsage: sEinitalize the test catalog: %s -i -f sEto run the basic tests: %s -b -f sEto run the advanced tests: %s -a -f (tprogram(R((RtusageOs   cCstitidddg\}}|itd|}|gjo.tt i i tidti dnxu|D]m\}}|ddgjo.tt i i tidti dn|djoti|aqqWt i id ttad |jotiitd nd |jotiitd nd|jotiitdnd|jotiitdnd|jotiitndS(Nishiabf:xpthelpcCs|dS(Ni(tx(R((Rt^sis-hs--helps-ftdatas-itinits-btbench1s-atbench2s-xtexps-p(tgetopttsystargvtoptsR_tsortRPtoptsLstRRoRptbasenametexittktvR?tatoiRiRYRNRrR\tTextTestRunnertrunt get_testst test_suite(RR_RRR((RtmainWs.%  . .      cCs tdS(Ntbasic(R(((RR|sc Cs|djodadtantdtttdddtdddtd ddtd ddtd ddf}tdddtddd tdddtddd td ddtd dd td ddtd dd td ddtd dd f }td ddddf}tdddf}tdttf}t i }x%t d|D]}|i|qW|SdS(NRidsdata/%dRkRRfiRRRRiRiRiRs%s_tests(twhatRiRrRZR{tt_ajt bench1_testst bench2_testst exp_testst init_testsR\t TestSuitettstevalRtaddTest(RRRRRRRR((RRs `  cCsdk}tdS(N(tpdbR(R((Rtpdebugs cCstidS(N(Rtdebug(((RRscCsdk}|iddS(Nsdebug()(RR(R((RRs t__main__(6RoRRptinserttTestingt ImportErrortenvirontgetcwdtheretZope2RtZODB.FileStorageRtProducts.ZCatalogR/RtProducts.ZCatalog.Catalogt CatalogErrort PersistencetExtensionClassRaR)RRRSR?R6RUtunittest_patchedR\RiRfRgRhRARvRRrRt PersistentR]RtBaseRGRbRZR{RRRRRRR(%RRR\RR)RhRRRR{RRRfRgRRRR?RURR6RRRRGRRaR/RRvRRZRRSRRRo((Rt?sR           6 B 4e  %  7