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 # actual nodes_per_slice is min(number_nodes,number_nodes_per_slice)
78 # this is to prevent quadractic test times on big tests
79 def define_test (keys,sites,persons,nodes,slices,nodes_per_slice,fast_mode=None):
80 global number_keys, number_sites, number_persons, number_nodes, number_slices
81 global number_nodes_per_slice, fast_flag
84 number_persons=persons
87 number_nodes_per_slice=nodes_per_slice
88 if fast_mode is not None:
91 # when we run locally on a given peer
95 print '%d keys, %d sites, %d persons, %d nodes, %d slices & %d nodes/slice'%(
96 number_keys, number_sites,number_persons,number_nodes,number_slices,number_nodes_per_slice),
97 print 'fast_flag',fast_flag
98 if local_index is not None:
99 print 'Running locally on index %d'%local_index
102 define_test(1,1,1,1,1,1,True)
105 define_test (keys=2,sites=4,persons=4,nodes=5,slices=4,nodes_per_slice=5,fast_mode=False)
107 # use only 1 key in this case
110 global number_keys, number_sites, number_persons, number_nodes, number_slices
112 (number_sites,number_persons,number_nodes,number_slices) = [
113 big_factor * x for x in (number_sites,number_persons,number_nodes,number_slices)]
118 global number_keys, number_sites, number_persons, number_nodes, number_slices
120 (number_sites,number_persons,number_nodes,number_slices) = [
121 huge_factor * x for x in (number_sites,number_persons,number_nodes,number_slices)]
124 # use mini test by default in interactive mode
129 # argh, for login_name that doesn't accept digits
130 plain_numbers=['zero','one','two','three','four','five','six','seven','eight','nine','ten',
131 'eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty']
132 plain_digits=['a','b','c','d','e','f','g','h','i','j']
134 plc1={ 'plcname':'plc1 in federation',
135 'hostname':'lurch.cs.princeton.edu',
136 'url-format':'https://%s:443/PLCAPI/',
137 'builtin-admin-id':'root@plc1.org',
138 'builtin-admin-password':'root',
139 'peer-admin-name':'peer1@planet-lab.org',
140 'peer-admin-password':'peer',
141 'node-format':'n1%02d.plc1.org',
143 'site-format':'one%s',
144 'person-format' : 'user1-%d@plc1.org',
145 'key-format':'ssh-rsa 11key4plc11 user%d-key%d',
146 'person-password' : 'password1',
148 plc2={ 'plcname':'plc2 in federation',
149 'hostname':'planetlab-devbox.inria.fr',
150 'url-format':'https://%s:443/PLCAPI/',
151 'builtin-admin-id':'root@plc2.org',
152 'builtin-admin-password':'root',
153 'peer-admin-name':'peer2@planet-lab.org',
154 'peer-admin-password':'peer',
155 'node-format':'n2%02d.plc2.org',
157 'site-format':'two%s',
158 'person-format' : 'user2-%d@plc2.org',
159 'key-format':'ssh-rsa 22key4plc22 user%d-key%d',
160 'person-password' : 'password2',
168 return plc[i]['plcname']
171 x=site_login_base(i,n)
172 return 'Site fullname '+x
174 def site_login_base (i,n):
176 if number_sites<len(plain_numbers):
177 return plc[i]['site-format']%plain_numbers[n]
183 string=plain_digits[rem]+string
188 return plc[i]['site-format']%string
190 def person_name (i,n):
191 return plc[i]['person-format']%n
193 def key_name (i,n,k):
194 return plc[i]['key-format']%(n,k)
197 return plc[i]['node-format']%n
200 result=(n%number_sites)
205 def slice_name (i,n):
206 site_index=map_on_site(n)
207 return "%s_slice%d"%(site_login_base(i,site_index),n)
212 # to have indexes start at 1
214 return range (1,n+1,1)
217 print "====================",
222 global epoch,last_time
225 print '+++ timer start'
230 print '+++ %.02f seconds ellapsed (%.02f)'%(now-epoch,now-last_time)
234 def test00_init (args=[1,2]):
237 ## have you loaded this file already (support for reload)
243 url=plc[i]['url-format']%plc[i]['hostname']
245 s[i]=xmlrpclib.ServerProxy(url,allow_none=True)
246 print 'initializing s[%d]'%i,url
247 aa[i]={'Username':plc[i]['builtin-admin-id'],
248 'AuthMethod':'password',
249 'AuthString':plc[i]['builtin-admin-password'],
251 print 'initialized aa[%d]'%i, aa[i]
252 a[i]={'Username':plc[i]['peer-admin-name'],
253 'AuthMethod':'password',
254 'AuthString':plc[i]['peer-admin-password'],
256 print 'initialized a[%d]'%i, a[i]
258 def test00_print (args=[1,2]):
261 print 'aa[%d]'%i, aa[i]
262 print 'a[%d]'%i, a[i]
264 def check_nodes (el,ef,args=[1,2]):
266 # use a single request and sort afterwards for efficiency
267 # could have used GetNodes's scope as well
268 all_nodes = s[i].GetNodes(a[i])
269 n = len ([ x for x in all_nodes if x['peer_id'] is None])
270 f = len ([ x for x in all_nodes if x['peer_id'] is not None])
271 print '%02d: Checking nodes: got %d local (e=%d) & %d foreign (e=%d)'%(i,n,el,f,ef)
275 def check_keys (el,ef,args=[1,2]):
277 # use a single request and sort afterwards for efficiency
278 # could have used GetKeys's scope as well
279 all_keys = s[i].GetKeys(a[i])
280 n = len ([ x for x in all_keys if x['peer_id'] is None])
281 f = len ([ x for x in all_keys if x['peer_id'] is not None])
282 print '%02d: Checking keys: got %d local (e=%d) & %d foreign (e=%d)'%(i,n,el,f,ef)
286 def check_persons (el,ef,args=[1,2]):
288 # use a single request and sort afterwards for efficiency
289 # could have used GetPersons's scope as well
290 all_persons = s[i].GetPersons(a[i])
291 n = len ([ x for x in all_persons if x['peer_id'] is None])
292 f = len ([ x for x in all_persons if x['peer_id'] is not None])
293 print '%02d: Checking persons: got %d local (e=%d) & %d foreign (e=%d)'%(i,n,el,f,ef)
297 # expected : local slices, foreign slices
298 def check_slices (els,efs,args=[1,2]):
300 ls=len(s[i].GetSlices(a[i],{'peer_id':None}))
301 fs=len(s[i].GetSlices(a[i],{'~peer_id':None}))
302 print '%02d: Checking slices: got %d local (e=%d) & %d foreign (e=%d)'%(i,ls,els,fs,efs)
306 def show_nodes (i,node_ids):
308 all_nodes = s[i].GetNodes(a[i],node_ids)
309 loc_nodes = filter (lambda n: n['peer_id'] is None, all_nodes)
310 for_nodes = filter (lambda n: n['peer_id'] is not None, all_nodes)
312 for message,nodes in [ ['LOC',loc_nodes], ['FOR',for_nodes] ] :
314 print '[%s:%d] : '%(message,len(nodes)),
316 print node['hostname']+' ',
319 def check_slice_nodes (expected_nodes, is_local_slice, args=[1,2]):
320 for ns in myrange(number_slices):
321 check_slice_nodes_n (ns,expected_nodes, is_local_slice, args)
323 def check_slice_nodes_n (ns,expected_nodes, is_local_slice, args=[1,2]):
327 sname=slice_name(i,ns)
328 slice=s[i].GetSlices(a[i],{'name':[sname],'peer_id':None})[0]
331 sname=slice_name(peer,ns)
332 slice=s[i].GetSlices(a[i],{'name':[sname],'~peer_id':None})[0]
334 print '%02d: %s slice %s (e=%d) '%(i,message,sname,expected_nodes),
335 slice_node_ids=slice['node_ids']
336 print 'on nodes ',slice_node_ids
337 show_nodes (i,slice_node_ids)
338 assert len(slice_node_ids)>=expected_nodes
339 if len(slice_node_ids) != expected_nodes:
342 # expected : nodes on local slice
343 def check_local_slice_nodes (expected, args=[1,2]):
344 check_slice_nodes(expected,True,args)
346 # expected : nodes on foreign slice
347 def check_foreign_slice_nodes (expected, args=[1,2]):
348 check_slice_nodes(expected,False,args)
350 def check_conf_files (args=[1,2]):
351 for nn in myrange(number_nodes):
352 check_conf_files_n (nn,args)
354 def check_conf_files_n (nn,args=[1,2]):
356 nodename=node_name(i,nn)
357 ndict= s[i].GetSlivers(a[i],[nodename])[0]
358 assert ndict['hostname'] == nodename
359 conf_files = ndict['conf_files']
360 print '%02d: %d conf_files in GetSlivers for node %s'%(i,len(conf_files),nodename)
361 for conf_file in conf_files:
362 print 'source=',conf_file['source'],'|',
363 print 'dest=',conf_file['dest'],'|',
364 print 'enabled=',conf_file['enabled'],'|',
368 pp = pprint.PrettyPrinter(indent=3)
370 def check_slivers (esn,args=[1,2]):
371 for nn in myrange(number_nodes):
372 check_slivers_n (nn,esn,args)
374 # too verbose to check all nodes, let's check only the first one
375 def check_slivers_1 (esn,args=[1,2]):
376 check_slivers_n (1,esn,args)
378 def check_slivers_n (nn,esn,args=[1,2]):
380 nodename=node_name(i,nn)
381 ndict= s[i].GetSlivers(a[i],[nodename])[0]
382 assert ndict['hostname'] == nodename
383 slivers = ndict['slivers']
384 print '%02d: %d slivers (exp. %d) in GetSlivers for node %s'\
385 %(i,len(slivers),esn,nodename)
386 for sliver in slivers:
387 print '>>slivername = ',sliver['name']
388 pretty_printer.pprint(sliver)
389 assert len(slivers) == esn
393 def test00_admin_person (args=[1,2]):
396 email = plc[i]['peer-admin-name']
398 p=s[i].GetPersons(a[i],[email])[0]
399 plc[i]['peer-admin-id']=p['person_id']
401 person_id=s[i].AddPerson(aa[i],{'first_name':'Local',
402 'last_name':'PeerPoint',
405 'password':plc[i]['peer-admin-password']})
406 print '%02d:== created peer admin account %d, %s - %s'%(i,
407 person_id,plc[i]['peer-admin-name'],
408 plc[i]['peer-admin-password'])
409 plc[i]['peer-admin-id']=person_id
411 def test00_admin_enable (args=[1,2]):
413 s[i].AdmSetPersonEnabled(aa[i],plc[i]['peer-admin-id'],True)
414 s[i].AddRoleToPerson(aa[i],'admin',plc[i]['peer-admin-id'])
415 print '%02d:== enabled+admin on account %d:%s'%(i,plc[i]['peer-admin-id'],plc[i]['peer-admin-name'])
417 def test00_peer_person (args=[1,2]):
421 email=plc[peer]['peer-admin-name']
423 p=s[i].GetPersons(a[i],[email])[0]
424 plc[i]['peer_person_id']=p['person_id']
426 person_id = s[i].AddPerson (a[i], {'first_name':'Peering(plain passwd)', 'last_name':plc_name(peer), 'role_ids':[3000],
427 'email':email,'password':plc[peer]['peer-admin-password']})
428 print '%02d:Created person %d as the peer person'%(i,person_id)
429 plc[i]['peer_person_id']=person_id
432 def test00_peer (args=[1,2]):
436 peername = plc_name(peer)
438 p=s[i].GetPeers (a[i], [peername])[0]
439 plc[i]['peer_id']=p['peer_id']
441 peer_id=s[i].AddPeer (a[i], {'peername':peername,'peer_url':plc[peer]['url'],'person_id':plc[i]['peer_person_id']})
442 # NOTE : need to manually reset the encrypted password through SQL at this point
443 print '%02d:Created peer %d'%(i,peer_id)
444 plc[i]['peer_id']=peer_id
445 print "PLEASE manually set password for person_id=%d in DB%d"%(plc[i]['peer_person_id'],i)
447 def test00_peer_passwd (args=[1,2]):
449 # using an ad-hoc local command for now - never could get quotes to reach sql....
450 print "Attempting to set passwd for person_id=%d in DB%d"%(plc[i]['peer_person_id'],i),
451 retcod=os.system("ssh root@%s new_plc_api/person-password.sh %d"%(plc[i]['hostname'],plc[i]['peer_person_id']))
452 print '-> system returns',retcod
454 # this one gets cached
457 return plc[i]['peer_id']
459 peername = plc_name (peer_index(i))
460 peer_id = s[i].GetPeers(a[i],[peername])[0]['peer_id']
461 plc[i]['peer_id'] = peer_id
464 ##############################
465 def test00_refresh (message,args=[1,2]):
466 print '=== refresh',message
469 print '%02d:== Refreshing peer'%(i),
470 retcod=s[i].RefreshPeer(a[i],get_peer_id(i))
475 def test01_site (args=[1,2]):
476 for ns in myrange(number_sites):
477 test01_site_n (ns,True,args)
479 def test01_del_site (args=[1,2]):
480 for ns in myrange(number_sites):
481 test01_site_n (ns,False,args)
483 def test01_site_n (ns,add_if_true,args=[1,2]):
485 login_base = site_login_base (i,ns)
487 site_id = s[i].GetSites(a[i],[login_base])[0]['site_id']
489 s[i].DeleteSite(a[i],site_id)
490 print "%02d:== deleted site_id %d"%(i,site_id)
493 sitename=site_name(i,ns)
494 abbrev_name="abbr"+str(i)
495 max_slices = number_slices
496 site_id=s[i].AddSite (a[i], {'name':plc_name(i),
497 'abbreviated_name': abbrev_name,
498 'login_base': login_base,
500 'url': 'http://%s.com/'%abbrev_name,
501 'max_slices':max_slices})
502 ### max_slices does not seem taken into account at that stage
503 s[i].UpdateSite(a[i],site_id,{'max_slices':max_slices})
504 print '%02d:== Created site %d with max_slices=%d'%(i,site_id,max_slices)
507 def test02_person (args=[1,2]):
508 for np in myrange(number_persons):
509 test02_person_n (np,True,args)
511 def test02_del_person (args=[1,2]):
512 for np in myrange(number_persons):
513 test02_person_n (np,False,args)
515 def test02_person_n (np,add_if_true,args=[1,2]):
516 test02_person_n_ks (np, myrange(number_keys),add_if_true,args)
518 def test02_person_n_ks (np,nks,add_if_true,args=[1,2]):
520 email = person_name(i,np)
522 person_id=s[i].GetPersons(a[i],[email])[0]['person_id']
524 s[i].DeletePerson(a[i],person_id)
525 print "%02d:== deleted person_id %d"%(i,person_id)
528 password = plc[i]['person-password']
529 person_id=s[i].AddPerson(a[i],{'first_name':'Your average',
530 'last_name':'User%d'%np,
533 'password': password })
534 print '%02d:== created user account %d, %s - %s'%(i, person_id,email,password)
536 key=key_name(i,np,nk)
537 s[i].AddPersonKey(aa[i],email,{'key_type':'ssh', 'key':key})
538 print '%02d:== added key %s to person %s'%(i,key,email)
541 # retrieves node_id from hostname - checks for local nodes only
542 def get_local_node_id(i,nodename):
543 return s[i].GetNodes(a[i],{'hostname':nodename,'peer_id':None})[0]['node_id']
545 # clean all local nodes - foreign nodes are not supposed to be cleaned up manually
546 def clean_all_nodes (args=[1,2]):
548 print '%02d:== Cleaning all nodes'%i
549 loc_nodes = s[i].GetNodes(a[i],{'peer_id':None})
550 for node in loc_nodes:
551 print '%02d:==== Cleaning node %d'%(i,node['node_id'])
552 s[i].DeleteNode(a[i],node['node_id'])
554 def test03_node (args=[1,2]):
555 for nn in myrange(number_nodes):
556 test03_node_n (nn,args)
558 def test03_node_n (nn,args=[1,2]):
560 nodename = node_name(i,nn)
562 get_local_node_id(i,nodename)
564 login_base=site_login_base(i,map_on_site(nn))
565 n=s[i].AddNode(a[i],login_base,{'hostname': nodename})
566 print '%02d:== Added node %d %s'%(i,n,node_name(i,i))
568 def test02_delnode (args=[1,2]):
569 for nn in myrange(number_nodes):
570 test02_delnode_n (nn,args)
572 def test02_delnode_n (nn,args=[1,2]):
574 nodename = node_name(i,nn)
575 node_id = get_local_node_id (i,nodename)
576 retcod=s[i].DeleteNode(a[i],nodename)
577 print '%02d:== Deleted node %d, returns %s'%(i,node_id,retcod)
580 def clean_all_slices (args=[1,2]):
582 print '%02d:== Cleaning all slices'%i
583 for slice in s[i].GetSlices(a[i],{'peer_id':None}):
584 slice_id = slice['slice_id']
585 if slice_id not in system_slices_ids:
586 print '%02d:==== Cleaning slice %d'%(i,slice_id)
587 s[i].DeleteSlice(a[i],slice_id)
589 def test04_slice (args=[1,2]):
590 for n in myrange(number_slices):
591 test04_slice_n (n,args)
593 def test04_slice_n (ns,args=[1,2]):
597 slicename=slice_name(i,ns)
598 max_nodes=number_nodes
600 s[i].GetSlices(a[i],[slicename])[0]
602 slice_id=s[i].AddSlice (a[i],{'name':slicename,
603 'description':'slice %s on %s'%(slicename,plcname),
604 'url':'http://planet-lab.org/%s'%slicename,
605 'max_nodes':max_nodes,
606 'instanciation':'plc-instantiated',
608 print '%02d:== created slice %d - max nodes=%d'%(i,slice_id,max_nodes)
609 for np in myrange(number_persons):
610 email = person_name (i,np)
611 retcod = s[i].AddPersonToSlice (a[i], email, slicename)
612 print '%02d:== Attached person %s to slice %s'%(i,email,slicename)
615 def test04_node_slice (is_local, add_if_true, args=[1,2]):
616 for ns in myrange(number_slices):
617 test04_node_slice_ns (ns,is_local, add_if_true, args)
619 def test04_node_slice_ns (ns,is_local, add_if_true, args=[1,2]):
620 actual_nodes_per_slice = min (number_nodes,number_nodes_per_slice)
621 test04_node_slice_nl_n (myrange(actual_nodes_per_slice),ns,is_local, add_if_true, args)
623 def test04_node_slice_nl_n (nnl,ns,is_local, add_if_true, args=[1,2]):
626 sname = slice_name (i,ns)
629 hostnames=[node_name(i,nn) for nn in nnl]
632 hostnames=[node_name(peer,nn) for nn in nnl]
635 s[i].AddSliceToNodes (a[i], sname,hostnames)
638 s[i].DeleteSliceFromNodes (a[i], sname,hostnames)
640 print '%02d:== %s in slice %s %s '%(i,message,sname,nodetype),
643 def test04_slice_add_lnode (args=[1,2]):
644 test04_node_slice (True,True,args)
646 def test04_slice_add_fnode (args=[1,2]):
647 test04_node_slice (False,True,args)
649 def test04_slice_del_lnode (args=[1,2]):
650 test04_node_slice (True,False,args)
652 def test04_slice_del_fnode (args=[1,2]):
653 test04_node_slice (False,False,args)
656 def test05_sat (args=[1,2]):
660 sat_id=s[i].GetSliceAttributeTypes (a[i],[name])[0]
662 description="custom sat on plc%d"%i
664 sat_id=s[i].AddSliceAttributeType (a[i],
666 'description': description,
667 'min_role_id' : min_role_id})
668 print '%02d:== created SliceAttributeType = %d'%(i,sat_id)
670 # for test, we create 4 slice_attributes
671 # on slice1 - sat=custom_made (see above) - all nodes
672 # on slice1 - sat=custom_made (see above) - node=n1
673 # on slice1 - sat='net_max' - all nodes
674 # on slice1 - sat='net_max' - node=n1
676 def test05_sa_atom (slice_name,sat_name,value,node,i):
677 sa_id=s[i].GetSliceAttributes(a[i],{'name':sat_name,
681 sa_id=s[i].AddSliceAttribute(a[i],
687 print 'slice_name',slice_name,'sat_name',sat_name
688 sa_id=s[i].AddSliceAttribute(a[i],
692 print '%02d:== created SliceAttribute = %d'%(i,sa_id),
693 print 'On slice',slice_name,'and node',node
695 def test05_sa (args=[1,2]):
697 test05_sa_atom (slice_name(i,1),sat_name(i),'custom sat/all nodes',None,i)
698 test05_sa_atom (slice_name(i,1),sat_name(i),'custom sat/node1',node_name(i,1),i)
699 test05_sa_atom (slice_name(i,1),'net_max','predefined sat/all nodes',None,i)
700 test05_sa_atom (slice_name(i,1),'net_max','predefined sat/node1',node_name(i,1),i)
702 ##############################
704 ##############################
706 print s['site_id'],s['peer_id'],s['login_base'],s['name'],s['node_ids']
709 print k['key_id'],k['peer_id'],k['key']
712 print p['person_id'],p['peer_id'],p['email'],'keys:',p['key_ids'],'sites:',p['site_ids']
715 print n['node_id'],n['peer_id'],n['hostname'],'sls=',n['slice_ids'],'site=',n['site_id']
718 print s['slice_id'],s['peer_id'],s['name'],'nodes=',s['node_ids'],'persons=',s['person_ids']
719 print '---','sas=',s['slice_attribute_ids'],s['name'],'crp=',s['creator_person_id']
720 print "--- 'expires':",s['expires']
723 print sat['attribute_type_id'],sat['peer_id'], sat['name'], sat['min_role_id'], sat['description']
726 print sa['slice_attribute_id'],sa['peer_id'],sa['name'],'AT_id:',sa['attribute_type_id']
727 print '---','v=',sa['value'],'sl=',sa['slice_id'],'n=',sa['node_id']
730 pretty_printer=pprint.PrettyPrinter(5)
732 def p_sliver (margin,x):
733 print margin,'SLIVERS for : hostname',x['hostname']
734 print margin,'%d config files'%len(x['conf_files'])
735 for sv in x['slivers']:
736 p_sliver_slice(margin,sv,x['hostname'])
738 def p_sliver_slice(margin,sliver,hostname):
739 print margin,'SLIVER on hostname %s, s='%hostname,sliver['name']
741 pretty_printer.pprint(sliver['keys'])
742 print margin,'ATTRIBUTES',
743 pretty_printer.pprint(sliver['attributes'])
745 def dump (args=[1,2]):
747 print '%02d:============================== DUMPING'%i
748 print '%02d: SITES'%i
749 [p_site(x) for x in s[i].GetSites(a[i])]
751 [p_key(x) for x in s[i].GetKeys(a[i])]
752 print '%02d: PERSONS'%i
753 [p_person(x) for x in s[i].GetPersons(a[i])]
754 print '%02d: NODES'%i
755 [p_node(x) for x in s[i].GetNodes(a[i])]
756 print '%02d: SLICES'%i
757 [p_slice(x) for x in s[i].GetSlices(a[i])]
758 print '%02d: Slice Attribute Types'%i
759 [p_sat(x) for x in s[i].GetSliceAttributeTypes(a[i])]
760 print '%02d: Slice Attributes'%i
761 [p_sa(x) for x in s[i].GetSliceAttributes(a[i])]
762 print '%02d: SLIVERS'%i
763 [p_sliver('%02d:'%i,x) for x in s[i].GetSlivers(a[i])]
764 print '%02d:============================== END DUMP'%i
767 ## for usage under the api
774 print (x['key_id'],x['peer_id'],x['key'])
777 for x in GetPersons():
785 for x in GetSlices():
789 for x in GetSliceAttributeTypes():
793 for x in GetSliceAttributes():
797 for s in GetSlivers():
811 print 'SLICE ATTR TYPES'
820 def test_all_init ():
824 test00_admin_person ()
825 test00_admin_enable ()
826 test00_peer_person ()
828 test00_peer_passwd ()
830 def test_all_sites ():
832 test00_refresh ('after site creation')
834 def test_all_persons ():
836 test00_refresh ('before persons&keys creation')
838 check_persons(system_persons,system_persons_cross)
839 message ("Creating persons&keys")
842 message ("1 extra del/add cycle for unique indexes")
843 test02_del_person([2])
845 check_keys(number_persons*number_keys,0)
846 check_persons(system_persons+number_persons,system_persons_cross)
847 test00_refresh ('after persons&keys creation')
848 check_keys(number_persons*number_keys,number_persons*number_keys)
849 check_persons(system_persons+number_persons,system_persons_cross+number_persons)
851 def test_all_nodes ():
853 message ("RESETTING NODES")
855 test00_refresh ('cleaned nodes')
858 # create one node on each site
859 message ("CREATING NODES")
861 check_nodes(number_nodes,0)
862 test00_refresh ('after node creation')
863 check_nodes(number_nodes,number_nodes)
866 message ("2 extra del/add cycles on plc2 for different indexes")
871 check_nodes(0,number_nodes,[2])
872 test00_refresh('after deletion on plc2')
873 check_nodes(number_nodes,0,[1])
874 check_nodes(0,number_nodes,[2])
875 message ("ADD on plc2 for different indexes")
877 check_nodes (number_nodes,0,[1])
878 check_nodes (number_nodes,number_nodes,[2])
879 test00_refresh('after re-creation on plc2')
880 check_nodes (number_nodes,number_nodes,)
882 def test_all_addslices ():
885 message ("RESETTING SLICES TEST")
889 test00_refresh ("After slices init")
891 # create slices on plc1
892 message ("CREATING SLICES on plc1")
894 # each site has 3 local slices and 0 foreign slice
895 check_slices (total_slices(),0,[1])
896 check_slices (system_slices(),0,[2])
897 test00_refresh ("after slice created on plc1")
898 check_slices (total_slices(),0,[1])
899 check_slices (system_slices(),number_slices,[2])
900 # no slice has any node yet
901 check_local_slice_nodes(0,[1])
902 check_foreign_slice_nodes(0,[2])
904 # insert local nodes in local slice on plc1
905 message ("ADDING LOCAL NODES IN SLICES")
906 test04_slice_add_lnode ([1])
907 # of course the change is only local
908 check_local_slice_nodes (number_nodes,[1])
909 check_foreign_slice_nodes(0,[2])
912 test00_refresh ("After local nodes were added on plc1")
913 check_local_slice_nodes (number_nodes,[1])
914 check_foreign_slice_nodes (number_nodes,[2])
916 # now we add foreign nodes into local slice
917 message ("ADDING FOREIGN NODES IN SLICES")
918 test04_slice_add_fnode ([1])
919 check_local_slice_nodes (2*number_nodes,[1])
920 check_foreign_slice_nodes (number_nodes,[2])
923 test00_refresh ("After foreign nodes were added in plc1")
924 # remember that foreign slices only know about LOCAL nodes
925 # so this does not do anything
926 check_local_slice_nodes (2*number_nodes,[1])
927 check_foreign_slice_nodes (2*number_nodes,[2])
929 check_slivers_1(total_slivers())
931 def test_all_delslices ():
933 message ("DELETING FOREIGN NODES FROM SLICES")
934 test04_slice_del_fnode([1])
935 check_local_slice_nodes (number_nodes,[1])
936 check_foreign_slice_nodes (2*number_nodes,[2])
938 check_slivers_1(total_slivers(),[1])
940 test00_refresh ("After foreign nodes were removed on plc1")
941 check_local_slice_nodes (number_nodes,[1])
942 check_foreign_slice_nodes (number_nodes,[2])
944 message ("DELETING LOCAL NODES FROM SLICES")
945 test04_slice_del_lnode([1])
946 check_local_slice_nodes (0,[1])
947 check_foreign_slice_nodes (number_nodes,[2])
949 test00_refresh ("After local nodes were removed on plc1")
950 check_local_slice_nodes (0,[1])
951 check_foreign_slice_nodes (0,[2])
953 message ("CHECKING SLICES CLEAN UP")
954 clean_all_slices([1])
955 check_slices (system_slices(),0,[1])
956 check_slices (system_slices(),number_slices,[2])
957 test00_refresh ("After slices clenaup")
958 check_slices(system_slices(),0)
960 def test_all_slices ():
961 test_all_addslices ()
962 test_all_delslices ()
964 def test_all_sats ():
966 test00_refresh("after SliceAttributeType creation")
985 ### ad hoc test sequences
998 test04_slice_add_lnode([1])
1004 # test00_refresh ("populate: refreshing peer 1",[1])
1006 # test04_slice_add_fnode([1])
1008 # test00_refresh("populate: refresh all")
1012 # temporary - scratch as needed
1017 # clean_all_slices()
1022 print "Usage: %s [-n] [-f]"%sys.argv[0]
1023 print " -n runs test_now instead of test_all"
1024 print " -p runs populate instead of test_all"
1025 print " -m run in mini mode (1 instance of each class)"
1026 print " -b performs big run (%d times as large as normal)"%big_factor
1027 print " -H performs huge run (%d times as large as normal)"%huge_factor
1028 print " -l n : tester runs locally for peer <n>, rather than through xmlrpc"
1034 (o,a) = getopt.getopt(sys.argv[1:], "mnpbHl:")
1040 print 'Running test_now'
1043 print 'Running populate'
1054 print '-l option not implemented yet'
1055 # need to figure a way to use Shell.py-like calling paradigm
1067 if __name__ == '__main__':