12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232 |
- # coding: utf-8
- # Copyright (C) 1994-2018 Altair Engineering, Inc.
- # For more information, contact Altair at www.altair.com.
- #
- # This file is part of the PBS Professional ("PBS Pro") software.
- #
- # Open Source License Information:
- #
- # PBS Pro is free software. You can redistribute it and/or modify it under the
- # terms of the GNU Affero General Public License as published by the Free
- # Software Foundation, either version 3 of the License, or (at your option) any
- # later version.
- #
- # PBS Pro is distributed in the hope that it will be useful, but WITHOUT ANY
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- # FOR A PARTICULAR PURPOSE.
- # See the GNU Affero General Public License for more details.
- #
- # You should have received a copy of the GNU Affero General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- # Commercial License Information:
- #
- # For a copy of the commercial license terms and conditions,
- # go to: (http://www.pbspro.com/UserArea/agreement.html)
- # or contact the Altair Legal Department.
- #
- # Altair’s dual-license business model allows companies, individuals, and
- # organizations to create proprietary derivative works of PBS Pro and
- # distribute them - whether embedded or bundled with other software -
- # under a commercial license agreement.
- #
- # Use of Altair’s trademarks, including but not limited to "PBS™",
- # "PBS Professional®", and "PBS Pro™" and Altair’s logos is subject to Altair's
- # trademark licensing policies.
- from tests.functional import *
- def convert_time(fmt, tm, fixdate=False):
- """
- Convert given time stamp <tm> into given format <fmt>
- if fixdate is True add <space> before date if date is < 9
- (This is because to match output with ctime as qstat uses it)
- """
- rv = time.strftime(fmt, time.localtime(float(tm)))
- if ((sys.platform not in ('cygwin', 'win32')) and (fixdate)):
- rv = rv.split()
- date = int(rv[2])
- if date <= 9:
- date = ' ' + str(date)
- rv[2] = str(date)
- rv = ' '.join(rv)
- return rv
- class TestPbsNodeRampDown(TestFunctional):
- """
- This tests the Node Rampdown Feature,
- where while a job is running, nodes/resources
- assigned by non-mother superior can be released.
- Custom parameters:
- moms: colon-separated hostnames of three MoMs
- """
- def transform_select(self, select):
- """
- Takes a select substring:
- "<res1>=<val1>:<res2>=<val2>...:<resN>=<valN>"
- and transform it so that if any of the resource
- (res1, res2,...,resN) matches 'mem', and
- the corresponding value has a suffix of 'gb',
- then convert it too 'kb' value. Also,
- this will attach a "1:' to the returned select
- substring.
- Ex:
- % str = "ncpus=7:mem=2gb:ompthreads=3"
- % transform_select(str)
- 1:ompthreads=3:mem=2097152kb:ncpus=7
- """
- sel_list = select.split(':')
- mystr = "1:"
- for index in range(len(sel_list) - 1, -1, -1):
- if (index != len(sel_list) - 1):
- mystr += ":"
- nums = [s for s in sel_list[index] if s.isdigit()]
- key = sel_list[index].split('=')[0]
- if key == "mem":
- mystr += sel_list[index].\
- replace(nums[0] + "gb",
- str(int(nums[0]) * 1024 * 1024)) + "kb"
- else:
- mystr += sel_list[index]
- return mystr
- def pbs_nodefile_match_exec_host(self, jid, exec_host,
- schedselect=None):
- """
- Look into the PBS_NODEFILE on the first host listed in 'exec_host'
- and returns True if all host entries in 'exec_host' match the entries
- in the file. Otherwise, return False.
- # Look for 'mpiprocs' values in 'schedselect' (if not None), and
- # verify that the corresponding node hosts are appearing in
- # PBS_NODEFILE 'mpiprocs' number of times.
- """
- pbs_nodefile = os.path.join(self.server.
- pbs_conf['PBS_HOME'], 'aux', jid)
- # look for mpiprocs settings
- mpiprocs = []
- if schedselect is not None:
- select_list = schedselect.split('+')
- for chunk in select_list:
- chl = chunk.split(':')
- for ch in chl:
- if ch.find('=') != -1:
- c = ch.split('=')
- if c[0] == "mpiprocs":
- mpiprocs.append(c[1])
- ehost = exec_host.split('+')
- first_host = ehost[0].split('/')[0]
- cmd = ['cat', pbs_nodefile]
- ret = self.server.du.run_cmd(first_host, cmd, sudo=False)
- ehost2 = []
- for h in ret['out']:
- ehost2.append(h.split('.')[0])
- ehost1 = []
- j = 0
- for eh in ehost:
- h = eh.split('/')
- if (len(mpiprocs) > 0):
- for k in range(int(mpiprocs[j])):
- ehost1.append(h[0])
- else:
- ehost1.append(h[0])
- j += 1
- if cmp(ehost1, ehost2) != 0:
- return False
- return True
- def license_count_match(self, num_licenses):
- """
- This will fail on an assert if server's license_count used value
- does not equal 'num_licenses'
- """
- n = retry = 5
- for _ in range(n):
- server_stat = self.server.status(SERVER, 'license_count')
- lic_count = server_stat[0]['license_count']
- for lic in lic_count.split():
- lic_split = lic.split(':')
- if lic_split[0] == 'Used':
- actual_licenses = int(lic_split[1])
- if actual_licenses == num_licenses:
- return
- break
- retry -= 1
- if retry == 0:
- raise AssertionError("not found %d licenses" % (num_licenses,))
- self.logger.info("sleeping 3 secs before next retry")
- time.sleep(3)
- def match_accounting_log(self, atype, jid, exec_host, exec_vnode,
- mem, ncpus, nodect, place, select):
- """
- This checks if there's an accounting log record 'atype' for
- job 'jid' containing the values given (i.e.
- Resource_List.exec_host, Resource_List.exec_vnode, etc...)
- This throws an exception upon encountering a non-matching
- accounting_logs entry.
- Some example values of 'atype' are: 'u' (update record due to
- release node request), 'c' (record containing the next
- set of resources to be used by a phased job as a result of
- release node request), 'e' (last update record for a phased job
- due to a release node request), 'E' (end of job record).
- """
- self.server.accounting_match(
- msg=".*%s;%s.*exec_host=%s.*" % (atype, jid, exec_host),
- regexp=True, n=20)
- self.server.accounting_match(
- msg=".*%s;%s.*exec_vnode=%s.*" % (atype, jid, exec_vnode),
- regexp=True, n=20)
- self.server.accounting_match(
- msg=".*%s;%s.*Resource_List\.mem=%s.*" % (atype, jid, mem),
- regexp=True, n=20)
- self.server.accounting_match(
- msg=".*%s;%s.*Resource_List\.ncpus=%d.*" % (atype, jid, ncpus),
- regexp=True, n=20)
- self.server.accounting_match(
- msg=".*%s;%s.*Resource_List\.nodect=%d.*" % (atype, jid, nodect),
- regexp=True, n=20)
- self.server.accounting_match(
- msg=".*%s;%s.*Resource_List\.place=%s.*" % (atype, jid, place),
- regexp=True, n=20)
- self.server.accounting_match(
- msg=".*%s;%s.*Resource_List\.select=%s.*" % (atype, jid, select),
- regexp=True, n=20)
- if atype != 'c':
- self.server.accounting_match(
- msg=".*%s;%s.*resources_used\..*" % (atype, jid),
- regexp=True, n=20)
- def match_vnode_status(self, vnode_list, state, jobs=None, ncpus=None,
- mem=None):
- """
- Given a list of vnode names in 'vnode_list', check to make
- sure each vnode's state, jobs string, resources_assigned.mem,
- and resources_assigned.ncpus match the passed arguments.
- This will throw an exception if a match is not found.
- """
- for vn in vnode_list:
- dict_match = {'state': state}
- if jobs is not None:
- dict_match['jobs'] = jobs
- if ncpus is not None:
- dict_match['resources_assigned.ncpus'] = ncpus
- if mem is not None:
- dict_match['resources_assigned.mem'] = mem
- self.server.expect(VNODE, dict_match, id=vn)
- def create_and_submit_job(self, job_type, attribs={}):
- """
- create the job object and submit it to the server
- based on 'job_type' and attributes list 'attribs'.
- """
- retjob = Job(TEST_USER, attrs=attribs)
- if job_type == 'job1':
- retjob.create_script(self.script['job1'])
- elif job_type == 'job1_1':
- retjob.create_script(self.script['job1_1'])
- elif job_type == 'job1_2':
- retjob.create_script(self.script['job1_2'])
- elif job_type == 'job1_3':
- retjob.create_script(self.script['job1_3'])
- elif job_type == 'job1_5':
- retjob.create_script(self.script['job1_5'])
- elif job_type == 'job1_6':
- retjob.create_script(self.script['job1_6'])
- elif job_type == 'job1_extra_res':
- retjob.create_script(self.script['job1_extra_res'])
- elif job_type == 'job2':
- retjob.create_script(self.script['job2'])
- elif job_type == 'job3':
- retjob.create_script(self.script['job3'])
- elif job_type == 'job5':
- retjob.create_script(self.script['job5'])
- elif job_type == 'job11':
- retjob.create_script(self.script['job11'])
- elif job_type == 'job11x':
- retjob.create_script(self.script['job11x'])
- elif job_type == 'job12':
- retjob.create_script(self.script['job12'])
- elif job_type == 'job13':
- retjob.create_script(self.script['job13'])
- elif job_type == 'jobA':
- retjob.create_script(self.script['jobA'])
- return self.server.submit(retjob)
- def setUp(self):
- if len(self.moms) != 3:
- self.skip_test(reason="need 3 mom hosts: -p moms=<m1>:<m2>:<m3>")
- TestFunctional.setUp(self)
- Job.dflt_attributes[ATTR_k] = 'oe'
- self.server.cleanup_jobs(extend="force")
- self.momA = self.moms.values()[0]
- self.momB = self.moms.values()[1]
- self.momC = self.moms.values()[2]
- # Now start setting up and creating the vnodes
- self.server.manager(MGR_CMD_DELETE, NODE, None, "")
- # set node momA
- self.hostA = self.momA.shortname
- self.momA.delete_vnode_defs()
- vnode_prefix = self.hostA
- a = {'resources_available.mem': '1gb',
- 'resources_available.ncpus': '1'}
- vnodedef = self.momA.create_vnode_def(vnode_prefix, a, 4)
- self.assertNotEqual(vnodedef, None)
- self.momA.insert_vnode_def(vnodedef, 'vnode.def')
- self.server.manager(MGR_CMD_CREATE, NODE, id=self.hostA)
- # set node momB
- self.hostB = self.momB.shortname
- self.momB.delete_vnode_defs()
- vnode_prefix = self.hostB
- a = {'resources_available.mem': '1gb',
- 'resources_available.ncpus': '1'}
- vnodedef = self.momB.create_vnode_def(vnode_prefix, a, 5,
- usenatvnode=True)
- self.assertNotEqual(vnodedef, None)
- self.momB.insert_vnode_def(vnodedef, 'vnode.def')
- self.server.manager(MGR_CMD_CREATE, NODE, id=self.hostB)
- # set node momC
- # This one has no vnode definition.
- self.hostC = self.momC.shortname
- self.momC.delete_vnode_defs()
- self.server.manager(MGR_CMD_CREATE, NODE, id=self.hostC)
- a = {'resources_available.ncpus': 2,
- 'resources_available.mem': '2gb'}
- # set natural vnode of hostC
- self.server.manager(MGR_CMD_SET, NODE, a, id=self.hostC,
- expect=True)
- a = {'state': 'free', 'resources_available.ncpus': (GE, 1)}
- self.server.expect(VNODE, {'state=free': 11}, op=EQ, count=True,
- max_attempts=10, interval=2)
- # Various node names
- self.n0 = self.hostA
- self.n1 = '%s[0]' % (self.hostA,)
- self.n2 = '%s[1]' % (self.hostA,)
- self.n3 = '%s[2]' % (self.hostA,)
- self.n4 = self.hostB
- self.n5 = '%s[0]' % (self.hostB,)
- self.n6 = '%s[1]' % (self.hostB,)
- self.n7 = self.hostC
- self.n8 = '%s[3]' % (self.hostA,)
- self.n9 = '%s[2]' % (self.hostB,)
- self.n10 = '%s[3]' % (self.hostB,)
- if sys.platform in ('cygwin', 'win32'):
- SLEEP_CMD = "pbs-sleep"
- else:
- SLEEP_CMD = "/bin/sleep"
- self.pbs_release_nodes_cmd = os.path.join(
- self.server.pbs_conf['PBS_EXEC'], 'bin', 'pbs_release_nodes')
- FIB40 = os.path.join(self.server.pbs_conf['PBS_EXEC'], 'bin', '') + \
- 'pbs_python -c "exec(\\\"def fib(i):\\n if i < 2:\\n \
- return i\\n return fib(i-1) + fib(i-2)\\n\\nprint fib(40)\\\")"'
- FIB45 = os.path.join(self.server.pbs_conf['PBS_EXEC'], 'bin', '') + \
- 'pbs_python -c "exec(\\\"def fib(i):\\n if i < 2:\\n \
- return i\\n return fib(i-1) + fib(i-2)\\n\\nprint fib(45)\\\")"'
- FIB50 = os.path.join(self.server.pbs_conf['PBS_EXEC'], 'bin', '') + \
- 'pbs_python -c "exec(\\\"def fib(i):\\n if i < 2:\\n \
- return i\\n return fib(i-1) + fib(i-2)\\n\\nprint fib(50)\\\")"'
- FIB400 = os.path.join(self.server.pbs_conf['PBS_EXEC'], 'bin', '') + \
- 'pbs_python -c "exec(\\\"def fib(i):\\n if i < 2:\\n \
- return i\\n return fib(i-1) + fib(i-2)\\n\\nprint fib(400)\\\")"'
- # job submission arguments
- self.script = {}
- self.job1_select = "ncpus=3:mem=2gb+ncpus=3:mem=2gb+ncpus=2:mem=2gb"
- self.job1_place = "scatter"
- # expected values upon successful job submission
- self.job1_schedselect = "1:ncpus=3:mem=2gb+1:ncpus=3:mem=2gb+" + \
- "1:ncpus=2:mem=2gb"
- self.job1_exec_host = "%s/0*0+%s/0*0+%s/0*2" % (
- self.n0, self.n4, self.n7)
- self.job1_exec_vnode = \
- "(%s:mem=1048576kb:ncpus=1+" % (self.n1,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n2,) + \
- "%s:ncpus=1)+" % (self.n3) + \
- "(%s:mem=1048576kb:ncpus=1+" % (self.n4,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,) + \
- "%s:ncpus=1)+" % (self.n6,) + \
- "(%s:ncpus=2:mem=2097152kb)" % (self.n7,)
- self.job1_sel_esc = self.job1_select.replace("+", "\+")
- self.job1_exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- self.job1_exec_vnode_esc = self.job1_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace("(", "\(").replace(
- ")", "\)").replace("+", "\+")
- self.job1_newsel = self.transform_select(self.job1_select.split(
- '+')[0])
- self.job1_new_exec_host = self.job1_exec_host.split('+')[0]
- self.job1_new_exec_vnode = self.job1_exec_vnode.split(')')[0] + ')'
- self.job1_new_exec_vnode_esc = \
- self.job1_new_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace(
- "+", "\+")
- self.script['job1'] = \
- "#PBS -S /bin/bash\n" \
- "#PBS -l select=" + self.job1_select + "\n" + \
- "#PBS -l place=" + self.job1_place + "\n" + \
- "#PBS -W stageout=test.img@%s:test.img\n" % (self.n4,) + \
- "#PBS -W release_nodes_on_stageout=true\n" + \
- "dd if=/dev/zero of=test.img count=1024 bs=1048576\n" + \
- "pbsdsh -n 1 -- %s\n" % (FIB40,) + \
- "pbsdsh -n 2 -- %s\n" % (FIB40,) + \
- "%s\n" % (FIB50,)
- self.script['job1_1'] = \
- "#PBS -S /bin/bash\n" \
- "#PBS -l select=" + self.job1_select + "\n" + \
- "#PBS -l place=" + self.job1_place + "\n" + \
- "#PBS -W stageout=test.img@%s:test.img\n" % (self.n4,) + \
- "#PBS -W release_nodes_on_stageout=false\n" + \
- "dd if=/dev/zero of=test.img count=1024 bs=1048576\n" + \
- "pbsdsh -n 1 -- %s\n" % (FIB40,) + \
- "pbsdsh -n 2 -- %s\n" % (FIB40,) + \
- "%s\n" % (FIB50,)
- self.script['job1_2'] = \
- "#PBS -S /bin/bash\n" \
- "#PBS -l select=" + self.job1_select + "\n" + \
- "#PBS -l place=" + self.job1_place + "\n" + \
- "#PBS -W stageout=test.img@%s:test.img\n" % (self.n4,) + \
- "dd if=/dev/zero of=test.img count=1024 bs=1048576\n" + \
- "pbsdsh -n 1 -- %s\n" % (FIB40,) + \
- "pbsdsh -n 2 -- %s\n" % (FIB40,) + \
- "%s\n" % (FIB50,)
- self.script['job1_3'] = \
- "#PBS -S /bin/bash\n" \
- "#PBS -l select=" + self.job1_select + "\n" + \
- "#PBS -l place=" + self.job1_place + "\n" + \
- SLEEP_CMD + " 5\n" + \
- "pbs_release_nodes -a\n" + \
- "%s\n" % (FIB50,)
- self.script['job1_5'] = \
- "#PBS -S /bin/bash\n" \
- "#PBS -l select=" + self.job1_select + "\n" + \
- "#PBS -l place=" + self.job1_place + "\n" + \
- "pbsdsh -n 1 -- %s &\n" % (FIB45,) + \
- "pbsdsh -n 2 -- %s &\n" % (FIB45,) + \
- "%s\n" % (FIB45,)
- self.script['jobA'] = \
- "#PBS -S /bin/bash\n" \
- "#PBS -l select=" + self.job1_select + "\n" + \
- "#PBS -l place=" + self.job1_place + "\n" + \
- "#PBS -J 1-5\n"\
- "pbsdsh -n 1 -- %s &\n" % (FIB45,) + \
- "pbsdsh -n 2 -- %s &\n" % (FIB45,) + \
- "%s\n" % (FIB45,)
- self.script['job1_6'] = \
- "#PBS -S /bin/bash\n" \
- "#PBS -l select=" + self.job1_select + "\n" + \
- "#PBS -l place=" + self.job1_place + "\n" + \
- SLEEP_CMD + " 5\n" + \
- self.pbs_release_nodes_cmd + " " + self.n4 + "\n" + \
- "%s\n" % (FIB50,)
- self.job1_extra_res_select = \
- "ncpus=3:mem=2gb:mpiprocs=3:ompthreads=2+" + \
- "ncpus=3:mem=2gb:mpiprocs=3:ompthreads=3+" + \
- "ncpus=2:mem=2gb:mpiprocs=2:ompthreads=2"
- self.job1_extra_res_place = "scatter"
- self.job1_extra_res_schedselect = \
- "1:ncpus=3:mem=2gb:mpiprocs=3:ompthreads=2+" + \
- "1:ncpus=3:mem=2gb:mpiprocs=3:ompthreads=3+" + \
- "1:ncpus=2:mem=2gb:mpiprocs=2:ompthreads=2"
- self.job1_extra_res_exec_host = "%s/0*0+%s/0*0+%s/0*2" % (
- self.n0, self.n4, self.n7)
- self.job1_extra_res_exec_vnode = \
- "(%s:mem=1048576kb:ncpus=1+" % (self.n1,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n2,) + \
- "%s:ncpus=1)+" % (self.n3,) + \
- "(%s:mem=1048576kb:ncpus=1+" % (self.n4,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,) + \
- "%s:ncpus=1)+" % (self.n6,) + \
- "(%s:ncpus=2:mem=2097152kb)" % (self.n7,)
- self.script['job1_extra_res'] = \
- "#PBS -S /bin/bash\n" \
- "#PBS -l select=" + self.job1_extra_res_select + "\n" + \
- "#PBS -l place=" + self.job1_extra_res_place + "\n" + \
- "pbsdsh -n 1 -- %s &\n" % (FIB40,) + \
- "pbsdsh -n 2 -- %s &\n" % (FIB40,) + \
- "%s\n" % (FIB50,)
- self.job2_select = "ncpus=1:mem=1gb+ncpus=4:mem=4gb+ncpus=2:mem=2gb"
- self.job2_place = "scatter"
- self.job2_schedselect = "1:ncpus=1:mem=1gb+1:ncpus=4:mem=4gb+" + \
- "1:ncpus=2:mem=2gb"
- self.job2_exec_host = "%s/1+%s/1*0+%s/1*2" % (
- self.n0, self.n4, self.n7)
- self.job2_exec_vnode = \
- "(%s:ncpus=1:mem=1048576kb)+" % (self.n8,) + \
- "(%s:mem=1048576kb:ncpus=1+" % (self.n4,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n9,) + \
- "%s:mem=1048576kb:ncpus=1)+" % (self.n10,) + \
- "(%s:ncpus=2:mem=2097152kb)" % (self.n7,)
- self.job2_exec_vnode_var1 = \
- "(%s:ncpus=1:mem=1048576kb)+" % (self.n8,) + \
- "(%s:mem=1048576kb:ncpus=1+" % (self.n4,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n6,) + \
- "%s:mem=1048576kb:ncpus=1)+" % (self.n9,) + \
- "(%s:ncpus=2:mem=2097152kb)" % (self.n7,)
- self.script['job2'] = \
- "#PBS -l select=" + self.job2_select + "\n" + \
- "#PBS -l place=" + self.job2_place + "\n" + \
- SLEEP_CMD + " 60\n"
- self.script['job3'] = \
- "#PBS -l select=vnode=" + self.n4 + "+vnode=" + self.n0 + \
- ":mem=4mb\n" + SLEEP_CMD + " 30\n"
- self.script['job5'] = \
- "#PBS -l select=vnode=" + self.n0 + ":mem=4mb\n" + \
- SLEEP_CMD + " 300\n"
- self.job11x_select = "ncpus=3:mem=2gb+ncpus=3:mem=2gb+ncpus=1:mem=1gb"
- self.job11x_place = "scatter:excl"
- self.job11x_schedselect = "1:ncpus=3:mem=2gb+" + \
- "1:ncpus=3:mem=2gb+1:ncpus=1:mem=1gb"
- self.job11x_exec_host = "%s/0*0+%s/0*0+%s/0" % (
- self.n0, self.n4, self.n7)
- self.job11x_exec_vnode = \
- "(%s:mem=1048576kb:ncpus=1+" % (self.n1,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n2,) + \
- "%s:ncpus=1)+" % (self.n3,) + \
- "(%s:mem=1048576kb:ncpus=1+" % (self.n4,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,) + \
- "%s:ncpus=1)+" % (self.n6,) + \
- "(%s:ncpus=1:mem=1048576kb)" % (self.n7,)
- self.script['job11x'] = \
- "#PBS -S /bin/bash\n" \
- "#PBS -l select=" + self.job11x_select + "\n" + \
- "#PBS -l place=" + self.job11x_place + "\n" + \
- "pbsdsh -n 1 -- %s\n" % (FIB40,) + \
- "pbsdsh -n 2 -- %s\n" % (FIB40,) + \
- "%s\n" % (FIB50,)
- self.job11_select = "ncpus=3:mem=2gb+ncpus=3:mem=2gb+ncpus=1:mem=1gb"
- self.job11_place = "scatter"
- self.job11_schedselect = "1:ncpus=3:mem=2gb+1:ncpus=3:mem=2gb+" + \
- "1:ncpus=1:mem=1gb"
- self.job11_exec_host = "%s/0*0+%s/0*0+%s/0" % (
- self.n0, self.n4, self.n7)
- self.job11_exec_vnode = \
- "(%s:mem=1048576kb:ncpus=1+" % (self.n1,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n2,) + \
- "%s:ncpus=1)+" % (self.n3,) + \
- "(%s:mem=1048576kb:ncpus=1+" % (self.n4,) + \
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,) + \
- "%s:ncpus=1)+" % (self.n6,) + \
- "(%s:ncpus=1:mem=1048576kb)" % (self.n7,)
- self.script['job11'] = \
- "#PBS -S /bin/bash\n" \
- "#PBS -l select=" + self.job11_select + "\n" + \
- "#PBS -l place=" + self.job11_place + "\n" + \
- "pbsdsh -n 1 -- %s\n" % (FIB40,) + \
- "pbsdsh -n 2 -- %s\n" % (FIB40,) + \
- "%s\n" % (FIB50,)
- self.job12_select = "vnode=%s:ncpus=1:mem=1gb" % (self.n7,)
- self.job12_schedselect = "1:vnode=%s:ncpus=1:mem=1gb" % (self.n7,)
- self.job12_place = "free"
- self.job12_exec_host = "%s/1" % (self.n7,)
- self.job12_exec_vnode = "(%s:ncpus=1:mem=1048576kb)" % (self.n7,)
- self.script['job12'] = \
- "#PBS -l select=" + self.job12_select + "\n" + \
- "#PBS -l place=" + self.job12_place + "\n" + \
- SLEEP_CMD + " 60\n"
- self.job13_select = "3:ncpus=1"
- self.script['job13'] = \
- "#PBS -S /bin/bash\n" \
- "#PBS -l select=" + self.job13_select + "\n" + \
- "#PBS -l place=" + self.job1_place + "\n" + \
- "pbsdsh -n 1 -- %s\n" % (FIB400,) + \
- "pbsdsh -n 2 -- %s\n" % (FIB400,) + \
- "pbsdsh -n 3 -- %s\n" % (FIB400,)
- def tearDown(self):
- self.momA.signal("-CONT")
- self.momB.signal("-CONT")
- self.momC.signal("-CONT")
- TestFunctional.tearDown(self)
- # Delete managers and operators if added
- attrib = ['operators', 'managers']
- self.server.manager(MGR_CMD_UNSET, SERVER, attrib, expect=True)
- def test_release_nodes_on_stageout_true(self):
- """
- Test:
- qsub -W release_nodes_on_stageout=true job.script
- where job.script specifies a select spec of
- 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter".
- With release_nodes_on_stageout=true option, when
- job is deleted and runs a lengthy stageout process,
- only the primary execution host's
- vnodes are left assigned to the job.
- """
- # Inside job1's script contains the
- # directive to release_nodes_on_stageout=true
- jid = self.create_and_submit_job('job1')
- self.server.expect(JOB, {'job_state': 'R',
- 'release_nodes_on_stageout': 'True',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Deleting the job will trigger the stageout process
- # at which time sister nodes are automatically released
- # due to release_nodes_stageout=true set
- self.server.delete(jid)
- # Verify mom_logs
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.n4), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.n7), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- # Verify remaining job resources.
- self.server.expect(JOB, {'job_state': 'E',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 3,
- 'Resource_List.select': self.job1_newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 1,
- 'schedselect': self.job1_newsel,
- 'exec_host': self.job1_new_exec_host,
- 'exec_vnode': self.job1_new_exec_vnode},
- id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(3)
- # Check various vnode status
- self.match_vnode_status([self.n1, self.n2],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3], 'job-busy', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n4, self.n5, self.n6,
- self.n7, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_new_exec_host))
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_new_exec_host,
- self.job1_new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, self.job1_newsel)
- def test_release_nodes_on_stageout_false(self):
- """
- Test:
- qsub -W release_nodes_on_stageout=False job.script
- where job.script specifies a select spec of
- 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter".
- With release_nodes_on_stageout=false option, when job is
- deleted and runs a lengthy stageout process, nothing
- changes in job's vnodes assignment.
- """
- # Inside job1_1's script contains the
- # directive to release_nodes_on_stageout=false
- jid = self.create_and_submit_job('job1_1')
- self.server.expect(JOB, {'job_state': 'R',
- 'release_nodes_on_stageout': 'False',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Deleting a job should not trigger automatic
- # release of nodes due to release_nodes_stagout=False
- self.server.delete(jid)
- # Verify mom_logs
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=5, interval=1,
- existence=False)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=5, interval=1,
- existence=False)
- # Verify no change in remaining job resources.
- self.server.expect(JOB, {'job_state': 'E',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy',
- jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Check for no existence of account update ('u') record
- self.server.accounting_match(
- msg='.*u;' + jid + ".*exec_host=%s.*" % (self.job1_exec_host_esc,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- # Check for no existence of account next ('c') record
- self.server.accounting_match(
- msg='.*c;' + jid + ".*exec_host=%s.*" % (self.job1_new_exec_host,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- def test_release_nodes_on_stageout_default(self):
- """
- Test:
- qsub: no -Wrelease_nodes_on_stageout
- option given.
- Job runs as normal.
- """
- jid = self.create_and_submit_job('job1_2')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.delete(jid)
- # Verify mom_logs
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=5, interval=1,
- existence=False)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=5, interval=1,
- existence=False)
- # Verify no change in remaining job resources.
- self.server.expect(JOB, {'job_state': 'E',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy',
- jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10],
- 'free')
- # Check for no existence of account update ('u') record
- self.server.accounting_match(
- msg='.*u;' + jid + ".*exec_host=%s.*" % (self.job1_exec_host_esc,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- # Check for no existence of account next ('c') record
- self.server.accounting_match(
- msg='.*c;' + jid + ".*exec_host=%s.*" % (self.job1_new_exec_host,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- def test_release_nodes_on_stageout_true_qalter(self):
- """
- Test:
- qalter -W release_nodes_on_stageout=true.
- After running job is modified by qalter,
- with release_nodes_on_stageout=true option, when
- job is deleted and runs a lengthy stageout process,
- only the primary execution host's
- vnodes are left assigned to the job.
- """
- jid = self.create_and_submit_job('job1_2')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # run qalter -Wrelease_nodes_on_stageout=true
- self.server.alterjob(jid,
- {ATTR_W: 'release_nodes_on_stageout=true'})
- self.server.expect(JOB, {'release_nodes_on_stageout': 'True'}, id=jid)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # This triggers the lengthy stageout process
- self.server.delete(jid)
- # Verify mom_logs
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- self.server.expect(JOB, {'job_state': 'E',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 3,
- 'Resource_List.select': self.job1_newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 1,
- 'schedselect': self.job1_newsel,
- 'exec_host': self.job1_new_exec_host,
- 'exec_vnode': self.job1_new_exec_vnode},
- id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(3)
- # Check various vnode status
- self.match_vnode_status([self.n1, self.n2],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3], 'job-busy', jobs_assn1,
- 1, '0kb')
- self.match_vnode_status([self.n0, self.n4, self.n5, self.n6,
- self.n7, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_new_exec_host))
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_new_exec_host,
- self.job1_new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, self.job1_newsel)
- def test_release_nodes_on_stageout_false_qalter(self):
- """
- Test:
- qalter -W release_nodes_on_stageout=False.
- After running job is modified by qalter,
- With release_nodes_on_stageout=false option, when job is
- deleted and runs a lengthy stageout process, nothing
- changes in job's vnodes assignment.
- """
- jid = self.create_and_submit_job('job1_2')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # run qalter -Wrelease_nodes_on_stageout=true
- self.server.alterjob(jid,
- {ATTR_W: 'release_nodes_on_stageout=false'})
- self.server.expect(JOB, {'release_nodes_on_stageout': 'False'}, id=jid)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # This triggers long stageout process
- self.server.delete(jid)
- # Verify mom_logs
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=5, interval=1,
- existence=False)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=5, interval=1,
- existence=False)
- # Verify no change in remaining job resources.
- self.server.expect(JOB, {'job_state': 'E',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy',
- jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Check for no existence of account update ('u') record
- self.server.accounting_match(
- msg='.*u;' + jid + ".*exec_host=%s.*" % (self.job1_exec_host_esc,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- # Check for no existence of account next ('c') record
- self.server.accounting_match(
- msg='.*c;' + jid + ".*exec_host=%s.*" % (self.job1_new_exec_host,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- def test_hook_release_nodes_on_stageout_true(self):
- """
- Test:
- Using a queuejob hook to set
- release_nodes_on_stageout=true.
- When job is deleted and runs a
- lengthy stageout process, only
- the primary execution host's
- vnodes are left assigned to the job.
- """
- hook_body = """
- import pbs
- pbs.logmsg(pbs.LOG_DEBUG, "queuejob hook executed")
- pbs.event().job.release_nodes_on_stageout=True
- """
- hook_event = "queuejob"
- hook_name = "qjob"
- a = {'event': hook_event, 'enabled': 'true'}
- self.server.create_import_hook(hook_name, a, hook_body)
- jid = self.create_and_submit_job('job1_2')
- self.server.log_match("queuejob hook executed", n=20,
- max_attempts=25, interval=2)
- self.server.expect(JOB, {'job_state': 'R',
- 'release_nodes_on_stageout': 'True',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Deleting the job will trigger the stageout process
- # at which time sister nodes are automatically released
- # due to release_nodes_stageout=true set
- self.server.delete(jid)
- # Verify mom_logs
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.n4,), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostC), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- # Verify remaining job resources.
- self.server.expect(JOB, {'job_state': 'E',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 3,
- 'Resource_List.select': self.job1_newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 1,
- 'schedselect': self.job1_newsel,
- 'exec_host': self.job1_new_exec_host,
- 'exec_vnode': self.job1_new_exec_vnode},
- id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(3)
- # Check various vnode status
- self.match_vnode_status([self.n1, self.n2],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3], 'job-busy', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n4, self.n5, self.n6,
- self.n7, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_new_exec_host))
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_new_exec_host,
- self.job1_new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, self.job1_newsel)
- def test_hook_release_nodes_on_stageout_false(self):
- """
- Test:
- Using a queuejob hook to set
- -Wrelease_nodes_on_stageout=False.
- When job is deleted and runs a
- lengthy stageout process, nothing
- changes in job's vnodes assignment.
- """
- hook_body = """
- import pbs
- pbs.logmsg(pbs.LOG_DEBUG, "queuejob hook executed")
- pbs.event().job.release_nodes_on_stageout=False
- """
- hook_event = "queuejob"
- hook_name = "qjob"
- a = {'event': hook_event, 'enabled': 'true'}
- self.server.create_import_hook(hook_name, a, hook_body)
- jid = self.create_and_submit_job('job1_2')
- self.server.log_match("queuejob hook executed", n=20,
- max_attempts=25, interval=2)
- self.server.expect(JOB, {'job_state': 'R',
- 'release_nodes_on_stageout': 'False',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Deleting a job should not trigger automatic
- # release of nodes due to release_nodes_stagout=False
- self.server.delete(jid)
- # Verify mom_logs
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=5, interval=1,
- existence=False)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=5, interval=1,
- existence=False)
- # Verify no change in remaining job resources.
- self.server.expect(JOB, {'job_state': 'E',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy',
- jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Check for no existence of account update ('u') record
- self.server.accounting_match(
- msg='.*u;' + jid + ".*exec_host=%s.*" % (self.job1_exec_host_esc,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- # Check for no existence of account next ('c') record
- self.server.accounting_match(
- msg='.*c;' + jid + ".*exec_host=%s.*" % (self.job1_new_exec_host,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- def test_hook2_release_nodes_on_stageout_true(self):
- """
- Test:
- Using a modifyjob hook to set
- release_nodes_on_stageout=true.
- When job is deleted and runs a
- lengthy stageout process, only
- the primary execution host's
- vnodes are left assigned to the job.
- """
- hook_body = """
- import pbs
- pbs.logmsg(pbs.LOG_DEBUG, "modifyjob hook executed")
- pbs.event().job.release_nodes_on_stageout=True
- """
- hook_event = "modifyjob"
- hook_name = "mjob"
- a = {'event': hook_event, 'enabled': 'true'}
- self.server.create_import_hook(hook_name, a, hook_body)
- jid = self.create_and_submit_job('job1_2')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # This triggers the modifyjob hook
- self.server.alterjob(jid, {ATTR_N: "test"})
- self.server.log_match("modifyjob hook executed", n=100,
- max_attempts=25, interval=2)
- self.server.expect(JOB, {'release_nodes_on_stageout': 'True'}, id=jid)
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Deleting the job will trigger the stageout process
- # at which time sister nodes are automatically released
- # due to release_nodes_stageout=true set
- self.server.delete(jid)
- # Verify mom_logs
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostB), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostC), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- # Verify remaining job resources.
- self.server.expect(JOB, {'job_state': 'E',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 3,
- 'Resource_List.select': self.job1_newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 1,
- 'schedselect': self.job1_newsel,
- 'exec_host': self.job1_new_exec_host,
- 'exec_vnode': self.job1_new_exec_vnode},
- id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(3)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3], 'job-busy', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n4, self.n5, self.n6,
- self.n7, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_new_exec_host))
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_new_exec_host,
- self.job1_new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, self.job1_newsel)
- def test_hook2_release_nodes_on_stageout_false(self):
- """
- Test:
- Using a modifyjob hook to set
- release_nodes_on_stageout=False.
- When job is deleted and runs a
- lengthy stageout process, nothing
- changes in job's vnodes assignment.
- """
- hook_body = """
- import pbs
- pbs.logmsg(pbs.LOG_DEBUG, "modifyjob hook executed")
- pbs.event().job.release_nodes_on_stageout=False
- """
- hook_event = "modifyjob"
- hook_name = "mjob"
- a = {'event': hook_event, 'enabled': 'true'}
- self.server.create_import_hook(hook_name, a, hook_body)
- jid = self.create_and_submit_job('job1_2')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # This triggers the modifyjob hook
- self.server.alterjob(jid, {ATTR_N: "test"})
- self.server.log_match("modifyjob hook executed", n=100,
- max_attempts=25, interval=2)
- self.server.expect(JOB, {'release_nodes_on_stageout': 'False'}, id=jid)
- # Deleting a job should not trigger automatic
- # release of nodes due to release_nodes_stagout=False
- self.server.delete(jid)
- # Verify mom_logs
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=5, interval=1,
- existence=False)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=5, interval=1,
- existence=False)
- # Verify no change in remaining job resources.
- self.server.expect(JOB, {'job_state': 'E',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy',
- jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Check for no existence of account update ('u') record
- self.server.accounting_match(
- msg='.*u;' + jid + ".*exec_host=%s.*" % (self.job1_exec_host_esc,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- # Check for no existence of account next ('c') record
- self.server.accounting_match(
- msg='.*c;' + jid + ".*exec_host=%s.*" % (self.job1_new_exec_host,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- def test_release_nodes_error(self):
- """
- Tests erroneous cases:
- - pbs_release_nodes (no options given)
- - pbs_release_nodes -j <job-id> (and nothing else)
- - pbs_release_nodes -a (not run inside a job)
- - pbs_release_nodes -j <job-id> -a <node1>
- (both -a and listed nodes are given)
- - pbs_release_nodes -j <unknown-job-id> -a
- - pbs_release_nodes -j <job-id> -a
- and job is not in a running state.
- Returns the appropriate error message.
- """
- # Test no option given
- cmd = [self.pbs_release_nodes_cmd]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertNotEqual(ret['rc'], 0)
- self.assertTrue(ret['err'][0].startswith('usage:'))
- # test only -j <jobid> given
- cmd = [self.pbs_release_nodes_cmd, '-j', '23']
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertNotEqual(ret['rc'], 0)
- self.assertTrue(ret['err'][0].startswith('usage:'))
- # test only -a given
- cmd = [self.pbs_release_nodes_cmd, '-a']
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertNotEqual(ret['rc'], 0)
- self.assertTrue(ret['err'][0].startswith(
- 'pbs_release_nodes: No jobid given'))
- # Test specifying an unknown job id
- cmd = [self.pbs_release_nodes_cmd, '-j', '300000', '-a']
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertNotEqual(ret['rc'], 0)
- self.assertTrue(ret['err'][0].startswith(
- 'pbs_release_nodes: Unknown Job Id 300000'))
- # Test having '-a' and vnode parameter given to pbs_release_nodes
- a = {'Resource_List.select': '3:ncpus=1',
- 'Resource_List.place': 'scatter'}
- jid = self.create_and_submit_job('job', a)
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, '-a', self.n4]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertNotEqual(ret['rc'], 0)
- self.assertTrue(ret['err'][0].startswith('usage:'))
- self.server.delete(jid)
- # Test pbs_release_nodes' permission
- jid = self.create_and_submit_job('job', a)
- self.server.expect(JOB, {'job_state': 'R'}, id=jid)
- # Run pbs_release_nodes as the executing user != TEST_USER
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, '-a']
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER1)
- self.assertNotEqual(ret['rc'], 0)
- self.assertTrue(ret['err'][0].startswith(
- 'pbs_release_nodes: Unauthorized Request'))
- self.server.delete(jid)
- # Test pbs_release_nodes on a non-running job
- a = {'Resource_List.select': '3:ncpus=1',
- ATTR_h: None,
- 'Resource_List.place': 'scatter'}
- jid = self.create_and_submit_job('job', a)
- self.server.expect(JOB, {'job_state': 'H'}, id=jid)
- # Run pbs_release_nodes
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, '-a']
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertNotEqual(ret['rc'], 0)
- self.assertTrue(ret['err'][0].startswith(
- 'pbs_release_nodes: Request invalid for state of job'))
- def test_release_ms_nodes(self):
- """
- Test:
- Given: a job that has been submitted with a select spec
- of 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an
- exec_vnode=
- (<n1>+<n2>+<n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Executing pbs_release_nodes -j <job-id> <n5> <n6> <n1> <n7> where
- <n1> is a mother superior vnode, results in
- entire request to get rejected.
- """
- jid = self.create_and_submit_job('job1')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Run pbs_release_nodes
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n5, self.n6,
- self.n1, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertNotEqual(ret['rc'], 0)
- self.assertTrue(ret['err'][0].startswith(
- "pbs_release_nodes: " +
- "Can't free '%s' since " % (self.n1,) +
- "it's on a primary execution host"))
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy',
- jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Check for no existence of account update ('u') record
- self.server.accounting_match(
- msg='.*u;' + jid + ".*exec_host=%s.*" % (self.job1_exec_host_esc,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- # Check for no existence of account next ('c') record
- self.server.accounting_match(
- msg='.*c;' + jid + ".*exec_host=%s.*" % (self.job1_new_exec_host,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- def test_release_not_assigned_nodes(self):
- """
- Test:
- Given: a job that has been submitted with a select spec
- of 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an
- exec_vnode=
- (<n1>+<n2>+<n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Executing:
- pbs_release_nodes -j <job-id> <n4> <n5> <no_node> <n6> <n7>
- with <no node> means such node is not assigned to the job.
- entire request to get rejected.
- Result:
- Returns an error message and no nodes get released.
- """
- jid = self.create_and_submit_job('job1')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Run pbs_release_nodes
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4, self.n5,
- self.n8, self.n6, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertNotEqual(ret['rc'], 0)
- self.assertTrue(ret['err'][0].startswith(
- "pbs_release_nodes: node(s) requested " +
- "to be released not " +
- "part of the job: %s" % (self.n8,)))
- # Ensure nothing has changed with the job.
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy',
- jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Check for no existence of account update ('u') record
- self.server.accounting_match(
- msg='.*u;' + jid + ".*exec_host=%s.*" % (self.job1_exec_host_esc,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- # Check for no existence of account next ('c') record
- self.server.accounting_match(
- msg='.*c;' + jid + ".*exec_host=%s.*" % (self.job1_new_exec_host,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- def test_release_cray_nodes(self):
- """
- Test:
- Given: a job that has been submitted with a select spec
- of 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an
- exec_vnode=
- (<n1>+<n2>+<n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Executing:
- pbs_release_nodes -j <job-id> <n4> <n5> <n6> <n7>
- where <n7> is a Cray node,
- Result:
- Returns an error message and no nodes get released.
- """
- jid = self.create_and_submit_job('job1')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Set hostC node to be of cray type
- a = {'resources_available.vntype': 'cray_login'}
- # set natural vnode of hostC
- self.server.manager(MGR_CMD_SET, NODE, a, id=self.n7,
- expect=True)
- # Run pbs_release_nodes
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4, self.n5,
- self.n6, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertNotEqual(ret['rc'], 0)
- self.assertTrue(ret['err'][0].startswith(
- "pbs_release_nodes: not currently supported " +
- "on Cray X* series nodes: "
- "%s" % (self.n7,)))
- # Ensure nothing has changed with the job.
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy',
- jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Check for no existence of account update ('u') record
- self.server.accounting_match(
- msg='.*u;' + jid + ".*exec_host=%s.*" % (self.job1_exec_host_esc,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- # Check for no existence of account next ('c') record
- self.server.accounting_match(
- msg='.*c;' + jid + ".*exec_host=%s.*" % (self.job1_new_exec_host,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- def test_release_cpuset_nodes(self):
- """
- Test:
- Given: a job that has been submitted with a select spec
- of 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an
- exec_vnode=
- (<n1>+<n2>+<n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Executing:
- pbs_release_nodes -j <job-id> <n4> <n5> <n6> <n7>
- where <n7> is a cpuset node,
- Result:
- Returns an error message and no nodes get released.
- """
- jid = self.create_and_submit_job('job1')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Set hostB to be of cpuset type
- a = {'resources_available.arch': 'linux_cpuset'}
- # set natural vnode of hostC
- self.server.manager(MGR_CMD_SET, NODE, a, id=self.n7,
- expect=True)
- # Run pbs_release_nodes
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4, self.n5,
- self.n6, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertNotEqual(ret['rc'], 0)
- self.assertTrue(ret['err'][0].startswith(
- "pbs_release_nodes: not currently supported on nodes whose " +
- "resources are part of a cpuset: %s" % (self.n7,)))
- # Ensure nothing has changed with the job.
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy',
- jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Check for no existence of account update ('u') record
- self.server.accounting_match(
- msg='.*u;' + jid + ".*exec_host=%s.*" % (self.job1_exec_host_esc,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- # Check for no existence of account next ('c') record
- self.server.accounting_match(
- msg='.*c;' + jid + ".*exec_host=%s.*" % (self.job1_new_exec_host,),
- regexp=True, n=20, existence=False, max_attempts=5, interval=1)
- def test_release_nodes_all(self):
- """
- Test:
- Given a job that specifies a select spec of
- 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter".
- Calling
- pbs_release_nodes -j <job-id> -a
- will result in all the sister nodes getting
- unassigned from the job.
- """
- jid = self.create_and_submit_job('job1_2')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Run pbs_release_nodes as regular user
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, '-a']
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostB), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostC), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- # Verify remaining job resources.
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 3,
- 'Resource_List.select': self.job1_newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 1,
- 'schedselect': self.job1_newsel,
- 'exec_host': self.job1_new_exec_host,
- 'exec_vnode': self.job1_new_exec_vnode},
- id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(3)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3], 'job-busy', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n4, self.n5, self.n6,
- self.n7, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_new_exec_host))
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_new_exec_host,
- self.job1_new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, self.job1_newsel)
- def test_release_nodes_all_as_root(self):
- """
- Test:
- Same test as test_release_nodes_all except the pbs_release_nodes
- call is executed by root. Result is the same.
- """
- jid = self.create_and_submit_job('job1_2')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, '-a']
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostB), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostC), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- # Verify remaining job resources.
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 3,
- 'Resource_List.select': self.job1_newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 1,
- 'schedselect': self.job1_newsel,
- 'exec_host': self.job1_new_exec_host,
- 'exec_vnode': self.job1_new_exec_vnode},
- id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(3)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3], 'job-busy', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n4, self.n5, self.n6,
- self.n7, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_new_exec_host))
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_new_exec_host,
- self.job1_new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, self.job1_newsel)
- def test_release_nodes_all_inside_job(self):
- """
- Test:
- Like test_release_all test except instead of calling
- pbs_release_nodes from a command line, it is executed
- inside the job script of a running job. Same results.
- """
- # This one has a job script that calls 'pbs_release_nodes'
- # (no jobid specified)
- jid = self.create_and_submit_job('job1_3')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # wait for the job to execute pbs_release_nodes
- time.sleep(10)
- # Verify mom_logs
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostB), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostC), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- # Verify remaining job resources.
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 3,
- 'Resource_List.select': self.job1_newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 1,
- 'schedselect': self.job1_newsel,
- 'exec_host': self.job1_new_exec_host,
- 'exec_vnode': self.job1_new_exec_vnode},
- id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(3)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3], 'job-busy', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n4, self.n5, self.n6,
- self.n7, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_new_exec_host))
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_new_exec_host,
- self.job1_new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, self.job1_newsel)
- def test_release_nodes1(self):
- """
- Test:
- Given: a job that has been submitted with a select spec
- of 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an
- exec_vnode=
- (<n1>+<n2>+<n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Executing pbs_release_nodes -j <job-id> <n4>
- results in:
- 1. node <n4> no longer appearing in job's
- exec_vnode value,
- 2. resources associated with the
- node are taken out of job's Resources_List.*,
- schedselect values,
- 3. Since node <n4> is just one of the vnodes in the
- host assigned to the second super-chunk, the node
- still won't accept new jobs until all the other
- allocated vnodes from the same mom host are released.
- The resources then assigned to the job from
- node <n4> continues to be assigned including
- corresponding licenses.
- NOTE: This is testing to make sure the position of <n4>
- in the exec_vnode string (left end of a super-chunk) will
- not break the recreation of the attribute value after
- release.
- """
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # momB's host will not get DELETE_JOB2 request since
- # not all its vnodes have been released yet from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=1048576kb:ncpus=2+" + \
- "1:ncpus=2:mem=2097152kb"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_exec_host
- new_exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode_esc = new_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=7 taking away released vnode
- # <n4>, it's coming from a super-chunk where other vnodes <n5> and
- # <n6> are still assigned to the job. So the parent mom of <n4>
- # till won't release the job and thus, the 1 license for it is still
- # allocated.
- self.license_count_match(8)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_exec_host_esc,
- new_exec_vnode_esc, "5242880kb",
- 7, 3, self.job1_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "5242880kb", 7, 3,
- self.job1_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb",
- 8, 3, self.job1_place, self.job1_sel_esc)
- def test_release_nodes1_as_user(self):
- """
- Test:
- Same as test_release_nodes1 except pbs_release_nodes
- is executed by as regular user. Same results.
- """
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Run pbs_release_nodes as regular user
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # momB and momC's hosts will not get DELETE_JOB2 request since
- # not all their vnodes have been released yet from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=1048576kb:ncpus=2+" + \
- "1:ncpus=2:mem=2097152kb"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_exec_host
- new_exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode_esc = new_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=7 taking away released vnode
- # <n4>, it's coming from a super-chunk where other vnodes <n5> and
- # <n6> are still assigned to the job. So the parent mom of <n4>
- # till won't release the job and thus, the 1 license for it is still
- # allocated.
- self.license_count_match(8)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_exec_host_esc,
- new_exec_vnode_esc, "5242880kb",
- 7, 3, self.job1_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "5242880kb", 7, 3,
- self.job1_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb",
- 8, 3, self.job1_place, self.job1_sel_esc)
- def test_release_nodes1_extra(self):
- """
- Test:
- Like test_release_nodes1 except instead of the super-chunk
- and chunks getting only ncpus and mem values, additional
- resources mpiprocs and ompthreads are also requested and
- assigned:
- For example:
- qsub -l select="ncpus=3:mem=2gb:mpiprocs=3:ompthreads=2+
- ncpus=3:mem=2gb:mpiprocs=3:ompthreads=3+
- ncpus=2:mem=2gb:mpiprocs=2:ompthreads=2"
- We want to make sure the ompthreads and mpiprocs values are
- preserved in the new exec_vnode, and that in the $PBS_NODEFILE,
- the host names are duplicated according to the number of
- mpiprocs. For example, if <n1> is assigned to first
- chunk, with mpiprocs=3, <n1> will appear 3 times in
- $PBS_NODEFILE.
- """
- jid = self.create_and_submit_job('job1_extra_res')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select':
- self.job1_extra_res_select,
- 'Resource_List.place':
- self.job1_extra_res_place,
- 'schedselect':
- self.job1_extra_res_schedselect,
- 'exec_host':
- self.job1_extra_res_exec_host,
- 'exec_vnode':
- self.job1_extra_res_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # inside pbs_nodefile_match_exec_host() function, takes care of
- # verifying that the host names appear according to the number of
- # mpiprocs assigned to the chunk.
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(
- jid, self.job1_extra_res_exec_host,
- self.job1_extra_res_schedselect))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # momB and momC's hosts will not get DELETE_JOB2 request since
- # not all their vnodes have been released yet from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- sel_esc = self.job1_extra_res_select.replace("+", "\+")
- exec_host_esc = self.job1_extra_res_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = \
- self.job1_extra_res_exec_vnode.replace(
- "[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace(
- "+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3:mpiprocs=3:ompthreads=2+" + \
- "1:mem=1048576kb:ncpus=2:mpiprocs=3:ompthreads=3+" + \
- "1:ncpus=2:mem=2097152kb:mpiprocs=2:ompthreads=2"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_extra_res_exec_host
- new_exec_host_esc = self.job1_extra_res_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_extra_res_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode_esc = new_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB,
- {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_extra_res_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=7 taking away released vnode
- # <n4>, it's coming from a super-chunk where other vnodes <n5> and
- # <n6> are still assigned to the job. So the parent mom of <n4>
- # till won't release the job and thus, the 1 license for it is still
- # allocated.
- self.license_count_match(8)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, exec_host_esc,
- exec_vnode_esc, "6gb", 8, 3,
- self.job1_extra_res_place,
- sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "5242880kb",
- 7, 3, self.job1_extra_res_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host, newsel))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "5242880kb", 7, 3,
- self.job1_extra_res_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, exec_host_esc,
- exec_vnode_esc, "6gb",
- 8, 3, self.job1_extra_res_place,
- sel_esc)
- @timeout(400)
- def test_release_nodes2(self):
- """
- Test:
- Given: a job that has been submitted with a select spec
- of 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an
- exec_vnode=
- (<n1>+<n2>+<n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Executing pbs_release_nodes -j <job-id> <n5>
- results in:
- 1. node <n5> no longer appearing in job's
- exec_vnode value,
- 2. resources associated with the
- node are taken out of job's Resources_List.*,
- schedselect values,
- 3. Since node <n5> is just one of the vnodes in the
- host assigned to the second super-chunk, the node
- still won't accept new jobs until all the other
- allocated vnodes from the same mom host are released.
- The resources then assigned to the job from
- node <n5> continues to be assigned including
- corresponding licenses.
- NOTE: This is testing to make sure the position of <n5>
- in the exec_vnode string (middle of a super-chunk) will
- not break the recreation of the attribute value after
- release.
- """
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n5]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # momB and momC's hosts will not get DELETE_JOB2 request since
- # not all their vnodes have been released yet from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=1048576kb:ncpus=2+" + \
- "1:ncpus=2:mem=2097152kb"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_exec_host
- new_exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,), "")
- new_exec_vnode_esc = new_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=7 taking away released vnode
- # <n5>, it's coming from a super-chunk where other vnodes <n4> and
- # <n6> are still assigned to the job. So the parent mom of <n5>
- # till won't release the job and thus, the 1 license for it is still
- # allocated.
- self.license_count_match(8)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_exec_host_esc,
- new_exec_vnode_esc, "5242880kb",
- 7, 3, self.job1_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "5242880kb", 7, 3,
- self.job1_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb",
- 8, 3, self.job1_place, self.job1_sel_esc)
- def test_release_nodes2_extra(self):
- """
- Test:
- Like test_release_nodes2 except instead of the super-chunk
- and chunks getting only ncpus and mem values, additional
- resources mpiprocs and ompthreads are also requested and
- assigned:
- For example:
- qsub -l select="ncpus=3:mem=2gb:mpiprocs=3:ompthreads=2+
- ncpus=3:mem=2gb:mpiprocs=3:ompthreads=3+
- ncpus=2:mem=2gb:mpiprocs=2:ompthreads=2"
- We want to make sure the ompthreads and mpiprocs values are
- preserved in the new exec_vnode, and that in the $PBS_NODEFILE,
- the host names are duplicated according to the number of
- mpiprocs. For example, if <n1> is assigned to first
- chunk, with mpiprocs=3, <n1> will appear 3 times in
- $PBS_NODEFILE.
- """
- jid = self.create_and_submit_job('job1_extra_res')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select':
- self.job1_extra_res_select,
- 'Resource_List.place':
- self.job1_extra_res_place,
- 'schedselect':
- self.job1_extra_res_schedselect,
- 'exec_host':
- self.job1_extra_res_exec_host,
- 'exec_vnode':
- self.job1_extra_res_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # inside pbs_nodefile_match_exec_host() function, takes care of
- # verifying that the host names appear according to the number of
- # mpiprocs assigned to the chunk.
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(
- jid, self.job1_extra_res_exec_host,
- self.job1_extra_res_schedselect))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n5]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # momB and momC's hosts will not get DELETE_JOB2 request since
- # not all their vnodes have been released yet from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- sel_esc = self.job1_extra_res_select.replace("+", "\+")
- exec_host_esc = self.job1_extra_res_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_extra_res_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3:mpiprocs=3:ompthreads=2+" + \
- "1:mem=1048576kb:ncpus=2:mpiprocs=3:ompthreads=3+" + \
- "1:ncpus=2:mem=2097152kb:mpiprocs=2:ompthreads=2"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_extra_res_exec_host
- new_exec_host_esc = self.job1_extra_res_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_extra_res_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,), "")
- new_exec_vnode_esc = new_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB,
- {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_extra_res_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=7 taking away released vnode
- # <n5>, it's coming from a super-chunk where other vnodes <n4> and
- # <n6> are still assigned to the job. So the parent mom of <n5>
- # till won't release the job and thus, the 1 license for it is still
- # allocated.
- self.license_count_match(8)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, exec_host_esc,
- exec_vnode_esc, "6gb", 8, 3,
- self.job1_extra_res_place,
- sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "5242880kb",
- 7, 3, self.job1_extra_res_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host, newsel))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "5242880kb", 7, 3,
- self.job1_extra_res_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, exec_host_esc,
- exec_vnode_esc, "6gb",
- 8, 3, self.job1_extra_res_place,
- sel_esc)
- @timeout(400)
- def test_release_nodes3(self):
- """
- Test:
- Given: a job that has been submitted with a select spec
- of 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an
- exec_vnode=
- (<n1>+<n2>+<n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Executing pbs_release_nodes -j <job-id> <n6>
- results in:
- 1. node <n6> no longer appearing in job's
- exec_vnode value,
- 2. resources associated with the
- node are taken out of job's Resources_List.*,
- schedselect values,
- 3. Since node <n6> is just one of the vnodes in the
- host assigned to the second super-chunk, the node
- still won't accept new jobs until all the other
- allocated vnodes from the same mom host are released.
- The resources then assigned to the job from
- node <n6> continues to be assigned including
- corresponding licenses.
- NOTE: This is testing to make sure the position of <n6>
- in the exec_vnode string (right end of a super-chunk) will
- not break the recreation of the attribute value after
- release.
- """
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n6]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # momB and momC's hosts will not get DELETE_JOB2 request since
- # not all their vnodes have been released yet from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=2097152kb:ncpus=2+" + \
- "1:ncpus=2:mem=2097152kb"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_exec_host
- new_exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace(
- "+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "+%s:ncpus=1" % (self.n6,), "")
- new_exec_vnode_esc = new_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=7 taking away released vnode
- # <n6>, it's coming from a super-chunk where other vnodes <n4> and
- # <n5> are still # assigned to the job. So the parent mom of <n6>
- # till won't release the job and thus, the 1 license for it is still
- # allocated.
- self.license_count_match(8)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_exec_host_esc,
- new_exec_vnode_esc, "6291456kb",
- 7, 3, self.job1_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "6291456kb", 7, 3,
- self.job1_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb",
- 8, 3, self.job1_place, self.job1_sel_esc)
- @timeout(400)
- def test_release_nodes3_extra(self):
- """
- Test:
- Like test_release_nodes3 except instead of the super-chunk
- and chunks getting only ncpus and mem values, additional
- resources mpiprocs and ompthreads are also requested and
- assigned:
- For example:
- qsub -l select="ncpus=3:mem=2gb:mpiprocs=3:ompthreads=2+
- ncpus=3:mem=2gb:mpiprocs=3:ompthreads=3+
- ncpus=2:mem=2gb:mpiprocs=2:ompthreads=2"
- We want to make sure the ompthreads and mpiprocs values are
- preserved in the new exec_vnode, and that in the $PBS_NODEFILE,
- the host names are duplicated according to the number of
- mpiprocs. For example, if <n1> is assigned to first
- chunk, with mpiprocs=3, <n1> will appear 3 times in
- $PBS_NODEFILE.
- """
- jid = self.create_and_submit_job('job1_extra_res')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select':
- self.job1_extra_res_select,
- 'Resource_List.place':
- self.job1_extra_res_place,
- 'schedselect':
- self.job1_extra_res_schedselect,
- 'exec_host':
- self.job1_extra_res_exec_host,
- 'exec_vnode':
- self.job1_extra_res_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # inside pbs_nodefile_match_exec_host() function, takes care of
- # verifying that the host names appear according to the number of
- # mpiprocs assigned to the chunk.
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(
- jid, self.job1_extra_res_exec_host,
- self.job1_extra_res_schedselect))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n6]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # momB and momC's hosts will not get DELETE_JOB2 request since
- # not all their vnodes have been released yet from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- sel_esc = self.job1_extra_res_select.replace("+", "\+")
- exec_host_esc = self.job1_extra_res_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_extra_res_exec_vnode.replace(
- "[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3:mpiprocs=3:ompthreads=2+" + \
- "1:mem=2097152kb:ncpus=2:mpiprocs=3:ompthreads=3+" + \
- "1:ncpus=2:mem=2097152kb:mpiprocs=2:ompthreads=2"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_extra_res_exec_host
- new_exec_host_esc = self.job1_extra_res_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_extra_res_exec_vnode.replace(
- "+%s:ncpus=1" % (self.n6,), "")
- new_exec_vnode_esc = new_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB,
- {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place':
- self.job1_extra_res_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=7 taking away released vnode
- # <n6>, it's coming from a super-chunk where other vnodes <n4> and
- # <n5> are still assigned to the job. So the parent mom of <n6>
- # till won't release the job and thus, the 1 license for it is still
- # allocated.
- self.license_count_match(8)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, exec_host_esc,
- exec_vnode_esc, "6gb", 8, 3,
- self.job1_extra_res_place,
- sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "6291456kb",
- 7, 3, self.job1_extra_res_place, newsel_esc)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'},
- id="workq")
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host, newsel))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "6291456kb", 7, 3,
- self.job1_extra_res_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, exec_host_esc,
- exec_vnode_esc, "6gb",
- 8, 3, self.job1_extra_res_place,
- sel_esc)
- def test_release_nodes4(self):
- """
- Test:
- Given: a job that has been submitted with a select spec
- of 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an
- exec_vnode=
- (<n1>+<n2>+<n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Executing pbs_release_nodes -j <job-id> <n4> <n5> <n7>
- results in:
- 1. node <n4>, <n5>, and <n7> are no longer appearing in
- job's exec_vnode value,
- 2. resources associated with the released
- nodes are taken out of job's Resources_List.*,
- schedselect values,
- 3. Since nodes <n4> and <n5> are some of the vnodes in the
- host assigned to the second super-chunk, the node
- still won't accept new jobs until all the other
- allocated vnodes (<n6>) from the same mom host are
- released.
- 4. The resources then assigned to the job from
- node <n4> and <n5> continue to be assigned including
- corresponding licenses.
- 5. <n7> is the only vnode assigned to the host mapped
- to the third chunk so it's fully deallocated and
- its assigned resources are removed from the job.
- """
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4, self.n5,
- self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # momB's host will not get job summary reported but
- # momC's host will get the job summary since all vnodes
- # from the host have been released.
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10, regexp=True, existence=False,
- max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10, regexp=True)
- # momB's host will not get DELETE_JOB2 request since
- # not all their vnodes have been released yet from the job.
- # momC's host will get DELETE_JOB2 request since sole vnnode
- # <n7> has been released from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20)
- # Ensure the 'fib' process is gone on hostC when DELETE_JOB request
- # is received
- self.server.pu.get_proc_info(
- self.momC.hostname, ".*fib.*", None, regexp=True)
- self.assertEqual(len(self.server.pu.processes), 0)
- # Verify remaining job resources.
- sel_esc = self.job1_select.replace("+", "\+")
- exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:ncpus=1"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_exec_host.replace(
- "+%s/0*2" % (self.n7,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=2:mem=2097152kb)" % (self.n7,), "")
- new_exec_vnode_esc = new_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=4 taking away released vnode
- # <n4> (1 cpu), <n5> (1 cpu), <n7> (2 cpus),
- # only <n7> got released. <n4> and <n5> are part of a super
- # chunk that wasn't fully released.
- self.license_count_match(6)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "2097152kb",
- 4, 2, self.job1_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- self.match_vnode_status([self.n0, self.n7, self.n8, self.n9, self.n10],
- 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "2097152kb", 4, 2,
- self.job1_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb",
- 8, 3, self.job1_place, self.job1_sel_esc)
- def test_release_nodes4_extra(self):
- """
- Test:
- Like test_release_nodes4 except instead of the super-chunk
- and chunks getting only ncpus and mem values, additional
- resources mpiprocs and ompthreads are also requested and
- assigned:
- For example:
- qsub -l select="ncpus=3:mem=2gb:mpiprocs=3:ompthreads=2+
- ncpus=3:mem=2gb:mpiprocs=3:ompthreads=3+
- ncpus=2:mem=2gb:mpiprocs=2:ompthreads=2"
- We want to make sure the ompthreads and mpiprocs values are
- preserved in the new exec_vnode, and that in the $PBS_NODEFILE,
- the host names are duplicated according to the number of
- mpiprocs. For example, if <n1> is assigned to first
- chunk, with mpiprocs=3, <n1> will appear 3 times in
- $PBS_NODEFILE.
- """
- jid = self.create_and_submit_job('job1_extra_res')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select':
- self.job1_extra_res_select,
- 'Resource_List.place':
- self.job1_extra_res_place,
- 'schedselect':
- self.job1_extra_res_schedselect,
- 'exec_host':
- self.job1_extra_res_exec_host,
- 'exec_vnode':
- self.job1_extra_res_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # inside pbs_nodefile_match_exec_host() function, takes care of
- # verifying that the host names appear according to the number of
- # mpiprocs assigned to the chunk.
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(
- jid, self.job1_extra_res_exec_host,
- self.job1_extra_res_schedselect))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4, self.n5,
- self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # momB's host will not get job summary reported but
- # momC's host will get the job summary since all vnodes
- # from the host have been released.
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10, regexp=True, existence=False,
- max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10, regexp=True)
- # momB's host will not get DELETE_JOB2 request since
- # not all their vnodes have been released yet from the job.
- # momC will get DELETE_JOB2 request since sole vnode
- # <n7> has been released from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20)
- # Ensure the 'fib' process is gone from hostC when DELETE_JOB request
- # received
- self.server.pu.get_proc_info(
- self.momC.hostname, ".*fib.*", None, regexp=True)
- self.assertEqual(len(self.server.pu.processes), 0)
- # Verify remaining job resources.
- sel_esc = self.job1_extra_res_select.replace("+", "\+")
- exec_host_esc = self.job1_extra_res_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_extra_res_exec_vnode.replace(
- "[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3:mpiprocs=3:ompthreads=2+" + \
- "1:ncpus=1:mpiprocs=3:ompthreads=3"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_extra_res_exec_host.replace(
- "+%s/0*2" % (self.n7,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_extra_res_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=2:mem=2097152kb)" % (self.n7,), "")
- new_exec_vnode_esc = new_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place':
- self.job1_extra_res_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=4 taking away released vnode
- # <n4> (1 cpu), <n5> (1 cpu), <n7> (2 cpus),
- # only <n7> got released. <n4> and <n5> are part of a super
- # chunk that wasn't fully released.
- self.license_count_match(6)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, exec_host_esc,
- exec_vnode_esc, "6gb", 8, 3,
- self.job1_extra_res_place,
- sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "2097152kb",
- 4, 2, self.job1_extra_res_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- self.match_vnode_status([self.n0, self.n7, self.n8, self.n9, self.n10],
- 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host, newsel))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "2097152kb", 4, 2,
- self.job1_extra_res_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, exec_host_esc,
- exec_vnode_esc, "6gb",
- 8, 3, self.job1_extra_res_place,
- sel_esc)
- def test_release_nodes5(self):
- """
- Test:
- Given: a job that has been submitted with a select spec
- of 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an
- exec_vnode=
- (<n1>+<n2>+<n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Executing pbs_release_nodes -j <job-id> <n5> <n6> <n7>
- results in:
- 1. node <n5>, <n6>, and <n7> are no longer appearing in
- job's exec_vnode value,
- 2. resources associated with the released
- nodes are taken out of job's Resources_List.*,
- schedselect values,
- 3. Since nodes <n5> and <n6> are some of the vnodes in the
- host assigned to the second super-chunk, the node
- still won't accept new jobs until all the other
- allocated vnodes (<n4>) from the same mom host are
- released.
- 4. The resources then assigned to the job from
- node <n5> and <n6> continue to be assigned including
- corresponding licenses.
- 5. <n7> is the only vnode assigned to the host mapped
- to the third chunk so it's fully deallocated and
- its assigned resources are removed from the job.
- """
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n5, self.n6,
- self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # momB's host will not get job summary reported but
- # momC's host will get the job summary since all vnodes
- # from the host have been released.
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10, regexp=True, existence=False,
- max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10, regexp=True)
- # momB's host will not get DELETE_JOB2 request since
- # not all their vnodes have been released yet from the job.
- # momC will get DELETE_JOB2 request since sole vnode
- # <n7> has been released from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20)
- # Ensure the 'fib' process is gone from hostC when DELETE_JOB request
- # received
- self.server.pu.get_proc_info(
- self.momC.hostname, ".*fib.*", None, regexp=True)
- self.assertEqual(len(self.server.pu.processes), 0)
- # Verify remaining job resources.
- sel_esc = self.job1_select.replace("+", "\+")
- exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=1048576kb:ncpus=1"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_exec_host.replace(
- "+%s/0*2" % (self.n7,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "+%s:mem=1048576kb:ncpus=1" % (self.n5,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+%s:ncpus=1" % (self.n6,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=2:mem=2097152kb)" % (self.n7,), "")
- new_exec_vnode_esc = \
- new_exec_vnode.replace("[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '3gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=4 taking away released vnode
- # <n5> (1 cpu), <n6> (1 cpu), <n7> (2 cpus),
- # only <n7> got released. <n5> and <n6> are part of a super
- # chunk that wasn't fully released.
- self.license_count_match(6)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "3145728kb",
- 4, 2, self.job1_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- # <n5> still job-busy
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- # <n6> still job-busy
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- # <n7> now free
- self.match_vnode_status([self.n0, self.n7, self.n8, self.n9, self.n10],
- 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "3145728kb", 4, 2,
- self.job1_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb",
- 8, 3, self.job1_place, self.job1_sel_esc)
- def test_release_nodes5_extra(self):
- """
- Test:
- Like test_release_nodes5 except instead of the super-chunk
- and chunks getting only ncpus and mem values, additional
- resources mpiprocs and ompthreads are also requested and
- assigned:
- For example:
- qsub -l select="ncpus=3:mem=2gb:mpiprocs=3:ompthreads=2+
- ncpus=3:mem=2gb:mpiprocs=3:ompthreads=3+
- ncpus=2:mem=2gb:mpiprocs=2:ompthreads=2"
- We want to make sure the ompthreads and mpiprocs values are
- preserved in the new exec_vnode, and that in the $PBS_NODEFILE,
- the host names are duplicated according to the number of
- mpiprocs. For example, if <n1> is assigned to first
- chunk, with mpiprocs=3, <n1> will appear 3 times in
- $PBS_NODEFILE.
- """
- jid = self.create_and_submit_job('job1_extra_res')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select':
- self.job1_extra_res_select,
- 'Resource_List.place':
- self.job1_extra_res_place,
- 'schedselect':
- self.job1_extra_res_schedselect,
- 'exec_host':
- self.job1_extra_res_exec_host,
- 'exec_vnode':
- self.job1_extra_res_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # inside pbs_nodefile_match_exec_host() function, takes care of
- # verifying that the host names appear according to the number of
- # mpiprocs assigned to the chunk.
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(
- jid, self.job1_extra_res_exec_host,
- self.job1_extra_res_schedselect))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n5, self.n6,
- self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # momB's host will not get job summary reported but
- # momC's host will get the job summary since all vnodes
- # from the host have been released.
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10, regexp=True, existence=False,
- max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10, regexp=True)
- # momB's host will not get DELETE_JOB2 request since
- # not all their vnodes have been released yet from the job.
- # momC will get DELETE_JOB2 request since sole vnode
- # <n7> has been released from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20)
- # Ensure the 'fib' process is gone from hostC when DELETE_JOB request
- # received
- self.server.pu.get_proc_info(
- self.momC.hostname, ".*fib.*", None, regexp=True)
- self.assertEqual(len(self.server.pu.processes), 0)
- # Verify remaining job resources.
- sel_esc = self.job1_extra_res_select.replace("+", "\+")
- exec_host_esc = self.job1_extra_res_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = \
- self.job1_extra_res_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace(
- "+", "\+")
- newsel = \
- "1:mem=2097152kb:ncpus=3:mpiprocs=3:ompthreads=2+" + \
- "1:mem=1048576kb:ncpus=1:mpiprocs=3:ompthreads=3"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_extra_res_exec_host.replace(
- "+%s/0*2" % (self.n7,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_extra_res_exec_vnode.replace(
- "+%s:mem=1048576kb:ncpus=1" % (self.n5,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+%s:ncpus=1" % (self.n6,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=2:mem=2097152kb)" % (self.n7,), "")
- new_exec_vnode_esc = \
- new_exec_vnode.replace("[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '3gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place':
- self.job1_extra_res_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=4 taking away released vnode
- # <n5> (1 cpu), <n6> (1 cpu), <n7> (2 cpus),
- # only <n7> got released. <n5> and <n6> are part of a super
- # chunk that wasn't fully released.
- self.license_count_match(6)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, exec_host_esc,
- exec_vnode_esc, "6gb", 8, 3,
- self.job1_extra_res_place,
- sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "3145728kb",
- 4, 2, self.job1_extra_res_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- # <n5> still job-busy
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- # <n6> still job-busy
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- # <n7> is now free
- self.match_vnode_status([self.n0, self.n7, self.n8, self.n9, self.n10],
- 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host, newsel))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "3145728kb", 4, 2,
- self.job1_extra_res_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, exec_host_esc,
- exec_vnode_esc, "6gb",
- 8, 3, self.job1_extra_res_place,
- sel_esc)
- def test_release_nodes6(self):
- """
- Test:
- Given: a job that has been submitted with a select spec
- of 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an
- exec_vnode=
- (<n1>+<n2>+<n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Executing pbs_release_nodes -j <job-id> <n4> <n5> <n6> <n7>
- is equivalent to doing 'pbs_release_nodes -a' which
- will have the same result as test_release_nodes_all.
- That is, all sister nodes assigned to the job are
- released early from the job.
- """
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_exec_host))
- # Run pbs_release_nodes as regular user
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4, self.n5,
- self.n6, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostB), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostC), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- # Ensure the 'fib' process is gone when DELETE_JOB2 received on momB
- self.server.pu.get_proc_info(
- self.momB.hostname, ".*fib.*", None, regexp=True)
- self.assertEqual(len(self.server.pu.processes), 0)
- # Ensure the 'fib' process is gone when DELETE_JOB2 received on momC
- self.server.pu.get_proc_info(
- self.momC.hostname, ".*fib.*", None, regexp=True)
- self.assertEqual(len(self.server.pu.processes), 0)
- # Verify remaining job resources.
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 3,
- 'Resource_List.select': self.job1_newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 1,
- 'schedselect': self.job1_newsel,
- 'exec_host': self.job1_new_exec_host,
- 'exec_vnode': self.job1_new_exec_vnode},
- id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(3)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3], 'job-busy', jobs_assn1, 1, '0kb')
- # nodes <n4>, <n5>, <n6>, <n7> are all free now
- self.match_vnode_status([self.n0, self.n4, self.n5, self.n6,
- self.n7, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, self.job1_new_exec_host))
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_new_exec_host,
- self.job1_new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, self.job1_newsel)
- # For job to end to get the end records in the accounting_logs
- self.server.delete(jid)
- # Check account phased end job ('e') record
- self.match_accounting_log('e', jid, self.job1_new_exec_host,
- self.job1_new_exec_vnode_esc, "2097152kb", 3,
- 1, self.job1_place, self.job1_newsel)
- # Check account end of job ('E') record
- self.match_accounting_log('E', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- def test_release_nodes6_extra(self):
- """
- Test:
- Like test_release_nodes6 except instead of the super-chunk
- and chunks getting only ncpus and mem values, additional
- resources mpiprocs and ompthreads are also requested and
- assigned:
- For example:
- qsub -l select="ncpus=3:mem=2gb:mpiprocs=3:ompthreads=2+
- ncpus=3:mem=2gb:mpiprocs=3:ompthreads=3+
- ncpus=2:mem=2gb:mpiprocs=2:ompthreads=2"
- We want to make sure the ompthreads and mpiprocs values are
- preserved in the new exec_vnode, and that in the $PBS_NODEFILE,
- the host names are duplicated according to the number of
- mpiprocs. For example, if <n1> is assigned to first
- chunk, with mpiprocs=3, <n1> will appear 3 times in
- $PBS_NODEFILE.
- """
- jid = self.create_and_submit_job('job1_extra_res')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select':
- self.job1_extra_res_select,
- 'Resource_List.place':
- self.job1_extra_res_place,
- 'schedselect':
- self.job1_extra_res_schedselect,
- 'exec_host': self.job1_extra_res_exec_host,
- 'exec_vnode': self.job1_extra_res_exec_vnode},
- id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid,
- self.job1_extra_res_exec_host,
- self.job1_extra_res_schedselect))
- # Run pbs_release_nodes as regular user
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4, self.n5,
- self.n6, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostB), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostC), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- # Ensure the 'fib' process is gone when DELETE_JOB2 received on momB
- self.server.pu.get_proc_info(
- self.momB.hostname, ".*fib.*", None)
- self.assertEqual(len(self.server.pu.processes), 0)
- # Ensure the 'fib' process is gone when DELETE_JOB2 received on momC
- self.server.pu.get_proc_info(
- self.momC.hostname, ".*fib.*", None, regexp=True)
- self.assertEqual(len(self.server.pu.processes), 0)
- # Verify remaining job resources.
- sel_esc = self.job1_extra_res_select.replace("+", "\+")
- exec_host_esc = self.job1_extra_res_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = \
- self.job1_extra_res_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3:mpiprocs=3:ompthreads=2"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_extra_res_exec_host.replace(
- "+%s/0*2" % (self.n7,), "")
- new_exec_host = new_exec_host.replace("+%s/0*0" % (self.n4,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_extra_res_exec_vnode.replace(
- "+%s:mem=1048576kb:ncpus=1" % (self.n5,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+%s:ncpus=1" % (self.n6,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:mem=1048576kb:ncpus=1)" % (self.n4,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=2:mem=2097152kb)" % (self.n7,), "")
- new_exec_vnode_esc = \
- new_exec_vnode.replace("[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB,
- {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 3,
- 'Resource_List.select': newsel,
- 'Resource_List.place':
- self.job1_extra_res_place,
- 'Resource_List.nodect': 1,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(3)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3], 'job-busy', jobs_assn1, 1, '0kb')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'},
- id="workq")
- # nodes <n4>, <n5>, <n6>, <n7> are all free now
- self.match_vnode_status([self.n0, self.n4, self.n5, self.n6,
- self.n7, self.n8, self.n9, self.n10], 'free')
- # Ensure the $PBS_NODEFILE contents account for the mpiprocs value;
- # that is, each node hostname is listed 'mpiprocs' number of times in
- # the file.
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(
- jid, self.job1_new_exec_host, newsel))
- # Check account update ('u') record
- self.match_accounting_log('u', jid, exec_host_esc,
- exec_vnode_esc,
- "6gb", 8, 3,
- self.job1_extra_res_place,
- sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- self.job1_new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, newsel_esc)
- # For job to end to get the end records in the accounting_logs
- self.server.delete(jid)
- # Check account phased end job ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc, "2097152kb", 3,
- 1, self.job1_place, newsel_esc)
- # Check account end of job ('E') record
- self.match_accounting_log('E', jid, exec_host_esc,
- exec_vnode_esc, "6gb", 8, 3,
- self.job1_place, sel_esc)
- # longer timeout needed as the following test takes a bit
- # longer waiting for job to finish due to stage out
- @timeout(400)
- def test_release_nodes_cmd_plus_stageout(self):
- """
- Test:
- This test calling pbs_release_nodes command on a job
- submitted with release_nodes_on_stageout option.
- Given a job submitted as:
- qsub -W release_nodes_on_stageout=true job.script
- where job.script specifies a select spec of
- 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an:
- exec_vnode=(<n1>+<n2>+<n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Then issue:
- pbs_release_nodes -j <job-id> <n7>
- This would generate a 'u' and 'c' accounting record.
- while <n7> vnode gets deallocated given that it's
- the only vnode assigned to host mapped to third chunk.
- Now call:
- qdel <job-id>
- This would cause the remaining vnodes <n4>, <n5>, <n6>
- to be deallocated due to job have the
- -W release_nodes_on_stageout=true setting.
- The result is reflected in the 'u', 'c', and 'e'
- accounting logs. 'E' accounting record summarizes
- everything.
- """
- jid = self.create_and_submit_job('job1')
- self.server.expect(JOB, {'job_state': 'R',
- 'release_nodes_on_stageout': 'True',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Run pbs_release_nodes
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Only mom hostC will get the job summary it was released
- # early courtesy of sole vnode <n7>.
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostB), n=10,
- regexp=True, existence=False, max_attempts=5, interval=1)
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostC), n=10,
- regexp=True)
- # Only mom hostC will gt the IM_DELETE_JOB2 request
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20)
- # Ensure the 'fib' process is gone from hostC when DELETE_JOB request
- # received
- self.server.pu.get_proc_info(
- self.momC.hostname, ".*fib.*", None, regexp=True)
- self.assertEqual(len(self.server.pu.processes), 0)
- # Verify remaining job resources.
- sel_esc = self.job1_select.replace("+", "\+")
- exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=2097152kb:ncpus=3"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = "%s/0*0+%s/0*0" % (self.n0, self.hostB)
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "+(%s:ncpus=2:mem=2097152kb)" % (self.n7,), "")
- new_exec_vnode_esc = new_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '4194304kb',
- 'Resource_List.ncpus': 6,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(6)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- # <n7> now free
- self.match_vnode_status([self.n0, self.n7, self.n8, self.n9, self.n10],
- 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host))
- # Check account update ('u') record
- self.match_accounting_log('u', jid, exec_host_esc,
- exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "4194304kb",
- 6, 2, self.job1_place, newsel_esc)
- # Terminate the job
- self.server.delete(jid)
- # Check 'u' accounting record from release_nodes_on_stageout=true
- self.match_accounting_log('u', jid, new_exec_host_esc,
- new_exec_vnode_esc, "4194304kb", 6, 2,
- self.job1_place,
- newsel_esc)
- # Verify mom_logs
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- max_attempts=18, interval=2, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=18, interval=2)
- # Verify remaining job resources.
- sel_esc = self.job1_select.replace("+", "\+")
- exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = self.transform_select(self.job1_select.split('+')[0])
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_exec_host.split('+')[0]
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.split(')')[0] + ')'
- new_exec_vnode_esc = new_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace(
- "+", "\+")
- self.server.expect(JOB, {'job_state': 'E',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 3,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 1,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(3)
- # Check various vnode status.
- # only vnodes from mother superior (sef.hostA) are job-busy
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3], 'job-busy', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n4, self.n5,
- self.n6, self.n7, self.n8, self.n9,
- self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host))
- # Check 'c' accounting record from release_nodes_on_stageout=true
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, newsel_esc)
- # wait for job to finish
- self.server.expect(JOB, 'queue', id=jid, op=UNSET, max_attempts=100,
- interval=4, offset=15)
- # Check 'e' record to release_nodes_on_stageout=true
- self.match_accounting_log('e', jid, new_exec_host,
- new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, newsel_esc)
- # Check 'E' (end of job) record to release_nodes_on_stageout=true
- self.match_accounting_log('E', jid, exec_host_esc,
- exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- def test_multi_release_nodes(self):
- """
- Test:
- This tests several calls to pbs_release_nodes command for
- the same job.
- Given a job submitted with a select spec of
- 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an:
- has exec_vnode=
- (<n1>+<n2><n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- First call:
- pbs_release_nodes -j <job-id> <n4>
- <n4> node no longer shows in job's exec_vnode,
- but it will still show as job-busy
- (not accept jobs) since the other 2 vnodes,
- <n5> and <n6> from the host mapped to second
- chunk are still assigned. The 'u' and 'c'
- accounting records will reflect this.
- Second call:
- pbs_release_nodes -j <job-id> <n5> <n6> <n7>
- Now since all vnodes assigned to the job from
- host mapped to second chunk will show as free.
- Again, the accounting 'u' and 'c' records would
- reflect this fact.
- """
- jid = self.create_and_submit_job('job1')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Run pbs_release_nodes
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- sel_esc = self.job1_select.replace("+", "\+")
- exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=1048576kb:ncpus=2+" + \
- "1:ncpus=2:mem=2097152kb"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_exec_host
- new_exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode_esc = \
- new_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(
- ")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=7 taking away released vnode
- # <n4> (1 cpu), its license is not taken away as <n4> is assigned
- # to a super chunk, and the parent mom still has not released the
- # job as vnodes <n5> and <n6> are still allocated to the job.
- self.license_count_match(8)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10],
- 'free')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'},
- id="workq")
- # Check account update ('u') record
- self.match_accounting_log('u', jid, exec_host_esc,
- exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "5242880kb",
- 7, 3, self.job1_place, newsel_esc)
- # Run pbs_release_nodes again
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n5,
- self.n6, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Now mom hostB and hostC can fully release the job
- # resulting in job summary information reported
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- max_attempts=8, interval=2, regexp=True)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- max_attempts=8, interval=2, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=8, interval=2)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=8, interval=2)
- # Check account update ('u') record got generated
- # second pbs_release_nodes call
- self.match_accounting_log('u', jid, new_exec_host_esc,
- new_exec_vnode_esc, "5242880kb", 7, 3,
- self.job1_place,
- newsel_esc)
- # Verify remaining job resources.
- newsel = "1:mem=2097152kb:ncpus=3"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = new_exec_host.replace("+%s/0*2" % (self.n7,), "")
- new_exec_host = new_exec_host.replace("+%s/0*0" % (self.n4,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:mem=1048576kb:ncpus=1" % (self.n5,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+%s:ncpus=1)" % (self.n6,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=2:mem=2097152kb)" % (self.n7,), "")
- new_exec_vnode_esc = new_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 3,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 1,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(3)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3], 'job-busy', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n4, self.n5, self.n6,
- self.n7, self.n8, self.n9, self.n10],
- 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 3,
- 'resources_assigned.mem': '2097152kb'},
- id="workq")
- # Check to make sure 'c' (next) record got generated for
- # second pbs_release_nodes call
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "2097152kb",
- 3, 1, self.job1_place, newsel_esc)
- def test_release_nodes_run_next_job(self):
- """
- Test:
- Test releasing nodes of one job to allow another
- job to use resources from the released nodes.
- Given a job submitted with a select spec of
- 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an:
- exec_vnode=
- (<n1>+<n2><n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- First call:
- pbs_release_nodes -j <job-id> <n4> <n5> <n7>
- Submit another job: j2 that will need also the
- unreleased vnode <n6> so job stays queued.
- Now execute:
- pbs_release_nodes -j <job-id> <n6>>
- And job j2 starts executing using node <n6>
- """
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Run pbs_release_nodes
- cmd = [self.pbs_release_nodes_cmd, '-j', jid,
- self.n4, self.n5, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- # this is a 7-cpu job that needs <n6> which has not been freed
- jid2 = self.create_and_submit_job('job2')
- # we expect job_state to be Queued
- self.server.expect(JOB, 'comment', op=SET, id=jid2)
- self.server.expect(JOB, {'job_state': 'Q'}, id=jid2)
- # Let's release the remaining <node6> vnode from hostB
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n6]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # now job 2 should start running
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '7gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job2_select,
- 'Resource_List.place': self.job2_place,
- 'schedselect': self.job2_schedselect,
- 'exec_host': self.job2_exec_host,
- 'exec_vnode': self.job2_exec_vnode_var1},
- id=jid2)
- jobs_assn2 = "%s/0" % (jid2,)
- self.match_vnode_status([self.n4, self.n5, self.n6, self.n8, self.n9],
- 'job-busy', jobs_assn2, 1, '1048576kb')
- jobs_assn3 = "%s/0, %s/1" % (jid2, jid2)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn3,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n10], 'free')
- def test_release_nodes_rerun(self):
- """
- Test:
- Test the behavior of a job with released nodes when they
- get rerun. The job is killed, requeued, and assigned
- the original set of resources before pbs_release_nodes
- was called.
- Given a job submitted with a select spec of
- 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter", resulting in an:
- exec_vnode=
- (<n1>+<n2><n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- First call:
- pbs_release_nodes -j <job-id> <n5> <n6> <n7>
- Then call:
- qrerun <job-id>
- Causes the job to rerun with the original requested
- resources.
- """
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Run pbs_release_nodes
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n5,
- self.n6, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # only mom hostC released the job since the sole vnode
- # <n7> has been released
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10, regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10, regexp=True)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20)
- # Verify remaining job resources.
- sel_esc = self.job1_select.replace("+", "\+")
- exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=1048576kb:ncpus=1"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_exec_host.replace(
- "+%s/0*2" % (self.n7,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "+%s:mem=1048576kb:ncpus=1" % (self.n5,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+%s:ncpus=1" % (self.n6,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=2:mem=2097152kb)" % (self.n7,), "")
- new_exec_vnode_esc = new_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '3gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=4 taking away released vnode
- # <n5> (1 cpu), <n6> (1 cpu), <n7> (2 cpus),
- # only the 2 cpu licenses from chunk containing <n7> are released as
- # <n5> and <n6> are from a super-chunk, and its parent mom is not
- # releasing the job yet since vnode <n4> is still assigned to the job.
- self.license_count_match(6)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, exec_host_esc,
- exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "3145728kb",
- 4, 2, self.job1_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n5], 'job-busy', jobs_assn1,
- 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n7, self.n8, self.n9, self.n10],
- 'free')
- # Now rerun the job
- self.server.rerunjob(jid)
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- def test_release_nodes_epilogue(self):
- """
- Test:
- Test to make sure when a job is removed from
- a mom host when all vnodes from that host have
- been released for the job, and run the epilogue hook.
- """
- # First, submit an epilogue hook:
- hook_body = """
- import pbs
- pbs.logjobmsg(pbs.event().job.id, "epilogue hook executed")
- """
- a = {'event': 'execjob_epilogue', 'enabled': 'true'}
- self.server.create_import_hook("epi", a, hook_body)
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (jid, jid)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # Run pbs_release_nodes
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4, self.n5,
- self.n6, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20)
- self.momB.log_match("Job;%s;epilogue hook executed" % (jid,), n=20)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- max_attempts=2, interval=5, regexp=True)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- max_attempts=2, interval=5, regexp=True)
- # Ensure the 'fib' process is gone when DELETE_JOB
- self.server.pu.get_proc_info(
- self.momB.hostname, ".*fib.*", None, regexp=True)
- self.assertEqual(len(self.server.pu.processes), 0)
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=2, interval=5)
- self.momC.log_match("Job;%s;epilogue hook executed" % (jid,), n=20,
- max_attempts=2, interval=5)
- # Ensure the 'fib' process is gone when DELETE_JOB
- self.server.pu.get_proc_info(
- self.momC.hostname, ".*fib.*", None, regexp=True)
- self.assertEqual(len(self.server.pu.processes), 0)
- def test_release_nodes_complex(self):
- """
- Test:
- Test a complicated scenario involving
- releasing nodes from a job that has been
- submitted with exclusive placement
- (-l place=scatter:excl), having one of the
- parent moms of released vnodes being
- stopped and continued, suspending and resuming
- of jobs, and finally submitting a new job
- requiring a non-exclusive access to a vnode.
- Given a job submitted with a select spec of
- 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=1 and mem=1gb, along with
- place spec of "scatter:excl", resulting in an:
- exec_vnode=
- (<n1>+<n2><n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Then stop parent mom host of <n7> (kill -STOP), now issue:
- pbs_release_nodes -j <job-id> <n4> <n5> <n7>
- causing <n4>, <n5>, and <n7> to still be tied to the job
- as there's still node <n6> tied to the job as part of mom
- hostB, which satisfies the second super-chunk.
- Node <n7> is still assigned to the job as parent
- mom hostC has been stopped.
- Submit another job (job2), needing the node <n7> and
- 1 cpu but job ends up queued since first job is still
- using <n7>.
- Now Delete job2.
- Now suspend the first job, and all resources_assigned to
- the job's nodes are cleared.
- Now resume the mom of <n7> (kill -CONT). This mom would
- tell server to free up node <n7> as first job has
- been completely removed from the node.
- Now resume job1, and all resources_asssigned
- of the job's nodes including <n4>, <n5> are shown
- allocated, with resources in node <n7> freed.
- Then submit a new 1-cpu job that specifically asks for
- vnode <n7>, and job should run
- taking vnode <n7>, but on pbsnodes listing,
- notice that the vnode's state is still "free"
- and using 1 cpu and 1gb of memory. It's because
- there's still 1 cpu and 1 gb of memory left to
- use in vnode <n7>.
- """
- jid = self.create_and_submit_job('job11x')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job11x_select,
- 'Resource_List.place': self.job11x_place,
- 'schedselect': self.job11x_schedselect,
- 'exec_host': self.job11x_exec_host,
- 'exec_vnode': self.job11x_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5, self.n7],
- 'job-exclusive', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-exclusive', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # temporarily suspend momC, prevents from operating on released nodes
- self.momC.signal("-STOP")
- # Run pbs_release_nodes on nodes belonging to momB and momC
- cmd = [self.pbs_release_nodes_cmd, '-j', jid,
- self.n4, self.n5, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # mom hostB and mom hostC continue to hold on to the job
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # since not all vnodes from momB have been freed from the job,
- # DELETE_JOB2 request from MS is not sent
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # since node <n7> from mom hostC has not been freed from the job
- # since mom is currently stopped, the DELETE_JOB2 request from
- # MS is not sent
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- sel_esc = self.job11x_select.replace("+", "\+")
- exec_host_esc = self.job11x_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job11x_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:ncpus=1"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job11x_exec_host.replace(
- "+%s/0" % (self.n7,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job11x_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n5), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=1:mem=1048576kb)" % (self.n7,), "")
- new_exec_vnode_esc = new_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job11x_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode},
- id=jid)
- # Though the job is listed with ncpus=4 taking away released vnode
- # <n4> (1 cpu), <n5> (1 cpu), <n7> (1 cpu),
- # hostB hasn't released job because <n6> is still part of the job and
- # <n7> hasn't been released because the mom is stopped.
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5,
- self.n7], 'job-exclusive', jobs_assn1, 1,
- '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-exclusive', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'},
- id="workq")
- # submit a new job needing node <n7>, which is still currently tied
- # to the previous job.
- jid2 = self.create_and_submit_job('job12')
- # we expect job_state to be Queued as the previous job still has
- # vnode managed by hostC assigned exclusively.
- self.server.expect(JOB, 'comment', op=SET, id=jid2)
- self.server.expect(JOB, {'job_state': 'Q'}, id=jid2)
- self.server.delete(jid2)
- # now suspend previous job
- self.server.sigjob(jid, 'suspend')
- a = {'job_state': 'S'}
- self.server.expect(JOB, a, id=jid)
- # server's license_count used is 0 since job is suspended.
- self.license_count_match(0)
- self.match_vnode_status([self.n0, self.n1, self.n2, self.n3,
- self.n4, self.n5, self.n6, self.n7,
- self.n8, self.n9, self.n10], 'free')
- # check server's resources_assigned values
- self.server.expect(SERVER, {'resources_assigned.ncpus': 0,
- 'resources_assigned.mem': '0kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 0,
- 'resources_assigned.mem': '0kb'},
- id="workq")
- # now resume previous job
- self.server.sigjob(jid, 'resume')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job11x_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode},
- id=jid)
- # Since job was resumed, the license count goes back to the same
- # number before job was suspended.
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5,
- self.n7], 'job-exclusive', jobs_assn1, 1,
- '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-exclusive', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'},
- id="workq")
- # resume momC
- self.momC.signal("-CONT")
- # With momC resumed, it now receives DELETE_JOB2 request from
- # MS
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20)
- # with mom on hostC resumed from its stopped state, then the
- # the released node <n7>'s 1 cpu license is finally freed
- # bringing the license count value to = 7 (previous value) - 1
- self.license_count_match(6)
- # submit this 1 cpu job that requests specifically vnode <n7>
- jid3 = self.create_and_submit_job('job12')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '1gb',
- 'Resource_List.ncpus': 1,
- 'Resource_List.nodect': 1,
- 'Resource_List.select': self.job12_select,
- 'Resource_List.place': self.job12_place,
- 'schedselect': self.job12_schedselect,
- 'exec_host': self.job12_exec_host,
- 'exec_vnode': self.job12_exec_vnode},
- id=jid3, max_attempts=3)
- # total license = 6 (previous value) + 1 for job 'jid3'
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-exclusive', jobs_assn1, 1,
- '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-exclusive', jobs_assn1, 1, '0kb')
- # Node <n7> shows as free since job 'jid3' did not request
- # exclusive access.
- jobs_assn2 = "%s/0" % (jid3,)
- self.match_vnode_status([self.n7], 'free', jobs_assn2,
- 1, '1048576kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'},
- id="workq")
- def test_release_nodes_excl_server_restart_quick(self):
- """
- Test:
- Test having a job submitted with exclusive
- placement (-l place=scatter:excl),
- then release a node from it where parent
- mom is stopped, before stopping the
- server with qterm -t quick which
- will leave the job running, and when
- server is started in warm mode where
- also previous job retains its state,
- job continues to have previous node
- assignment including the pending
- released node.
- Given a job submitted with a select spec of
- 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter:excl", resulting in an:
- exec_vnode=
- (<n1>+<n2><n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Then stop parent mom host of <n7> (kill -STOP), now issue:
- pbs_release_nodes -j <job-id> <n4> <n5> <n7>
- causing <n4>, <n5>, and <n7> to still be tied to the job
- as there's still node <n6> tied to the job as part of mom
- hostB, which satisfies the second super-chunk.
- Node <n7> is still assigned to the job as parent
- mom hostC has been stopped.
- Do a qterm -t quick, which will leave the job
- running.
- Now start pbs_server in default warm mode where all
- running jobs are retained in that state including
- their node assignments.
- The job is restored to the same nodes assignment
- as before taking into account the released nodes.
- Now resume the mom of <n7> (kill -CONT). This mom would
- tell server to free up node <n7> as first job has
- been completely removed from the node.
- """
- jid = self.create_and_submit_job('job11x')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job11x_select,
- 'Resource_List.place': self.job11x_place,
- 'schedselect': self.job11x_schedselect,
- 'exec_host': self.job11x_exec_host,
- 'exec_vnode': self.job11x_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5, self.n7],
- 'job-exclusive', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-exclusive', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # temporarily suspend momC, prevents from operating on released nodes
- self.momC.signal("-STOP")
- # Run pbs_release_nodes on nodes belonging to momB and momC
- cmd = [self.pbs_release_nodes_cmd, '-j', jid,
- self.n4, self.n5, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # mom hostB and mom hostC continuue to hold on to the job
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # since not all vnodes from momB have been freed from the job,
- # DELETE_JOB2 request from MS is not sent
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # since node <n7> from mom hostC has not been freed from the job
- # since mom is currently stopped, the DELETE_JOB2 request from
- # MS is not sent
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- sel_esc = self.job11x_select.replace("+", "\+")
- exec_host_esc = self.job11x_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job11x_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:ncpus=1"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job11x_exec_host.replace(
- "+%s/0" % (self.n7,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job11x_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n5), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=1:mem=1048576kb)" % (self.n7,), "")
- new_exec_vnode_esc = new_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job11x_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode},
- id=jid)
- # Though the job is listed with ncpus=4 taking away released vnode
- # <n4> (1 cpu), <n5> (1 cpu), <n7> (1 cpu),
- # hostB hasn't released job because <n6> is still part of the job and
- # <n7> hasn't been released because the mom is stopped.
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5,
- self.n7], 'job-exclusive', jobs_assn1, 1,
- '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-exclusive', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'},
- id="workq")
- # Stop and Start the server
- om = self.server.get_op_mode()
- self.server.set_op_mode(PTL_CLI)
- self.server.qterm(manner="quick")
- self.server.set_op_mode(om)
- self.assertFalse(self.server.isUp())
- self.server.start()
- self.assertTrue(self.server.isUp())
- # Job should have the same state as before
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job11x_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode},
- id=jid)
- # Since job was resumed, the license count goes back to the same
- # number before job was suspended.
- self.logger.info("sleep for 10 secs while server relicense job")
- time.sleep(10)
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-exclusive', jobs_assn1, 1,
- '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-exclusive', jobs_assn1, 1, '0kb')
- # parent mom of <n7> is currently in stopped state
- self.match_vnode_status([self.n7], 'state-unknown,down,job-exclusive',
- jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'},
- id="workq")
- # resume momC
- self.momC.signal("-CONT")
- # With momC resumed, it now receives DELETE_JOB2 request from
- # MS
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20)
- # with mom on hostC resumed from its stopped state, then the
- # the released node <n7>'s 1 cpu license is finally freed
- # bringing the license count value to = 7 (previous value) - 1
- self.license_count_match(6)
- def test_release_nodes_excl_server_restart_immed(self):
- """
- Test:
- Test having a job submitted with exclusive
- placement (-l place=scatter:excl),
- then release a node from it where parent
- mom is stopped, before stopping the
- server with qterm -t immediate which
- will requeue job completely, and when
- server is started, job gets assigned
- the vnodes from the original request
- before the pbs_release_nodes call.
- Given a job submitted with a select spec of
- 2 super-chunks of ncpus=3 and mem=2gb each,
- and 1 chunk of ncpus=2 and mem=2gb, along with
- place spec of "scatter:excl", resulting in an:
- exec_vnode=
- (<n1>+<n2><n3>)+(<n4>+<n5>+<n6>)+(<n7>)
- Then stop parent mom host of <n7> (kill -STOP), now issue:
- pbs_release_nodes -j <job-id> <n4> <n5> <n7>
- causing <n4>, <n5>, and <n7> to still be tied to the job
- as there's still node <n6> tied to the job sd part of mom
- hostB, which satisfies the second super-chunk.
- Node <n7> is still assigned to the job as parent
- mom hostC has been stopped.
- Do a qterm -t immediate, which will requeue the
- currently running job.
- Now start pbs_server.
- The job goes back to getting assigned to the
- original resources, before pbs_releaes_nodes
- was called.
- """
- jid = self.create_and_submit_job('job11x')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job11x_select,
- 'Resource_List.place': self.job11x_place,
- 'schedselect': self.job11x_schedselect,
- 'exec_host': self.job11x_exec_host,
- 'exec_vnode': self.job11x_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5, self.n7],
- 'job-exclusive', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-exclusive', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # temporarily suspend momC, prevents from operating on released nodes
- self.momC.signal("-STOP")
- # Run pbs_release_nodes on nodes belonging to momB and momC
- cmd = [self.pbs_release_nodes_cmd, '-j', jid,
- self.n4, self.n5, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # mom hostB and mom hostC continuue to hold on to the job
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # since not all vnodes from momB have been freed from the job,
- # DELETE_JOB2 request from MS is not sent
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # since node <n7> from mom hostC has not been freed from the job
- # since mom is currently stopped, the DELETE_JOB2 request from
- # MS is not sent
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- sel_esc = self.job11x_select.replace("+", "\+")
- exec_host_esc = self.job11x_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job11x_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:ncpus=1"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job11x_exec_host.replace(
- "+%s/0" % (self.n7,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job11x_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n5), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=1:mem=1048576kb)" % (self.n7,), "")
- new_exec_vnode_esc = new_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job11x_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode},
- id=jid)
- # Though the job is listed with ncpus=4 taking away released vnode
- # <n4> (1 cpu), <n5> (1 cpu), <n7> (1 cpu),
- # hostB hasn't released job because <n6> is still part of the job and
- # <n7> hasn't been released because the mom is stopped.
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5,
- self.n7], 'job-exclusive', jobs_assn1, 1,
- '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-exclusive', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'},
- id="workq")
- # Stop and Start the server
- om = self.server.get_op_mode()
- self.server.set_op_mode(PTL_CLI)
- self.server.qterm(manner="immediate")
- self.server.set_op_mode(om)
- self.assertFalse(self.server.isUp())
- # resume momC, but this is a stale request (nothing happens)
- # since server is down.
- self.momC.signal("-CONT")
- # start the server again
- self.server.start()
- self.assertTrue(self.server.isUp())
- # make sure job is now running with assigned resources
- # from the original request
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job11x_select,
- 'Resource_List.place': self.job11x_place,
- 'schedselect': self.job11x_schedselect,
- 'exec_host': self.job11x_exec_host,
- 'exec_vnode': self.job11x_exec_vnode}, id=jid)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5,
- self.n7], 'job-exclusive', jobs_assn1, 1,
- '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-exclusive', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'},
- id="workq")
- def test_release_nodes_shared_server_restart_quick(self):
- """
- Test:
- Like test_release_nodes_excl_server_restart_quick test
- except the job submitted does not have exclusive
- placement, simply -l place=scatter.
- The results are the same, except the vnode states
- are either "job-busy" or "free" when there are resources
- still available to share.
- """
- jid = self.create_and_submit_job('job11')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job11_select,
- 'Resource_List.place': self.job11_place,
- 'schedselect': self.job11_schedselect,
- 'exec_host': self.job11_exec_host,
- 'exec_vnode': self.job11_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- # node <n7> is free since there's still 1 ncpus and 1 gb
- # that can be shared with other jobs
- self.match_vnode_status([self.n7], 'free', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # temporarily suspend momC, prevents from operating on released nodes
- self.momC.signal("-STOP")
- # Run pbs_release_nodes on nodes belonging to momB and momC
- cmd = [self.pbs_release_nodes_cmd, '-j', jid,
- self.n4, self.n5, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # mom hostB and mom hostC continuue to hold on to the job
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # since not all vnodes from momB have been freed from the job,
- # DELETE_JOB2 request from MS is not sent
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # since node <n7> from mom hostC has not been freed from the job
- # since mom is currently stopped, the DELETE_JOB2 request from
- # MS is not sent
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- sel_esc = self.job11_select.replace("+", "\+")
- exec_host_esc = self.job11_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job11_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:ncpus=1"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job11_exec_host.replace(
- "+%s/0" % (self.n7,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job11_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=1:mem=1048576kb)" % (self.n7,), "")
- new_exec_vnode_esc = new_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job11_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode},
- id=jid)
- # Though the job is listed with ncpus=4 taking away released vnode
- # <n4> (1 cpu), <n5> (1 cpu), <n7> (1 cpu),
- # hostB hasn't released job because <n6> is still part of the job and
- # <n7> hasn't been released because the mom is stopped.
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1,
- '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- # node <n7> is free since there's still 1 ncpus and 1 gb
- # that can be shared with other jobs
- self.match_vnode_status([self.n7], 'free', jobs_assn1,
- 1, '1048576kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'},
- id="workq")
- # Stop and Start the server
- om = self.server.get_op_mode()
- self.server.set_op_mode(PTL_CLI)
- self.server.qterm(manner="quick")
- self.server.set_op_mode(om)
- self.assertFalse(self.server.isUp())
- self.server.start()
- self.assertTrue(self.server.isUp())
- # Job should have the same state as before
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job11_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode},
- id=jid)
- # Since job was resumed, the license count goes back to the same
- # number before job was suspended.
- self.logger.info("sleep for 10 secs while server relicense job")
- time.sleep(10)
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1,
- '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- # parent mom of <n7> is currently in stopped state
- self.match_vnode_status([self.n7], 'state-unknown,down', jobs_assn1,
- 1, '1048576kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'},
- id="workq")
- # resume momC
- self.momC.signal("-CONT")
- # With momC resumed, it now receives DELETE_JOB2 request from
- # MS
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20)
- # with mom on hostC resumed from its stopped state, then the
- # the released node <n7>'s 1 cpu license is finally freed
- # bringing the license count value to = 7 (previous value) - 1
- self.license_count_match(6)
- def test_release_nodes_shared_server_restart_immed(self):
- """
- Test:
- Like test_release_nodes_excl_server_restart_quick test
- except the job submitted does not have exclusive
- placement, simply -l place=scatter.
- The results are the same, except the vnode states
- are either "job-busy" or "free" when there are resources
- still available to share.
- """
- jid = self.create_and_submit_job('job11')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job11_select,
- 'Resource_List.place': self.job11_place,
- 'schedselect': self.job11_schedselect,
- 'exec_host': self.job11_exec_host,
- 'exec_vnode': self.job11_exec_vnode}, id=jid)
- # server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- # node <n7> still has resources (ncpus=1, mem=1gb) to share
- self.match_vnode_status([self.n7], 'free', jobs_assn1,
- 1, '1048576kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- # temporarily suspend momC, prevents from operating on released nodes
- self.momC.signal("-STOP")
- # Run pbs_release_nodes on nodes belonging to momB and momC
- cmd = [self.pbs_release_nodes_cmd, '-j', jid,
- self.n4, self.n5, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # mom hostB and mom hostC continuue to hold on to the job
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostC), n=10,
- regexp=True,
- existence=False, max_attempts=5, interval=1)
- # since not all vnodes from momB have been freed from the job,
- # DELETE_JOB2 request from MS is not sent
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # since node <n7> from mom hostC has not been freed from the job
- # since mom is currently stopped, the DELETE_JOB2 request from
- # MS is not sent
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- existence=False, max_attempts=5, interval=1)
- # Verify remaining job resources.
- sel_esc = self.job11_select.replace("+", "\+")
- exec_host_esc = self.job11_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job11_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:ncpus=1"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job11_exec_host.replace(
- "+%s/0" % (self.n7,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job11_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=1:mem=1048576kb)" % (self.n7,), "")
- new_exec_vnode_esc = new_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- # job's substate is 41 (PRERUN) since MS mom is stopped
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '2gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job11_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode},
- id=jid)
- # Though the job is listed with ncpus=4 taking away released vnode
- # <n4> (1 cpu), <n5> (1 cpu), <n7> (1 cpu),
- # hostB hasn't released job because <n6> is still part of the job and
- # <n7> hasn't been released because the mom is stopped.
- self.license_count_match(7)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1,
- '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- # node <n7> still has resources (ncpus=1, mem=1gb) to share
- self.match_vnode_status([self.n7], 'free', jobs_assn1,
- 1, '1048576kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'},
- id="workq")
- # Stop and Start the server
- om = self.server.get_op_mode()
- self.server.set_op_mode(PTL_CLI)
- self.server.qterm(manner="immediate")
- self.server.set_op_mode(om)
- self.assertFalse(self.server.isUp())
- # resume momC, but this is a stale request (nothing happens)
- # since server is down.
- self.momC.signal("-CONT")
- # start the server again
- self.server.start()
- self.assertTrue(self.server.isUp())
- # make sure job is now running with assigned resources
- # from the original request
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job11_select,
- 'Resource_List.place': self.job11_place,
- 'schedselect': self.job11_schedselect,
- 'exec_host': self.job11_exec_host,
- 'exec_vnode': self.job11_exec_vnode}, id=jid)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1,
- '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- # node <n7> still has resources (ncpus=1, mem=1gb) to share
- self.server.expect(VNODE, {'state': 'free',
- 'jobs': jobs_assn1,
- 'resources_assigned.ncpus': 1,
- 'resources_assigned.mem': '1048576kb'},
- id=self.n7)
- self.match_vnode_status([self.n7], 'free', jobs_assn1,
- 1, '1048576kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 7,
- 'resources_assigned.mem': '5242880kb'},
- id="workq")
- def test_release_mgr_oper(self):
- """
- Test that nodes are getting released as manager and operator
- """
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- manager = str(MGR_USER) + '@*'
- self.server.manager(MGR_CMD_SET, SERVER,
- {'managers': (INCR, manager)},
- sudo=True)
- operator = str(OPER_USER) + '@*'
- self.server.manager(MGR_CMD_SET, SERVER,
- {'operators': (INCR, operator)},
- sudo=True)
- # Release hostC as manager
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=MGR_USER)
- self.assertEqual(ret['rc'], 0)
- # Only mom hostC will get the job summary it was released
- # early courtesy of sole vnode <n7>.
- self.momA.log_match(
- "Job;%s;%s.+cput=.+ mem=.+" % (jid, self.hostC), n=10,
- regexp=True)
- # Only mom hostC will get the IM_DELETE_JOB2 request
- self.momC.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20)
- # Release vnodes from momB as operator
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n5, self.n6]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=OPER_USER)
- self.assertEqual(ret['rc'], 0)
- # momB's host will not get job summary reported
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- jid, self.hostB), n=10, regexp=True, max_attempts=5,
- existence=False, interval=1)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid,), n=20,
- max_attempts=5, existence=False, interval=1)
- # Verify remaining job resources.
- sel_esc = self.job1_select.replace("+", "\+")
- exec_host_esc = self.job1_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- exec_vnode_esc = self.job1_exec_vnode.replace("[", "\[").replace(
- "]", "\]").replace("(", "\(").replace(")", "\)").replace("+", "\+")
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=1048576kb:ncpus=1"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_exec_host.replace(
- "+%s/0*2" % (self.n7,), "")
- new_exec_host_esc = new_exec_host.replace(
- "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "+%s:mem=1048576kb:ncpus=1" % (self.n5,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+%s:ncpus=1" % (self.n6,), "")
- new_exec_vnode = new_exec_vnode.replace(
- "+(%s:ncpus=2:mem=2097152kb)" % (self.n7,), "")
- new_exec_vnode_esc = \
- new_exec_vnode.replace("[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '3gb',
- 'Resource_List.ncpus': 4,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Though the job is listed with ncpus=4 taking away released vnode
- # <n5> (1 cpu), <n6> (1 cpu), <n7> (2 cpus),
- # only <n7> got released. <n5> and <n6> are part of a super
- # chunk that wasn't fully released.
- self.license_count_match(6)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, new_exec_host_esc,
- new_exec_vnode_esc, "3145728kb",
- 4, 2, self.job1_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (jid,)
- # <n5> still job-busy
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- # <n6> still job-busy
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- # <n7> now free
- self.match_vnode_status([self.n0, self.n7, self.n8, self.n9, self.n10],
- 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 6,
- 'resources_assigned.mem': '4194304kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(jid, new_exec_host))
- self.server.delete(jid)
- # Check account phased end ('e') record
- self.match_accounting_log('e', jid, new_exec_host_esc,
- new_exec_vnode_esc,
- "3145728kb", 4, 2,
- self.job1_place,
- newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- self.match_accounting_log('E', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb",
- 8, 3, self.job1_place, self.job1_sel_esc)
- def test_release_job_array(self):
- """
- Release vnodes from a job array and subjob
- """
- jid = self.create_and_submit_job('jobA')
- self.server.expect(JOB, {'job_state': 'B',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect}, id=jid)
- # Release nodes from job array. It will fail
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4]
- try:
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- except PtlExceptions as e:
- self.assertTrue("not supported for Array jobs" in e.msg)
- self.assertFalse(e.rc)
- # Verify the same for subjob1
- subjob1 = jid.replace('[]', '[1]')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode},
- id=subjob1)
- # Server's license_count used value matches job's 'ncpus' value.
- self.license_count_match(8)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (subjob1,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6],
- 'job-busy', jobs_assn1, 1, '0kb')
- jobs_assn2 = "%s/0, %s/1" % (subjob1, subjob1)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(subjob1, self.job1_exec_host))
- # Run pbs_release_nodes as root
- cmd = [self.pbs_release_nodes_cmd, '-j', subjob1, self.n4]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertEqual(ret['rc'], 0)
- # Verify mom_logs
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- subjob1, self.hostB), n=10,
- regexp=True,
- max_attempts=5,
- existence=False, interval=1)
- self.momA.log_match("Job;%s;%s.+cput=.+ mem=.+" % (
- subjob1, self.hostC), n=10,
- regexp=True, max_attempts=5,
- existence=False, interval=1)
- # momB's host will not get DELETE_JOB2 request since
- # not all its vnodes have been released yet from the job.
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (subjob1,),
- n=20, max_attempts=5,
- existence=False, interval=1)
- # Verify remaining job resources.
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=1048576kb:ncpus=2+" + \
- "1:ncpus=2:mem=2097152kb"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_host = self.job1_exec_host
- # Below variable is being used for the accounting log match
- # which is currently blocked on PTL bug PP-596.
- # new_exec_host_esc = self.job1_exec_host.replace(
- # "*", "\*").replace("[", "\[").replace("]", "\]").replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode_esc = new_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': new_exec_vnode}, id=subjob1)
- # Though the job is listed with ncpus=7 taking away released vnode
- # <n4>, it's coming from a super-chunk where other vnodes <n5> and
- # <n6> are still assigned to the job. So the parent mom of <n4>
- # till won't release the job and thus, the 1 license for it is still
- # allocated.
- self.license_count_match(8)
- # BELOW IS CODE IS BLOCEKD ON PP-596
- # Check account update ('u') record
- # self.match_accounting_log('u', subjob1, self.job1_exec_host_esc,
- # self.job1_exec_vnode_esc, "6gb", 8, 3,
- # self.job1_place,
- # self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- # self.match_accounting_log('c', subjob1, self.job1_exec_host_esc,
- # new_exec_vnode_esc, "5242880kb",
- # 7, 3, self.job1_place, newsel_esc)
- # Check various vnode status.
- jobs_assn1 = "%s/0" % (subjob1,)
- self.match_vnode_status([self.n1, self.n2, self.n4, self.n5],
- 'job-busy', jobs_assn1, 1, '1048576kb')
- self.match_vnode_status([self.n3, self.n6], 'job-busy', jobs_assn1, 1,
- '0kb')
- jobs_assn2 = "%s/0, %s/1" % (subjob1, subjob1)
- self.match_vnode_status([self.n7], 'job-busy', jobs_assn2,
- 2, '2097152kb')
- self.match_vnode_status([self.n0, self.n8, self.n9, self.n10], 'free')
- self.server.expect(SERVER, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'})
- self.server.expect(QUEUE, {'resources_assigned.ncpus': 8,
- 'resources_assigned.mem': '6291456kb'},
- id="workq")
- self.assertTrue(
- self.pbs_nodefile_match_exec_host(subjob1, new_exec_host))
- self.server.delete(subjob1)
- # Check account phased end ('e') record
- # self.match_accounting_log('e', subjob1, new_exec_host_esc,
- # new_exec_vnode_esc,
- # "5242880kb", 7, 3,
- # self.job1_place,
- # newsel_esc)
- # Check to make sure 'E' (end of job) record got generated
- # self.match_accounting_log('E', subjob1, self.job1_exec_host_esc,
- # self.job1_exec_vnode_esc, "6gb",
- # 8, 3, self.job1_place, self.job1_sel_esc)
- def test_release_job_states(self):
- """
- Release nodes on jobs in various states; Q, H, S, W
- """
- # Submit a regular job that cannot run
- a = {'Resource_List.ncpus': 100}
- j = Job(TEST_USER, a)
- jid = self.server.submit(j)
- self.server.expect(JOB, {'job_state': 'Q'}, id=jid)
- # Release nodes from a queued job
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertNotEqual(ret['rc'], 0)
- self.server.delete(jid, wait=True)
- # Submit a held job and try releasing the node
- j1 = Job(TEST_USER, {ATTR_h: None})
- jid1 = self.server.submit(j1)
- self.server.expect(JOB, {'job_state': 'H'}, id=jid1)
- cmd = [self.pbs_release_nodes_cmd, '-j', jid1, self.n4]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertNotEqual(ret['rc'], 0)
- self.server.delete(jid1, wait=True)
- # Submit a job in W state and try releasing the node
- mydate = int(time.time()) + 120
- mytime = convert_time('%m%d%H%M', str(mydate))
- j2 = Job(TEST_USER, {ATTR_a: mytime})
- jid2 = self.server.submit(j2)
- self.server.expect(JOB, {'job_state': 'W'}, id=jid2)
- cmd = [self.pbs_release_nodes_cmd, '-j', jid2, self.n4]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertNotEqual(ret['rc'], 0)
- self.server.delete(jid2, wait=True)
- def test_release_finishjob(self):
- """
- Test that releasing vnodes on finished jobs will fail
- also verify the updated schedselect on a finished job
- """
- self.server.manager(MGR_CMD_SET, SERVER,
- {'job_history_enable': "true"}, sudo=True)
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': "R"}, id=jid)
- # Release hostC
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd)
- self.assertEqual(ret['rc'], 0)
- # Submit another job and make sure it is
- # picked up by hostC
- j = Job(TEST_USER,
- {'Resource_List.select': "1:host=" + self.hostC})
- jid2 = self.server.submit(j)
- ehost = self.hostC + "/1"
- self.server.expect(JOB, {'job_state': "R",
- "exec_host": ehost}, id=jid2)
- self.server.delete(jid, wait=True)
- # Release vnode4 from a finished job. It will throw error.
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4]
- ret = self.server.du.run_cmd(self.server.hostname, cmd)
- self.assertNotEqual(ret['rc'], 0)
- # Verify the schedselect for a finished job
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=2097152kb:ncpus=3"
- new_exec_host = "%s/0*0+%s/0*0" % (self.n0, self.hostB)
- new_exec_vnode = self.job1_exec_vnode.replace(
- "+(%s:ncpus=2:mem=2097152kb)" % (self.n7,), "")
- self.server.expect(JOB, {'job_state': 'F',
- 'Resource_List.mem': '4194304kb',
- 'Resource_List.ncpus': 6,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 2,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode},
- extend='x', id=jid)
- def test_release_suspendjob(self):
- """
- Test that releasing nodes on suspended job will also
- fail and schedselect will not change
- """
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n4]
- ret = self.server.du.run_cmd(self.server.hostname, cmd)
- self.assertEqual(ret['rc'], 0)
- # Verify remaining job resources
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=1048576kb:ncpus=2+" + \
- "1:ncpus=2:mem=2097152kb"
- new_exec_vnode = self.job1_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Suspend the job with qsig
- self.server.sigjob(jid, 'suspend', runas=ROOT_USER)
- self.server.expect(JOB, {'job_state': 'S'}, id=jid)
- # Try releasing a node from suspended job
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- sudo=True)
- self.assertNotEqual(ret['rc'], 0)
- # Verify that resources won't change
- self.server.expect(JOB, {'job_state': 'S',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- # Release the job and make sure it is running
- self.server.sigjob(jid, 'resume')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
- @timeout(500)
- def test_release_multi_jobs(self):
- """
- Release vnodes when multiple jobs are present
- """
- # Delete the vnodes and recreate them
- self.momA.delete_vnode_defs()
- self.momB.delete_vnode_defs()
- self.momA.restart()
- self.momB.restart()
- self.server.manager(MGR_CMD_DELETE, NODE, None, "")
- self.server.manager(MGR_CMD_CREATE, NODE, id=self.hostA)
- self.server.manager(MGR_CMD_CREATE, NODE, id=self.hostB)
- self.server.manager(MGR_CMD_CREATE, NODE, id=self.hostC)
- self.server.manager(MGR_CMD_SET, NODE,
- {'resources_available.ncpus': 3},
- id=self.hostA)
- self.server.manager(MGR_CMD_SET, NODE,
- {'resources_available.ncpus': 3},
- id=self.hostB)
- self.server.manager(MGR_CMD_SET, NODE,
- {'resources_available.ncpus': 3},
- id=self.hostC)
- # Submit multiple jobs
- jid1 = self.create_and_submit_job('job13')
- jid2 = self.create_and_submit_job('job13')
- jid3 = self.create_and_submit_job('job13')
- e_host_j1 = self.hostA + "/0+" + self.hostB + "/0+" + self.hostC + "/0"
- e_host_j2 = self.hostA + "/1+" + self.hostB + "/1+" + self.hostC + "/1"
- e_host_j3 = self.hostA + "/2+" + self.hostB + "/2+" + self.hostC + "/2"
- e_vnode = "(%s:ncpus=1)+(%s:ncpus=1)+(%s:ncpus=1)" \
- % (self.hostA, self.hostB, self.hostC)
- self.server.expect(JOB, {"job_state=R": 3})
- self.server.expect(JOB, {"exec_host": e_host_j1,
- "exec_vnode": e_vnode}, id=jid1)
- self.server.expect(JOB, {"exec_host": e_host_j2,
- "exec_vnode": e_vnode}, id=jid2)
- self.server.expect(JOB, {"exec_host": e_host_j3,
- "exec_vnode": e_vnode}, id=jid3)
- # Verify that 3 processes running on hostB
- n = retry = 5
- for _ in range(n):
- process = 0
- self.server.pu.get_proc_info(
- self.momB.hostname, ".*fib.*", None, regexp=True)
- if (self.server.pu.processes is not None):
- for key in self.server.pu.processes:
- if ("fib" in key):
- process = len(self.server.pu.processes[key])
- self.logger.info(
- "length of the process is " + str(process) +
- ", expected 3")
- if process == 3:
- break
- retry -= 1
- if retry == 0:
- raise AssertionError("not found 3 fib processes")
- self.logger.info("sleeping 3 secs before next retry")
- time.sleep(3)
- # Release node2 from job1 only
- cmd = [self.pbs_release_nodes_cmd, '-j', jid1, self.hostB]
- ret = self.server.du.run_cmd(self.server.hostname, cmd,
- runas=TEST_USER)
- self.assertEqual(ret['rc'], 0)
- self.momB.log_match("Job;%s;DELETE_JOB2 received" % (jid1,),
- max_attempts=18, interval=2)
- # Verify that only 2 process left on hostB now
- process = 0
- self.server.pu.get_proc_info(
- self.momB.hostname, ".*fib.*", None, regexp=True)
- if (self.server.pu.processes is not None):
- for key in self.server.pu.processes:
- if ("fib" in key):
- process = len(self.server.pu.processes[key])
- print "length of the process is %d " % (process,)
- self.assertEqual(process, 2)
- # Mom logs only have message for job1 for node3
- self.momA.log_match(
- "Job;%s;%s.+cput=.+mem.+" % (jid1, self.hostB),
- max_attempts=18, interval=2, regexp=True)
- self.momA.log_match(
- "Job;%s;%s.+cput=.+mem.+" % (jid2, self.hostB),
- max_attempts=5, regexp=True,
- existence=False, interval=1)
- self.momA.log_match(
- "Job;%s;%s.+cput=.+mem.+" % (jid3, self.hostB),
- max_attempts=5, regexp=True,
- existence=False, interval=1)
- # Verify the new schedselect for job1
- new_e_host_j1 = e_host_j1.replace("+%s/0" % (self.hostB,), "")
- new_e_vnode = e_vnode.replace("+(%s:ncpus=1)" % (self.hostB,), "")
- self.server.expect(JOB, {'job_state': "R",
- "exec_host": new_e_host_j1,
- "exec_vnode": new_e_vnode,
- "schedselect": "1:ncpus=1+1:ncpus=1",
- "Resource_List.ncpus": 2,
- "Resource_List.nodect": 2}, id=jid1)
- # Verify that host and vnode won't change for job2 and job3
- self.server.expect(JOB, {'job_state': "R",
- "exec_host": e_host_j2,
- "exec_vnode": e_vnode,
- "Resource_List.nodect": 3}, id=jid2)
- self.server.expect(JOB, {'job_state': 'R',
- "exec_host": e_host_j3,
- "exec_vnode": e_vnode,
- "Resource_List.nodect": 3}, id=jid3)
- def test_PBS_JOBID(self):
- """
- Test that if -j jobid is not provided then it is
- picked by env variable $PBS_JOBID in job script
- """
- # This one has a job script that calls 'pbs_release_nodes'
- # (no jobid specified)
- jid = self.create_and_submit_job('job1_6')
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '6gb',
- 'Resource_List.ncpus': 8,
- 'Resource_List.nodect': 3,
- 'Resource_List.select': self.job1_select,
- 'Resource_List.place': self.job1_place,
- 'schedselect': self.job1_schedselect,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': self.job1_exec_vnode}, id=jid)
- # Verify remaining job resources
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=1048576kb:ncpus=2+" + \
- "1:ncpus=2:mem=2097152kb"
- newsel_esc = newsel.replace("+", "\+")
- new_exec_vnode = self.job1_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n4,), "")
- new_exec_vnode_esc = new_exec_vnode.replace(
- "[", "\[").replace("]", "\]").replace(
- "(", "\(").replace(")", "\)").replace("+", "\+")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.place': self.job1_place,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': self.job1_exec_host,
- 'exec_vnode': new_exec_vnode},
- id=jid, interval=1, max_attempts=30)
- # Check account update ('u') record
- self.match_accounting_log('u', jid, self.job1_exec_host_esc,
- self.job1_exec_vnode_esc, "6gb", 8, 3,
- self.job1_place,
- self.job1_sel_esc)
- # Check to make sure 'c' (next) record got generated
- self.match_accounting_log('c', jid, self.job1_exec_host_esc,
- new_exec_vnode_esc, "5242880kb",
- 7, 3, self.job1_place, newsel_esc)
- def test_release_nodes_on_stageout_diffvalues(self):
- """
- Set release_nodes_on_stageout to different values other than
- true or false
- """
- a = {ATTR_W: "release_nodes_on_stageout=-1"}
- j = Job(TEST_USER, a)
- try:
- self.server.submit(j)
- except PtlException as e:
- self.assertTrue("illegal -W value" in e.msg[0])
- a = {ATTR_W: "release_nodes_on_stageout=11"}
- j = Job(TEST_USER, a)
- try:
- self.server.submit(j)
- except PtlException as e:
- self.assertTrue("illegal -W value" in e.msg[0])
- a = {ATTR_W: "release_nodes_on_stageout=tru"}
- j = Job(TEST_USER, a)
- try:
- self.server.submit(j)
- except PtlException as e:
- self.assertTrue("illegal -W value" in e.msg[0])
- def test_resc_accumulation(self):
- """
- Test that resources gets accumulated when a mom is released
- """
- # skip this test due to PP-972
- self.skip_test(reason="Test fails due to PP-972")
- self.server.manager(MGR_CMD_SET, SERVER,
- {'job_history_enable': "true"}, sudo=True)
- # Create custom resources
- attr = {}
- attr['type'] = 'float'
- attr['flag'] = 'nh'
- r = 'foo_f'
- self.server.manager(
- MGR_CMD_CREATE, RSC, attr, id=r, runas=ROOT_USER, logerr=False)
- attr1 = {}
- attr1['type'] = 'size'
- attr1['flag'] = 'nh'
- r1 = 'foo_i'
- self.server.manager(
- MGR_CMD_CREATE, RSC, attr1, id=r1, runas=ROOT_USER, logerr=False)
- hook_body = """
- import pbs
- e=pbs.event()
- pbs.logmsg(pbs.LOG_DEBUG, "executed epilogue hook")
- if e.job.in_ms_mom():
- e.job.resources_used["vmem"] = pbs.size("9gb")
- e.job.resources_used["foo_i"] = pbs.size(999)
- e.job.resources_used["foo_f"] = 0.09
- else:
- e.job.resources_used["vmem"] = pbs.size("10gb")
- e.job.resources_used["foo_i"] = pbs.size(1000)
- e.job.resources_used["foo_f"] = 0.10
- """
- hook_name = "epi"
- a = {'event': "execjob_epilogue", 'enabled': 'True'}
- rv = self.server.create_import_hook(
- hook_name,
- a,
- hook_body,
- overwrite=True)
- self.assertTrue(rv)
- jid = self.create_and_submit_job('job1_5')
- self.server.expect(JOB, {'job_state': "R"}, id=jid)
- # Release hostC
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n7]
- ret = self.server.du.run_cmd(self.server.hostname, cmd)
- self.assertEqual(ret['rc'], 0)
- self.momC.log_match("executed epilogue hook", max_attempts=10)
- self.momC.log_match("DELETE_JOB2 received", max_attempts=10)
- self.server.delete(jid, wait=True)
- self.server.expect(JOB, {'job_state': 'F',
- "resources_used.foo_i": "3kb",
- "resources_used.foo_f": '0.29',
- "resources_used.vmem": '29gb'}, id=jid)
- @timeout(500)
- def test_release_reservations(self):
- """
- Release nodes from a reservation will throw error. However
- jobs inside reservation queue works as expected.
- """
- # Create a reservation on multiple nodes
- start = int(time.time()) + 30
- a = {'Resource_List.select': self.job1_select,
- 'Resource_List.place': 'scatter',
- 'reserve_start': start}
- r = Reservation(TEST_USER, a)
- rid = self.server.submit(r)
- rid = rid.split('.')[0]
- self.server.expect(RESV,
- {'reserve_state': (MATCH_RE, "RESV_CONFIRMED|2")},
- id=rid)
- # Release a vnode from reservation. It will throw error.
- cmd = [self.pbs_release_nodes_cmd, '-j', rid, self.n5]
- r = self.server.du.run_cmd(self.server.hostname, cmd)
- self.assertNotEqual(r['rc'], 0)
- # Submit a job inside reservations and release vnode
- a = {'queue': rid,
- 'Resource_List.select': self.job1_select}
- j = Job(TEST_USER, a)
- jid = self.server.submit(j)
- # Wait for the job to start
- self.server.expect(JOB, {'job_state': 'R'},
- offset=30, id=jid, max_attempts=30)
- # Release vnodes from the job
- cmd = [self.pbs_release_nodes_cmd, '-j', jid, self.n5]
- r = self.server.du.run_cmd(self.server.hostname, cmd)
- self.assertEqual(r['rc'], 0)
- # Verify the new schedselect
- newsel = "1:mem=2097152kb:ncpus=3+1:mem=1048576kb:ncpus=2+" + \
- "1:ncpus=2:mem=2097152kb"
- new_exec_host = self.job1_exec_host
- new_exec_vnode = self.job1_exec_vnode.replace(
- "%s:mem=1048576kb:ncpus=1+" % (self.n5,), "")
- self.server.expect(JOB, {'job_state': 'R',
- 'Resource_List.mem': '5gb',
- 'Resource_List.ncpus': 7,
- 'Resource_List.select': newsel,
- 'Resource_List.nodect': 3,
- 'schedselect': newsel,
- 'exec_host': new_exec_host,
- 'exec_vnode': new_exec_vnode}, id=jid)
|