1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025
|
#!/usr/bin/env python2
#############################################################################
# SRMV2 TEST SUITE FOR MULTIPLE FILES (version-3) #
# BY FARIDA NAZ <Farida.Naz@cern.ch> #
# Last modification: Fri Nov 25 5:31:40 CEST 2005 #
##############################################################################
### THE SCRIPT PERFORMS ----- TESTS OF SRMV2 ###
# The script uses files '/boot/vmlinux-2.4.21-37.EL.cernsmp'(3.5M)
# /etc/ldap.conf(6.5K)
#/etc/group (8byte)
import sys
import os
import time
import commands
import getopt
import traceback
def getcmd(cmd):
output = commands.getoutput(cmd)
return output
def gettime():
tm=time.localtime()
s_date="%s-%s-%s"%(tm[0],tm[1],tm[2])
s_time="%s:%s:%s"%(tm[3],tm[4],tm[5])
return s_date,s_time
def elapsed_time(start_time):
return int(time.time()-start_time)
def checkproxy():
try:
proxy_file_name = os.environ['X509_USER_PROXY']
except:
proxy_file_name = '/tmp/x509up_u'+ repr(os.getuid())
if os.path.isfile(proxy_file_name):
cmd="grid-proxy-info -timeleft "
timeleft=commands.getoutput(cmd)
secondsLeft =20*60
if int(timeleft)==-1:
errMsg="Error: UI_PROXY_EXPIRED"
print errMsg
sys.exit(0)
elif int(timeleft)>0 and int(timeleft)<secondsLeft:
valid = "00:20"
errMsg="*** Error: UI_PROXY_DURATION ***\n Proxy certificate will expire within less then %s seconds."%valid
print errMsg
sys.exit(0)
else:
# The Proxy Does not exist
errMsg="**** Error:UI_PROXY_NOT_FOUND ****\nProxy certificate not found.\n"
print errMsg
sys.exit(0)
def main():
global SE,pathdir,GRIDFTP_COPY
GRIDFTP_EXIST ="$EDG_LOCATION/bin/edg-gridftp-exists"
GRIDFTP_COPY = "$GLOBUS_LOCATION/bin/globus-url-copy"
getopts()
targetSE=SE
srmv2=SE
print "\ntarget SE: ",targetSE
print "srmv2: ",srmv2
cmd="hostname -f"
host=getcmd(cmd)
print "localhost: ",host
endpoint="https://%s:8444"%targetSE
d_path=pathdir
if d_path!="":
path="gsiftp://%s"%(SE)+d_path
cmd="%s %s"%(GRIDFTP_EXIST,path)
(s, o) = commands.getstatusoutput(cmd)
if o!="":
print o
sys.stderr.write("source path doesn't exist ")
traceback.print_exc()
sys.exit(1)
else:
if d_path[-1]!='/':
d_path+='/'
u_token="srm_v2token"
overwrite=0
nb_SURLs=2
srm_path=""
surl_path=""
r_token=""
surl_base="srm://%s:8444/%s"%(targetSE,d_path)
surls=[]
for i in range(2):
filename="srmv2_TfileA-%i"%i
lifetime=1000*(i+1)
size=1024*(i+1)
surl_path=surl_path+" "+"srm://%s:8444/%s"%(targetSE,d_path)+"%s"%(filename)
surl="srm://%s:8444/%s"%(targetSE,d_path)+"%s"%filename
surls.append(surl)
srm_path=srm_path+" "+"srm://%s:8444/%s" %(targetSE,d_path)+ "%s %i V %i"%(filename,lifetime,size)
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testPut ***"
operation="./srm2_testPut"
print operation, commands.getoutput(operation)
cmd= "./srm2_testPut %s %i %i %s "%(u_token,nb_SURLs,overwrite,srm_path)
print "CMD: ",cmd
s_time=time.time()
output=getcmd(cmd)
#end_time=time.time()-s_time()
#print output
#print "********************"
r_token,TURL=getresult(output)
SURLs=getputdone(r_token,surl_path)
#print "SURL: ",SURLs
num=0
for SURL in SURLs:
f_token,f_TURL,g_token,g_TURL=getGet(u_token,SURL)
file_name=SURL.split('/')[-1]
dest_f="/tmp/%sF"%file_name
dest_g="/tmp/%sG"%file_name
getrfcopy(f_TURL,dest_f)
getglobuscopy(g_TURL,file_name)
src=getsrcfile(num)
dests=[]
dests.append(dest_f)
dests.append(dest_g)
for dest in dests:
getdiff(src,dest)
num+=1
getreleasefiles(f_token,SURL)
getrequestsummary(endpoint,r_token,f_token,g_token)
sec=3600
getextendlifetime(f_token,SURL,sec)
getsetpermission(SURL)
getls(surl_path)
getmkdir(surl_base)
surl2=surl_base+"srm2_newdir"
for surl in surls:
getmv(surl,"%sX"%surl)
getrmdir(surl2)
getls(surl_base)
getrmdir(surl_base)
getreqId(endpoint,u_token)
getcheckpermission(surl)
getAbortFiles(r_token,"%sX"%surl)
getSuspendRequest(r_token,"%sX"%surl)
getRemoveFiles(r_token,"%sX"%surl)
##getsrm2_testCopy(u_token,"%sX"%surl,"%sXX"%surl)
getResumeRequest(r_token,"%sX"%surl)
getReassignToUser("%sX"%surl)
getChangeFileStorageType(surl)
for surl in surls:
getrm(surl)
getrm("%sX"%surl)
temp(path,surl_base,endpoint)
def temp(path,surl_base,endpoint):
cmd="edg-gridftp-exists %s"%path+"testfile"
o,s=commands.getstatusoutput(cmd)
if o==0:
cmd="edg-gridftp-rm %s"%path+"testfile"
o,s=commands.getstatusoutput(cmd)
SURL=surl_base +"testfile"
cmd1="./srm2_testPut srmv2-token 1 0 %s 300 0 1000"%SURL
print "CMD: ",cmd1
res1=getcmd(cmd1)
x=res1.split('\n')
for j in range(0,len(x)):
y= x[j].split()
for i in range(0,len(y)):
if y[i]=="r_token":
r_token1=y[i+1]
if y[i]=="TURL":
TURL=y[i+2]
print TURL
qq=TURL.split('//')[1:3]
sTURL=':/'.join(qq)
cmd2="rfcp /etc/group %s"%sTURL
print "CMD: ",cmd2
res2=getcmd(cmd2)
#print
print "\n*** LET ABORT THE REQUEST OF SRM2_TESTPUT FOR testfile ***"
getAbortRequest(endpoint,r_token1)
getputdone(r_token1,SURL)
def getputdone(r_token,SURL):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testPutDone *** "
SURLs=[]
operation="./srm2_testPutDone"
print commands.getoutput(operation)
cmd="./srm2_testPutDone %s %s"%(r_token,SURL)
srm_path=SURL
#print "srm_path::::: ",srm_path
print "CMD: ",cmd
start_t=time.time()
output=getcmd(cmd)
end_t=int(time.time()-start_t)
#print "OUTPUT-> "
#print output
#print " ------------------ "
x=output.split('\n')
for j in range(0,len(x)):
y= x[j].split()
for i in range(0,len(y)):
if y[i]=="state":
#print "this is state : ",y[i+1]
state=y[i+1]
state_out=statusCode(int(state))
print "request state: ",state_out
if y[i]=="SURL":
SURL=y[i+2]
print "SURL: ",SURL
SURLs.append(SURL)
state_t=y[-4][0:-1]
#print "state_t ",state_t
code=int(state_t)
state_out=statusCode(code)
print "state file: ",state_out
if y[i]=="explanation:":
x= h[i:]
exp=" ".join(x)
print exp
if int(state)!=0:
print "test failed with status: %s"%(statusCode(int(state)))
sys.exit(1)
else:
status="OK"
print "operation: %s = %s elapsed_time=%i \n"%(operation,status,end_t)
print "================================================================================="
return SURLs
def getresult(output):
#print "end_time: ",end_time
r_token=""
state=-1
t_state=-1
status=""
TURLs=[]
x=output.split('\n')
num=0
for j in range(0,len(x)):
y= x[j].split()
for i in range(0,len(y)):
if y[i]=="r_token":
print "r_token: ", y[i+1]
r_token=y[i+1]
if y[i]=="state":
#print "this is state : ",y[i+1]
state=y[i+1]
if state=="11":
print "Request state: ",statusCode(int(state))
sys.exit(1)
state_out=statusCode(int(state))
print "request state: ",state_out
if y[i]=="TURL":
TURL=y[i+2]
print "TURL: ",TURL
state_t=y[-6]
t_state=y[-4][0:-1]
state_out=statusCode(int(t_state))
print "state file: ",state_out
TURLs.append(TURL)
qq=TURL.split('//')[1:3]
sTURL=':/'.join(qq)
dest=sTURL
print "operation: srm2_testPut=OK Durration: \n "
print "================================================================"
if getsrcfile(num)!="":
src=getsrcfile(num)
#print "num: src: ",num,src
#getrfcopy(src,dest)
if pathdir.split('/')[1]=="pnfs":
print "Storage Type: dCache"
cmd="dccp %s %s"%(src,dest)
print "CMD: ",cmd
output=getcmd(cmd)
print output
else:
getrfcopy(src,dest)
num+=1
return r_token,TURLs
def getrfcopy(src,dest):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** RFCOPY *** "
operation="rfcp"
print commands.getoutput(operation)
cmd="rfcp %s %s"%(src,dest)
print "CMD: ",cmd
start_t=time.time()
output=getcmd(cmd)
end_t=int(time.time()-start_t)
print "OUTPUT: \n ",output
print "operation: %s=OK Durration: %s"%(operation,end_t)
print "================================================================================"
def getsrcfile(num):
#you can add more files here with diff sizes
tuple=['/etc/group', \
'/etc/ldap.conf', \
'/boot/vmlinux-2.4.21-37.EL.cernsmp']
if num < len(tuple):
return tuple[num]
else:
print "No more source files!"
def getglobuscopy(g_TURL,filename):
global GRIDFTP_COPY
s_date,s_time=gettime()
print "\n",s_date,s_time," *** GLOBUS-URL-COPY *** "
operation="globus-url-copy"
print commands.getoutput(operation)
cmd="%s %s file:/tmp/%sG"%(GRIDFTP_COPY,g_TURL,filename)
print "CMD: ",cmd
start_t=time.time()
output=getcmd(cmd)
end_t=int(time.time()-start_t)
print "OUTPUT: ",output
print "operation: %s=OK Durration:"%(operation),end_t
print "=================================================================================="
def getdiff(src,dest):
cmd="diff -s %s %s"%(src,dest)
print "CMD: ",cmd
output=getcmd(cmd)
print "OUTPUT: \n ",output
print "=============================================================================="
def getGet(u_token,SURL):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testGet *** "
operation="./srm2_testGet"
print commands.getoutput(operation)
cmd1="./srm2_testGet rfio %s %s"%(u_token,SURL)
cmd2="./srm2_testGet gsiftp %s %s"%(u_token,SURL)
cmds=[]
cmds.append(cmd1)
cmds.append(cmd2)
for cmd in cmds:
print
print "CMD: ",cmd
s_time=time.time()
output_4=getcmd(cmd)
end_time=time.time()-s_time
#print "OUTPUT->: ",output_4
#print " **************** "
dd=output_4.split('/n')
for j in range(0,len(dd)):
tt=dd[j].split()
for i in range(0,len(tt)):
if tt[i]=="r_token":
r_token=tt[i+1]
if cmd==cmd1:
f_token=r_token
print "r_token : ", tt[i+1]
else:
g_token=r_token
print "r_token : ", tt[i+1]
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "request state: ",state_req
if tt[i]=="23,":
code=tt[i][0:-1]
print "Status file: ",statusCode(int(code))
if tt[i]=="TURL":
#print "TURL: ",tt[i+2]
TURL_get=tt[i+2]
if cmd==cmd1:
x=TURL_get.split('//')[1:3]
f_TURL=':/'.join(x)
print "TURL[rfio]: %s"%f_TURL
else:
g_TURL=TURL_get
print "TURL[gsiftp]: %s"%g_TURL
if tt[i]=="explanation:":
x= tt[i:]
exp=" ".join(x)
print exp
print "state file: ",state_req
if int(state)!=26:
status="FAILED"
print "TEST FAILED with status %s"%(statusCode(int(state)))
sys.exit(1)
#elif (f_TURL or g_TURL)!=TURL:
#print "Mismatch: %s %s"%(TURL,f_TURL)
#sys.exit(1)
else:
status="OK"
print "test successful..."
print "operation: %s= %s Duration:"%(operation,status),int(end_time)
print "------------------------------------------------------"
return f_token,f_TURL,g_token,g_TURL
def getreleasefiles(f_token,SURL):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST:srm2_testReleaseFiles *** "
operation="./srm2_testReleaseFiles"
print commands.getoutput(operation)
cmd="./srm2_testReleaseFiles %s %s"%(f_token,SURL)
print "command: ",cmd
start_t=time.time()
output=getcmd(cmd)
end_t=start_t-time.time()
#print "OUTPUT: "
#print output
#print " ---------------- "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "state file: ",state_req
if tt[i]=="SURL":
print "SURL= ",tt[i+2]
if tt[i]=="23,":
code=tt[i][0:-1]
print "status file: ",statusCode(int(code))
if tt[i]=="explanation:":
x= tt[i:]
exp=" ".join(x)
print exp
if int(state)!=0:
status='OK'
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration:"%(operation),int(end_t)
print " ========================================================================= "
def getrequestsummary(endpoint,r_token,f_token,g_token):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testGetRequestSummary *** "
operation="./srm2_testGetRequestSummary"
print commands.getoutput(operation)
cmd="./srm2_testGetRequestSummary %s %s %s %s"%(endpoint,r_token,f_token,g_token)
print "command: ",cmd
start_t=time.time()
output_6=getcmd(cmd)
end_t=start_t-time.time()
print "OUTPUT->: ",output_6
print " ***************** "
g=output_6.split('/n')
for i in range(len(g)):
h=g[i].split()
for j in range(len(h)):
if "state"==h[j]:
state=h[j+1]
#print "request status: ",statusCode(int(state))
print "request status: ",statusCode(int(state))
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration:"%(operation),int(end_t)
print "==================================================================== "
def getmkdir(surl_base):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testMkdir *** "
operation="./srm2_testMkdir"
print commands.getoutput(operation)
cmd="./srm2_testMkdir %s"%(surl_base)+"srm2_newdir"
print "command: ",cmd
start_t=time.time()
output=getcmd(cmd)
end_t=int(time.time()-start_t)
#print output
#print " ************** "
g=output.split('/n')
for i in range(len(g)):
h=g[i].split()
for j in range(len(h)):
if h[j]=="state":
state=h[j+1]
print "state file: ",statusCode(int(state))
if h[j]=="explanation:":
x= h[j:]
exp=" ".join(x)
print exp
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration:"%(operation),end_t
print " ==================================================================== "
def getmv(src,dest):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testMv *** "
operation="./srm2_testMv"
print commands.getoutput(operation)
#print
cmd="./srm2_testMv %s %s"%(src,dest)
print "command: ",cmd
#start_t=time.time()
output=getcmd(cmd)
#end_t=time.time()-start_t()
#print "OUTPUT: ",output
#print " ************** "
g=output.split('/n')
for i in range(len(g)):
h=g[i].split()
for j in range(len(h)):
if h[j]=="state":
state=h[j+1]
print "state file: ",statusCode(int(state))
if h[j]=="explanation:":
x= h[j:]
exp=" ".join(x)
print exp
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration:"%(operation)
print "========================================================================== "
def getls(SURL):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testLs *** "
operation="./srm2_testLs"
print commands.getoutput(operation)
cmd="./srm2_testLs -l %s"%SURL
print "command: ",cmd
start_t=time.time()
output=getcmd(cmd)
end_t=int(time.time()-start_t)
print "OUTPUT: "
print output
aa=output.split('/n')
for k in range(len(aa)):
ss=aa[k].split()
for l in range(len(ss)):
if ss[l]=="state":
state=ss[l+1]
#print "state: ",state
code=int(state)
state_t=statusCode(code)
#print "state_t: ",state_t
#print "request state: ",state_t
print "state file: ",state_t
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration:"%(operation),end_t
print "======================================================================= "
def getrmdir(surl):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testRmdir *** "
operation="./srm2_testRmdir"
print commands.getoutput(operation)
#print
cmd="./srm2_testRmdir %s"%(surl)
print "command: ",cmd
start_t=time.time()
output=getcmd(cmd)
end_t=time.time()-start_t
#print "OUTPUT-> ",output
#print " ***************** "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "state file: ",state_req
if tt[i]=="explanation:":
x= tt[i:]
exp=" ".join(x)
print exp
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration: "%(operation),int(end_t)
print "========================================================================"
def getextendlifetime(f_token,SURL,sec):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testExtendFileLifeTime *** "
operation="./srm2_testExtendFileLifeTime"
print commands.getoutput(operation)
cmd="./srm2_testExtendFileLifeTime %s %s %i"%(f_token,SURL,sec)
print "command: ",cmd
#start_t=time.time()
output=getcmd(cmd)
#end_t=start_t-time.time()
#print "OUTPUT: ",output
#print " ********* "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "state file: ",state_req
if tt[i]=="time":
y=tt[i:]
time=" ".join(y)
print time
if tt[i]=="explanation:":
x= tt[i:]
exp=" ".join(x)
print exp
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration:"%(operation)
print "========================================================================"
def getreqId(endpoint,u_token):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testGetRequestID *** "
operation="./srm2_testGetRequestID"
print commands.getoutput(operation)
cmd="./srm2_testGetRequestID %s %s"%(endpoint,u_token)
print "command: ",cmd
#start_t=time.time()
output=getcmd(cmd)
#end_t=time.time()-start_t()
print "OUTPUT->: "
print output
print " ******** "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "state file: ",state_req
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration:"%(operation)
print "================================================================="
def getrm(surl):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testRm *** "
operation="./srm2_testRm"
print commands.getoutput(operation)
print
cmd="./srm2_testRm %s "%(surl)
print "command: ",cmd
start_t=time.time()
output=getcmd(cmd)
end_t=start_t-time.time()
print "OUTPUT->: "
#print output
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "state file: ",state_req
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration:"%(operation),end_t
print "================================================================"
def getsetpermission(SURL):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testSetPermission *** "
operation="./srm2_testSetPermission"
print commands.getoutput(operation)
cmd="./srm2_testSetPermission 2 7 5 %s 1 - dteam 5"%(SURL)
print "command: ",cmd
start_t=time.time()
output=getcmd(cmd)
end_t=start_t-time.time()
#print "OUTPUT-> ",output
#print " **************** "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "File state: ",state_req
if tt[i]=="explanation:":
x= tt[i:]
exp=" ".join(x)
print exp
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration:" %(operation),int(end_t)
print "========================================================================"
def getcheckpermission(SURL):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testCheckPermission *** "
operation="./srm2_testCheckPermission"
print commands.getoutput(operation)
cmd="./srm2_testCheckPermission %s"%(SURL)
print "command: ",cmd
#output=getcmd(cmd)
print "**** NOT YET IMPLEMENTED ****"
print "========================================================================"
def getAbortFiles(r_token,surl):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testAbortFiles *** "
operation="./srm2_testAbortFiles"
print commands.getoutput(operation)
cmd="./srm2_testAbortFiles %s %s"%(r_token,surl)
print "command: ",cmd
output=getcmd(cmd)
#print "OUTPUT-> ",output
#print " **************** "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "Request state: ",state_req
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration: "%(operation)
print "========================================================================"
def getSuspendRequest(r_token,surl):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testSuspendRequest *** "
operation="./srm2_testSuspendRequest"
print commands.getoutput(operation)
cmd="./srm2_testSuspendRequest %s %s"%(r_token,surl)
print "command: ",cmd
output=getcmd(cmd)
#print "OUTPUT-> ",output
#print " **************** "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "Request state: ",state_req
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration: "%(operation)
print "========================================================================"
def getRemoveFiles(r_token,surl):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testRemoveFiles *** "
operation="./srm2_testRemoveFiles"
print commands.getoutput(operation)
cmd="./srm2_testRemoveFiles %s %s"%(r_token,surl)
print "command: ",cmd
output=getcmd(cmd)
#print "OUTPUT-> ",output
#print " **************** "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "Request state: ",state_req
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration: "%(operation)
print "========================================================================"
def getAbortRequest(endpoint,r_token):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testAbortRequest *** "
operation="./srm2_testAbortRequest"
print commands.getoutput(operation)
cmd="./srm2_testAbortRequest %s %s"%(endpoint,r_token)
print "command: ",cmd
s_time=time.time()
output=getcmd(cmd)
end_t=time.time()-s_time
#print "OUTPUT-> ",output
#print " **************** "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "Request state: ",state_req
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration: "%(operation),int(end_t)
print "========================================================================"
def getsrm2_testCopy(u_token,src,dest):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testCopy *** "
operation="./srm2_testCopy"
print commands.getoutput(operation)
cmd="./srm2_testCopy %s %s %s"%(u_token,src,dest)
print "command: ",cmd
output=getcmd(cmd)
#print "OUTPUT-> ",output
#print " **************** "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "Request state: ",state_req
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration: "%(operation)
print "========================================================================"
def getResumeRequest(r_token,surl):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testResumeRequest *** "
operation="./srm2_testResumeRequest"
print commands.getoutput(operation)
cmd="./srm2_testResumeRequest %s %s "%(r_token,surl)
print "command: ",cmd
output=getcmd(cmd)
#print "OUTPUT-> ",output
#print " **************** "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "Request state: ",state_req
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration: "%(operation)
print "========================================================================"
def getReassignToUser(surl):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testReassignToUser *** "
operation="./srm2_testReassignToUser"
print commands.getoutput(operation)
cmd="./srm2_testReassignToUser fnaz 1000 %s "%(surl)
print "command: ",cmd
output=getcmd(cmd)
#print "OUTPUT-> ",output
#print " **************** "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "Request state: ",state_req
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration: "%(operation)
print "========================================================================"
def getChangeFileStorageType(surl):
s_date,s_time=gettime()
print "\n",s_date,s_time," *** TEST: srm2_testChangeFileStorageType *** "
operation="./srm2_testChangeFileStorageType"
print commands.getoutput(operation)
cmd="./srm2_testChangeFileStorageType 2 %sX"%(surl)
print "command: ",cmd
start_t=time.time()
output=getcmd(cmd)
end_t=time.time()-start_t
#print "OUTPUT-> ",output
#print " **************** "
x=output.split('/n')
for j in range(0,len(x)):
tt=x[j].split()
for i in range(0,len(tt)):
if tt[i]=="state":
state=tt[i+1]
code=int(state)
state_req=statusCode(code)
print "Request state: ",state_req
if int(state)!=0:
print "TEST FAILED with status %s"%(statusCode(int(state)))
else:
print "operation: %s=OK Duration:"%(operation),end_t
print "========================================================================"
def statusCode(code):
tuple=['SRM_SUCCESS', \
'SRM_FAILURE', \
'SRM_AUTHENTICATION_FAILURE', \
'SRM_UNAUTHORIZED_ACCESS', \
'SRM_INVALID_REQUEST', \
'SRM_INVALID_PATH', \
'SRM_FILE_LIFETIME_EXPIRED', \
'SRM_SPACE_LIFETIME_EXPIRED', \
'SRM_EXCEED_ALLOCATION', \
'SRM_NO_USER_SPACE', \
'SRM_NO_FREE_SPACE', \
'SRM_DUPLICATION_ERROR', \
'SRM_NON_EMPTY_DIRECTORY', \
'SRM_TOO_MANY_RESULTS', \
'SRM_INTERNAL_ERROR', \
'SRM_FATAL_INTERNAL_ERROR', \
'SRM_NOT_SUPPORTED', \
'SRM_REQUEST_QUEUED', \
'SRM_REQUEST_INPROGRESS', \
'SRM_REQUEST_SUSPENDED', \
'SRM_ABORTED', \
'SRM_RELEASED', \
'SRM_FILE_PINNED', \
'SRM_FILE_IN_CACHE', \
'SRM_SPACE_AVAILABLE', \
'SRM_LOWER_SPACE_GRANTED', \
'SRM_DONE', \
'SRM_CUSTOM_STATUS']
return tuple[code]
def usage():
print
print "Usage:",sys.argv[0],"[-s <SE>] [-d <pathdir>]"
print
print "-h --help <Displays the usage>"
print "-s --SE <target-SE>"
print "-d --pathdir <Dir name. e.g /dpm/cern.ch/home/dteam/.. > "
print
def getopts():
global SE,pathdir
try:
optlist, args = getopt.getopt(sys.argv[1:], "hs:d:", \
["help","targetSE=","pathdir"])
except:
usage()
sys.exit(1)
for o, a in optlist:
if o in ("-h", "--help"):
usage()
sys.exit(0)
if o in ("-s", "--SE"):
SE=a
if o in ("-d", "--pathdir"):
pathdir=a
if len(optlist) <2:
usage()
sys.exit(1)
if __name__ == "__main__":
#check the valid proxy
checkproxy()
main()
|