3 ##############################
5 ### preparation / requirements
7 ### two separate instances of myplc
8 ### for now they are located on the same box on lurch
11 ### your myplcs should more or less come out of the box,
12 ### I prefer not to alter the default PLC_ROOT_USER value,
13 ### instead we create a PI account on the site_id=1
15 ##############################
21 # support reloading without wiping everything off
22 # dunno how to do (defvar plc)
28 ## we use indexes 1 and 2
38 ## the authentication objects
44 ## the builtin root user for bootstrapping
56 # number of 'system' persons
57 # builtin maint, local root, 2 persons for the peering
59 # among that, 1 gets refreshed - other ones have conflicting names
60 system_persons_cross = 1
62 system_slices_ids = (1,2)
64 return len(system_slices_ids)
66 return number_slices+system_slices()
68 # temporary - the myplc I use doesnt know about 'system' yet
69 def system_slivers ():
70 # return len(system_slices_ids)
73 return number_slices+system_slivers()
76 # set initial conditions
77 def define_test (sites,keys,persons,nodes,slices,fast_mode):
78 global number_sites, number_keys, number_persons, number_nodes, number_slices, fast_flag
81 number_persons=persons
87 print '%d sites, %d keys, %d persons, %d nodes & %d slices'%(
88 number_sites, number_keys,number_persons,number_nodes,number_slices)
91 define_test(1,1,1,1,1,True)
94 define_test (sites=4,keys=2,persons=4,nodes=5,slices=4,fast_mode=False)
98 global number_sites, number_keys, number_persons, number_nodes, number_slices
100 (number_sites,number_keys,number_persons,number_nodes,number_slices) = [
101 big_factor * x for x in (number_sites,number_keys,number_persons,number_nodes,number_slices)]
105 global number_sites, number_keys, number_persons, number_nodes, number_slices
107 (number_sites,number_keys,number_persons,number_nodes,number_slices) = [
108 huge_factor * x for x in (number_sites,number_keys,number_persons,number_nodes,number_slices)]
110 # use fast by default in interactive mode
115 # argh, for login_name that doesn't accept digits
116 plain_numbers=['zero','one','two','three','four','five','six','seven','eight','nine','ten',
117 'eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty']
119 plc1={ 'plcname':'plc1 in federation',
120 'hostname':'lurch.cs.princeton.edu',
121 'url-format':'https://%s:443/PLCAPI/',
122 'builtin-admin-id':'root@plc1.org',
123 'builtin-admin-password':'root',
124 'peer-admin-name':'peer1@planet-lab.org',
125 'peer-admin-password':'peer',
126 'node-format':'n1%02d.plc1.org',
128 'site-format':'one%s',
129 'person-format' : 'user1-%d@plc1.org',
130 'key-format':'ssh-rsa 1111111111111111 user%d-key%d',
131 'person-password' : 'password1',
133 plc2={ 'plcname':'plc2 in federation',
134 'hostname':'planetlab-devbox.inria.fr',
135 'url-format':'https://%s:443/PLCAPI/',
136 'builtin-admin-id':'root@plc2.org',
137 'builtin-admin-password':'root',
138 'peer-admin-name':'peer2@planet-lab.org',
139 'peer-admin-password':'peer',
140 'node-format':'n2%02d.plc2.org',
142 'site-format':'two%s',
143 'person-format' : 'user2-%d@plc2.org',
144 'key-format':'ssh-rsa 2222222222222222 user%d-key%d',
145 'person-password' : 'password2',
153 return plc[i]['plcname']
156 x=site_login_base(i,n)
157 return 'Site fullname '+x
159 def site_login_base (i,n):
160 return plc[i]['site-format']%plain_numbers[n]
162 def person_name (i,n):
163 return plc[i]['person-format']%n
165 def key_name (i,n,k):
166 return plc[i]['key-format']%(n,k)
169 return plc[i]['node-format']%n
172 result=(n%number_sites)
177 def slice_name (i,n):
178 site_index=map_on_site(n)
179 return "%s_slice%d"%(site_login_base(i,site_index),n)
184 # to have indexes start at 1
186 return range (1,n+1,1)
189 print "====================",
194 global epoch,last_time
197 print '+++ timer start'
202 print '+++ %.02f seconds ellapsed (%.02f)'%(now-epoch,now-last_time)
206 def test00_init (args=[1,2]):
209 ## have you loaded this file already (support for reload)
215 url=plc[i]['url-format']%plc[i]['hostname']
217 s[i]=xmlrpclib.ServerProxy(url,allow_none=True)
218 print 'initializing s[%d]'%i,url
219 aa[i]={'Username':plc[i]['builtin-admin-id'],
220 'AuthMethod':'password',
221 'AuthString':plc[i]['builtin-admin-password'],
223 print 'initialized aa[%d]'%i, aa[i]
224 a[i]={'Username':plc[i]['peer-admin-name'],
225 'AuthMethod':'password',
226 'AuthString':plc[i]['peer-admin-password'],
228 print 'initialized a[%d]'%i, a[i]
230 def test00_print (args=[1,2]):
233 print 'aa[%d]'%i, aa[i]
234 print 'a[%d]'%i, a[i]
236 def check_nodes (el,ef,args=[1,2]):
238 # use a single request and sort afterwards for efficiency
239 # could have used GetNodes's scope as well
240 all_nodes = s[i].GetNodes(a[i])
241 n = len ([ x for x in all_nodes if x['peer_id'] is None])
242 f = len ([ x for x in all_nodes if x['peer_id'] is not None])
243 print '%02d: Checking nodes: got %d local (e=%d) & %d foreign (e=%d)'%(i,n,el,f,ef)
247 def check_keys (el,ef,args=[1,2]):
249 # use a single request and sort afterwards for efficiency
250 # could have used GetKeys's scope as well
251 all_keys = s[i].GetKeys(a[i])
252 n = len ([ x for x in all_keys if x['peer_id'] is None])
253 f = len ([ x for x in all_keys if x['peer_id'] is not None])
254 print '%02d: Checking keys: got %d local (e=%d) & %d foreign (e=%d)'%(i,n,el,f,ef)
258 def check_persons (el,ef,args=[1,2]):
260 # use a single request and sort afterwards for efficiency
261 # could have used GetPersons's scope as well
262 all_persons = s[i].GetPersons(a[i])
263 n = len ([ x for x in all_persons if x['peer_id'] is None])
264 f = len ([ x for x in all_persons if x['peer_id'] is not None])
265 print '%02d: Checking persons: got %d local (e=%d) & %d foreign (e=%d)'%(i,n,el,f,ef)
269 # expected : local slices, foreign slices
270 def check_slices (els,efs,args=[1,2]):
272 ls=len(s[i].GetSlices(a[i],{'peer_id':None}))
273 fs=len(s[i].GetSlices(a[i],{'~peer_id':None}))
274 print '%02d: Checking slices: got %d local (e=%d) & %d foreign (e=%d)'%(i,ls,els,fs,efs)
278 def show_nodes (i,node_ids):
280 all_nodes = s[i].GetNodes(a[i],node_ids)
281 loc_nodes = filter (lambda n: n['peer_id'] is None, all_nodes)
282 for_nodes = filter (lambda n: n['peer_id'] is not None, all_nodes)
284 for message,nodes in [ ['LOC',loc_nodes], ['FOR',for_nodes] ] :
286 print '[%s:%d] : '%(message,len(nodes)),
288 print node['hostname']+' ',
291 def check_slice_nodes (expected_nodes, is_local_slice, args=[1,2]):
292 for ns in myrange(number_slices):
293 check_slice_nodes_n (ns,expected_nodes, is_local_slice, args)
295 def check_slice_nodes_n (ns,expected_nodes, is_local_slice, args=[1,2]):
299 sname=slice_name(i,ns)
300 slice=s[i].GetSlices(a[i],{'name':[sname],'peer_id':None})[0]
303 sname=slice_name(peer,ns)
304 slice=s[i].GetSlices(a[i],{'name':[sname],'~peer_id':None})[0]
306 print '%02d: %s slice %s (e=%d) '%(i,message,sname,expected_nodes),
307 slice_node_ids=slice['node_ids']
308 print 'on nodes ',slice_node_ids
309 show_nodes (i,slice_node_ids)
310 assert len(slice_node_ids)>=expected_nodes
311 if len(slice_node_ids) != expected_nodes:
314 # expected : nodes on local slice
315 def check_local_slice_nodes (expected, args=[1,2]):
316 check_slice_nodes(expected,True,args)
318 # expected : nodes on foreign slice
319 def check_foreign_slice_nodes (expected, args=[1,2]):
320 check_slice_nodes(expected,False,args)
322 def check_conf_files (args=[1,2]):
323 for nn in myrange(number_nodes):
324 check_conf_files_n (nn,args)
326 def check_conf_files_n (nn,args=[1,2]):
328 nodename=node_name(i,nn)
329 ndict= s[i].GetSlivers(a[i],[nodename])[0]
330 assert ndict['hostname'] == nodename
331 conf_files = ndict['conf_files']
332 print '%02d: %d conf_files in GetSlivers for node %s'%(i,len(conf_files),nodename)
333 for conf_file in conf_files:
334 print 'source=',conf_file['source'],'|',
335 print 'dest=',conf_file['dest'],'|',
336 print 'enabled=',conf_file['enabled'],'|',
340 pp = pprint.PrettyPrinter(indent=3)
342 def check_slivers (esn,args=[1,2]):
343 for nn in myrange(number_nodes):
344 check_slivers_n (nn,esn,args)
346 # too verbose to check all nodes, let's check only the first one
347 def check_slivers_1 (esn,args=[1,2]):
348 check_slivers_n (1,esn,args)
350 def check_slivers_n (nn,esn,args=[1,2]):
352 nodename=node_name(i,nn)
353 ndict= s[i].GetSlivers(a[i],[nodename])[0]
354 assert ndict['hostname'] == nodename
355 slivers = ndict['slivers']
356 print '%02d: %d slivers (exp. %d) in GetSlivers for node %s'\
357 %(i,len(slivers),esn,nodename)
358 for sliver in slivers:
359 print '>>slivername = ',sliver['name']
360 pretty_printer.pprint(sliver)
361 assert len(slivers) == esn
365 def test00_admin_person (args=[1,2]):
368 email = plc[i]['peer-admin-name']
370 p=s[i].GetPersons(a[i],[email])[0]
371 plc[i]['peer-admin-id']=p['person_id']
373 person_id=s[i].AddPerson(aa[i],{'first_name':'Local',
374 'last_name':'PeerPoint',
377 'password':plc[i]['peer-admin-password']})
378 print '%02d:== created peer admin account %d, %s - %s'%(i,
379 person_id,plc[i]['peer-admin-name'],
380 plc[i]['peer-admin-password'])
381 plc[i]['peer-admin-id']=person_id
383 def test00_admin_enable (args=[1,2]):
385 s[i].AdmSetPersonEnabled(aa[i],plc[i]['peer-admin-id'],True)
386 s[i].AddRoleToPerson(aa[i],'admin',plc[i]['peer-admin-id'])
387 print '%02d:== enabled+admin on account %d:%s'%(i,plc[i]['peer-admin-id'],plc[i]['peer-admin-name'])
389 def test00_peer_person (args=[1,2]):
393 email=plc[peer]['peer-admin-name']
395 p=s[i].GetPersons(a[i],[email])[0]
396 plc[i]['peer_person_id']=p['person_id']
398 person_id = s[i].AddPerson (a[i], {'first_name':'Peering(plain passwd)', 'last_name':plc_name(peer), 'role_ids':[3000],
399 'email':email,'password':plc[peer]['peer-admin-password']})
400 print '%02d:Created person %d as the peer person'%(i,person_id)
401 plc[i]['peer_person_id']=person_id
404 def test00_peer (args=[1,2]):
408 peername = plc_name(peer)
410 p=s[i].GetPeers (a[i], [peername])[0]
411 plc[i]['peer_id']=p['peer_id']
413 peer_id=s[i].AddPeer (a[i], {'peername':peername,'peer_url':plc[peer]['url'],'person_id':plc[i]['peer_person_id']})
414 # NOTE : need to manually reset the encrypted password through SQL at this point
415 print '%02d:Created peer %d'%(i,peer_id)
416 plc[i]['peer_id']=peer_id
417 print "PLEASE manually set password for person_id=%d in DB%d"%(plc[i]['peer_person_id'],i)
419 def test00_peer_passwd (args=[1,2]):
421 # using an ad-hoc local command for now - never could get quotes to reach sql....
422 print "Attempting to set passwd for person_id=%d in DB%d"%(plc[i]['peer_person_id'],i),
423 retcod=os.system("ssh root@%s new_plc_api/person-password.sh %d"%(plc[i]['hostname'],plc[i]['peer_person_id']))
424 print '-> system returns',retcod
426 # this one gets cached
429 return plc[i]['peer_id']
431 peername = plc_name (peer_index(i))
432 peer_id = s[i].GetPeers(a[i],[peername])[0]['peer_id']
433 plc[i]['peer_id'] = peer_id
436 ##############################
437 def test00_refresh (message,args=[1,2]):
438 print '=== refresh',message
441 print '%02d:== Refreshing peer'%(i),
442 retcod=s[i].RefreshPeer(a[i],get_peer_id(i))
447 def test01_site (args=[1,2]):
448 for ns in myrange(number_sites):
449 test01_site_n (ns,True,args)
451 def test01_del_site (args=[1,2]):
452 for ns in myrange(number_sites):
453 test01_site_n (ns,False,args)
455 def test01_site_n (ns,add_if_true,args=[1,2]):
457 login_base = site_login_base (i,ns)
459 site_id = s[i].GetSites(a[i],[login_base])[0]['site_id']
461 s[i].DeleteSite(a[i],site_id)
462 print "%02d:== deleted site_id %d"%(i,site_id)
465 sitename=site_name(i,ns)
466 abbrev_name="abbr"+str(i)
467 max_slices = number_slices
468 site_id=s[i].AddSite (a[i], {'name':plc_name(i),
469 'abbreviated_name': abbrev_name,
470 'login_base': login_base,
472 'url': 'http://%s.com/'%abbrev_name,
473 'max_slices':max_slices})
474 ### max_slices does not seem taken into account at that stage
475 s[i].UpdateSite(a[i],site_id,{'max_slices':max_slices})
476 print '%02d:== Created site %d with max_slices=%d'%(i,site_id,max_slices)
479 def test02_person (args=[1,2]):
480 for np in myrange(number_persons):
481 test02_person_n (np,True,args)
483 def test02_del_person (args=[1,2]):
484 for np in myrange(number_persons):
485 test02_person_n (np,False,args)
487 def test02_person_n (np,add_if_true,args=[1,2]):
488 test02_person_n_ks (np, myrange(number_keys),add_if_true,args)
490 def test02_person_n_ks (np,nks,add_if_true,args=[1,2]):
492 email = person_name(i,np)
494 person_id=s[i].GetPersons(a[i],[email])[0]['person_id']
496 s[i].DeletePerson(a[i],person_id)
497 print "%02d:== deleted person_id %d"%(i,person_id)
500 password = plc[i]['person-password']
501 person_id=s[i].AddPerson(a[i],{'first_name':'Your average',
502 'last_name':'User%d'%np,
505 'password': password })
506 print '%02d:== created user account %d, %s - %s'%(i, person_id,email,password)
508 key=key_name(i,np,nk)
509 s[i].AddPersonKey(aa[i],email,{'key_type':'ssh', 'key':key})
510 print '%02d:== added key %s to person %s'%(i,key,email)
513 # retrieves node_id from hostname - checks for local nodes only
514 def get_local_node_id(i,nodename):
515 return s[i].GetNodes(a[i],{'hostname':nodename,'peer_id':None})[0]['node_id']
517 # clean all local nodes - foreign nodes are not supposed to be cleaned up manually
518 def clean_all_nodes (args=[1,2]):
520 print '%02d:== Cleaning all nodes'%i
521 loc_nodes = s[i].GetNodes(a[i],{'peer_id':None})
522 for node in loc_nodes:
523 print '%02d:==== Cleaning node %d'%(i,node['node_id'])
524 s[i].DeleteNode(a[i],node['node_id'])
526 def test03_node (args=[1,2]):
527 for nn in myrange(number_nodes):
528 test03_node_n (nn,args)
530 def test03_node_n (nn,args=[1,2]):
532 nodename = node_name(i,nn)
534 get_local_node_id(i,nodename)
536 login_base=site_login_base(i,map_on_site(nn))
537 n=s[i].AddNode(a[i],login_base,{'hostname': nodename})
538 print '%02d:== Added node %d %s'%(i,n,node_name(i,i))
540 def test02_delnode (args=[1,2]):
541 for nn in myrange(number_nodes):
542 test02_delnode_n (nn,args)
544 def test02_delnode_n (nn,args=[1,2]):
546 nodename = node_name(i,nn)
547 node_id = get_local_node_id (i,nodename)
548 retcod=s[i].DeleteNode(a[i],nodename)
549 print '%02d:== Deleted node %d, returns %s'%(i,node_id,retcod)
552 def clean_all_slices (args=[1,2]):
554 print '%02d:== Cleaning all slices'%i
555 for slice in s[i].GetSlices(a[i],{'peer_id':None}):
556 slice_id = slice['slice_id']
557 if slice_id not in system_slices_ids:
558 print '%02d:==== Cleaning slice %d'%(i,slice_id)
559 s[i].DeleteSlice(a[i],slice_id)
561 def test04_slice (args=[1,2]):
562 for n in myrange(number_slices):
563 test04_slice_n (n,args)
565 def test04_slice_n (ns,args=[1,2]):
569 slicename=slice_name(i,ns)
570 max_nodes=number_nodes
572 s[i].GetSlices(a[i],[slicename])[0]
574 slice_id=s[i].AddSlice (a[i],{'name':slicename,
575 'description':'slice %s on %s'%(slicename,plcname),
576 'url':'http://planet-lab.org/%s'%slicename,
577 'max_nodes':max_nodes,
578 'instanciation':'plc-instantiated',
580 print '%02d:== created slice %d - max nodes=%d'%(i,slice_id,max_nodes)
581 for np in myrange(number_persons):
582 email = person_name (i,np)
583 retcod = s[i].AddPersonToSlice (a[i], email, slicename)
584 print '%02d:== Attached person %s to slice %s'%(i,email,slicename)
587 def test04_node_slice (is_local, add_if_true, args=[1,2]):
588 for ns in myrange(number_slices):
589 test04_node_slice_ns (ns,is_local, add_if_true, args)
591 def test04_node_slice_ns (ns,is_local, add_if_true, args=[1,2]):
592 test04_node_slice_nl_n (myrange(number_nodes),ns,is_local, add_if_true, args)
594 def test04_node_slice_nl_n (nnl,ns,is_local, add_if_true, args=[1,2]):
597 sname = slice_name (i,ns)
600 hostnames=[node_name(i,nn) for nn in nnl]
603 hostnames=[node_name(peer,nn) for nn in nnl]
606 s[i].AddSliceToNodes (a[i], sname,hostnames)
609 s[i].DeleteSliceFromNodes (a[i], sname,hostnames)
611 print '%02d:== %s in slice %s %s '%(i,message,sname,nodetype),
614 def test04_slice_add_lnode (args=[1,2]):
615 test04_node_slice (True,True,args)
617 def test04_slice_add_fnode (args=[1,2]):
618 test04_node_slice (False,True,args)
620 def test04_slice_del_lnode (args=[1,2]):
621 test04_node_slice (True,False,args)
623 def test04_slice_del_fnode (args=[1,2]):
624 test04_node_slice (False,False,args)
627 def test05_sat (args=[1,2]):
631 sat_id=s[i].GetSliceAttributeTypes (a[i],[name])[0]
633 description="custom sat on plc%d"%i
635 sat_id=s[i].AddSliceAttributeType (a[i],
637 'description': description,
638 'min_role_id' : min_role_id})
639 print '%02d:== created SliceAttributeType = %d'%(i,sat_id)
641 # for test, we create 4 slice_attributes
642 # on slice1 - sat=custom_made (see above) - all nodes
643 # on slice1 - sat=custom_made (see above) - node=n1
644 # on slice1 - sat='net_max' - all nodes
645 # on slice1 - sat='net_max' - node=n1
647 def test05_sa_atom (slice_name,sat_name,value,node,i):
648 sa_id=s[i].GetSliceAttributes(a[i],{'name':sat_name,
652 sa_id=s[i].AddSliceAttribute(a[i],
658 print 'slice_name',slice_name,'sat_name',sat_name
659 sa_id=s[i].AddSliceAttribute(a[i],
663 print '%02d:== created SliceAttribute = %d'%(i,sa_id),
664 print 'On slice',slice_name,'and node',node
666 def test05_sa (args=[1,2]):
668 test05_sa_atom (slice_name(i,1),sat_name(i),'custom sat/all nodes',None,i)
669 test05_sa_atom (slice_name(i,1),sat_name(i),'custom sat/node1',node_name(i,1),i)
670 test05_sa_atom (slice_name(i,1),'net_max','predefined sat/all nodes',None,i)
671 test05_sa_atom (slice_name(i,1),'net_max','predefined sat/node1',node_name(i,1),i)
673 ##############################
675 ##############################
677 print s['site_id'],s['peer_id'],s['login_base'],s['name'],s['node_ids']
680 print k['key_id'],k['peer_id'],k['key']
683 print p['person_id'],p['peer_id'],p['email'],'keys:',p['key_ids'],'sites:',p['site_ids']
686 print n['node_id'],n['peer_id'],n['hostname'],'sls=',n['slice_ids'],'site=',n['site_id']
689 print s['slice_id'],s['peer_id'],s['name'],'nodes=',s['node_ids'],'persons=',s['person_ids']
690 print '---','sas=',s['slice_attribute_ids'],s['name'],'crp=',s['creator_person_id'],'e=',s['expires']
693 print sat['attribute_type_id'],sat['peer_id'], sat['name'], sat['min_role_id'], sat['description']
696 print sa['slice_attribute_id'],sa['peer_id'],sa['name'],'AT_id:',sa['attribute_type_id']
697 print '---','v=',sa['value'],'sl=',sa['slice_id'],'n=',sa['node_id']
700 pretty_printer=pprint.PrettyPrinter(5)
702 def p_sliver (margin,x):
703 print margin,'SLIVERS for : hostname',x['hostname']
704 print margin,'%d config files'%len(x['conf_files'])
705 for sv in x['slivers']:
706 p_sliver_slice(margin,sv,x['hostname'])
708 def p_sliver_slice(margin,sliver,hostname):
709 print margin,'SLIVER on hostname %s, s='%hostname,sliver['name']
711 pretty_printer.pprint(sliver['keys'])
712 print margin,'ATTRIBUTES',
713 pretty_printer.pprint(sliver['attributes'])
715 def dump (args=[1,2]):
717 print '%02d:============================== DUMPING'%i
718 print '%02d: SITES'%i
719 [p_site(x) for x in s[i].GetSites(a[i])]
721 [p_key(x) for x in s[i].GetKeys(a[i])]
722 print '%02d: PERSONS'%i
723 [p_person(x) for x in s[i].GetPersons(a[i])]
724 print '%02d: NODES'%i
725 [p_node(x) for x in s[i].GetNodes(a[i])]
726 print '%02d: SLICES'%i
727 [p_slice(x) for x in s[i].GetSlices(a[i])]
728 print '%02d: Slice Attribute Types'%i
729 [p_sat(x) for x in s[i].GetSliceAttributeTypes(a[i])]
730 print '%02d: Slice Attributes'%i
731 [p_sa(x) for x in s[i].GetSliceAttributes(a[i])]
732 print '%02d: SLIVERS'%i
733 [p_sliver('%02d:'%i,x) for x in s[i].GetSlivers(a[i])]
734 print '%02d:============================== END DUMP'%i
737 ## for usage under the api
744 print (x['key_id'],x['peer_id'],x['key'])
747 for x in GetPersons():
755 for x in GetSlices():
759 for x in GetSliceAttributeTypes():
763 for x in GetSliceAttributes():
767 for s in GetSlivers():
781 print 'SLICE ATTR TYPES'
790 def test_all_init ():
794 test00_admin_person ()
795 test00_admin_enable ()
796 test00_peer_person ()
798 test00_peer_passwd ()
800 def test_all_sites ():
802 test00_refresh ('after site creation')
804 def test_all_persons ():
806 test00_refresh ('before persons&keys creation')
808 check_persons(system_persons,system_persons_cross)
809 message ("Creating persons&keys")
812 message ("1 extra del/add cycle for unique indexes")
813 test02_del_person([2])
815 check_keys(number_persons*number_keys,0)
816 check_persons(system_persons+number_persons,system_persons_cross)
817 test00_refresh ('after persons&keys creation')
818 check_keys(number_persons*number_keys,number_persons*number_keys)
819 check_persons(system_persons+number_persons,system_persons_cross+number_persons)
821 def test_all_nodes ():
823 message ("RESETTING NODES")
825 test00_refresh ('cleaned nodes')
828 # create one node on each site
829 message ("CREATING NODES")
831 check_nodes(number_nodes,0)
832 test00_refresh ('after node creation')
833 check_nodes(number_nodes,number_nodes)
836 message ("2 extra del/add cycles on plc2 for different indexes")
841 check_nodes(0,number_nodes,[2])
842 test00_refresh('after deletion on plc2')
843 check_nodes(number_nodes,0,[1])
844 check_nodes(0,number_nodes,[2])
845 message ("ADD on plc2 for different indexes")
847 check_nodes (number_nodes,0,[1])
848 check_nodes (number_nodes,number_nodes,[2])
849 test00_refresh('after re-creation on plc2')
850 check_nodes (number_nodes,number_nodes,)
852 def test_all_addslices ():
855 message ("RESETTING SLICES TEST")
859 test00_refresh ("After slices init")
861 # create slices on plc1
862 message ("CREATING SLICES on plc1")
864 # each site has 3 local slices and 0 foreign slice
865 check_slices (total_slices(),0,[1])
866 check_slices (system_slices(),0,[2])
867 test00_refresh ("after slice created on plc1")
868 check_slices (total_slices(),0,[1])
869 check_slices (system_slices(),number_slices,[2])
870 # no slice has any node yet
871 check_local_slice_nodes(0,[1])
872 check_foreign_slice_nodes(0,[2])
874 # insert local nodes in local slice on plc1
875 message ("ADDING LOCAL NODES IN SLICES")
876 test04_slice_add_lnode ([1])
877 # of course the change is only local
878 check_local_slice_nodes (number_nodes,[1])
879 check_foreign_slice_nodes(0,[2])
882 test00_refresh ("After local nodes were added on plc1")
883 check_local_slice_nodes (number_nodes,[1])
884 check_foreign_slice_nodes (number_nodes,[2])
886 # now we add foreign nodes into local slice
887 message ("ADDING FOREIGN NODES IN SLICES")
888 test04_slice_add_fnode ([1])
889 check_local_slice_nodes (2*number_nodes,[1])
890 check_foreign_slice_nodes (number_nodes,[2])
893 test00_refresh ("After foreign nodes were added in plc1")
894 # remember that foreign slices only know about LOCAL nodes
895 # so this does not do anything
896 check_local_slice_nodes (2*number_nodes,[1])
897 check_foreign_slice_nodes (2*number_nodes,[2])
899 check_slivers_1(total_slivers())
901 def test_all_delslices ():
903 message ("DELETING FOREIGN NODES FROM SLICES")
904 test04_slice_del_fnode([1])
905 check_local_slice_nodes (number_nodes,[1])
906 check_foreign_slice_nodes (2*number_nodes,[2])
908 check_slivers_1(total_slivers(),[1])
910 test00_refresh ("After foreign nodes were removed on plc1")
911 check_local_slice_nodes (number_nodes,[1])
912 check_foreign_slice_nodes (number_nodes,[2])
914 message ("DELETING LOCAL NODES FROM SLICES")
915 test04_slice_del_lnode([1])
916 check_local_slice_nodes (0,[1])
917 check_foreign_slice_nodes (number_nodes,[2])
919 test00_refresh ("After local nodes were removed on plc1")
920 check_local_slice_nodes (0,[1])
921 check_foreign_slice_nodes (0,[2])
923 message ("CHECKING SLICES CLEAN UP")
924 clean_all_slices([1])
925 check_slices (system_slices(),0,[1])
926 check_slices (system_slices(),number_slices,[2])
927 test00_refresh ("After slices clenaup")
928 check_slices(system_slices(),0)
930 def test_all_slices ():
931 test_all_addslices ()
932 test_all_delslices ()
934 def test_all_sats ():
936 test00_refresh("after SliceAttributeType creation")
955 ### ad hoc test sequences
968 test04_slice_add_lnode([1])
974 test00_refresh ("populate: refreshing peer 1",[1])
976 test04_slice_add_fnode([1])
978 test00_refresh("populate: refresh all")
982 # temporary - scratch as needed
992 print "Usage: %s [-n] [-f]"%sys.argv[0]
993 print " -n runs test_now instead of test_all"
994 print " -p runs populate instead of test_all"
995 print " -m run in mini mode (1 instance of each class)"
996 print " -b performs big run (%d times as large as normal)"%big_factor
997 print " -H performs huge run (%d times as large as normal)"%huge_factor
1003 (o,a) = getopt.getopt(sys.argv[1:], "mnpbH")
1009 print 'Running test_now'
1012 print 'Running populate'
1028 if __name__ == '__main__':