#!/bin/env python #copytest.py #Marco Mambelli """Test for copy tools """ import commands from timed_command import timed_command from futil import * timeout = 60*10 # 10 min # class for options class MyOpt: pass opt = MyOpt() del MyOpt opt.verbose = 3 # verbosity level: 0 ... opt.addtoname = '' # string added to output file name to help with name uniqueness (to run multiple tests opt.runtestsetup = False #True opt.dryrun = False #True #opt.addtoname = 't2.' # string added to output file name to help with name uniqueness (to run multiple tests if opt.addtoname: opt.runtestsetup = False # General setup (prepare directories, ...) test_setup_str = "rm -rf /tmp/marco/cptest; mkdir -p /tmp/marco/cptest; \ echo 'Remember to delete on uct3-edge3 /pnfs/uct3/test/cptestmarco-* uct2-grid6 /pnfs/uchicago.edu/test/cptestmarco-*'" default_setup = 'source /local/inst2/wlcg-client080725/setup.sh' # /share/wlcg-client/setup.sh' """ srmcp: -streams_num= -srm_protocol_version= -pushmode= -space_token= -server_mode= -cksm_type= calculate and verify server and client checksum values using this type (adler32|MD4|MD5| .... ). If checksum value has been omitted, missing value will be computed over the local file. If negotiate is set - client will attempt to negotiate cksm type for the file checksum value avilable at the server. For gridftp transfers to/from servers that support checksumming features -cksm_value= override dynamic calucation of the local checksum with this value. If cksm_type option has not been set, adler32 will be assumed. For gridftp transfers to/from servers that support checksumming features srm-copy: -spacetoken (valid space token returned by srm-space request, used to put a file in the reserved space, or get a file from the reserved space.) ngcp: -p, -passive -r, -recursive level operate recursively (if possible) up to specified level (0 - no recursion) -R, -retries number how many times to retry transfer of every file before failing -d -3 ... 3 lcg-cp: export LCG_GFAL_INFOSYS=lcg-bdii.cern.ch:2170 lcg-cp [-h,--help] [-i,--insecure] [-c,--config config_file] [-n nbstreams] [-s,--sst src_spacetokendesc] [-S,--dst dest_spacetokendesc] [-D,--defaultsetype se|srmv1|srmv2] [-T,--srcsetype se|srmv1|srmv2] [-U,--dstsetype se|srmv1|srmv2] [-b,--nobdii] [-t timeout] [-v,--verbose] [-V,--vo vo] [--version] src_file dest_file """ lcg_cp_setup = '%s; export LCG_GFAL_INFOSYS="lcg-bdii.cern.ch:2170"' % (default_setup) copy_commands = { 'globus': ['', 'globus-url-copy' ], 'lcg': [lcg_cp_setup, 'lcg-cp', ], 'lcg2': ['', 'lcg-cp -b', ], 'lcg3': ['', 'lcg-cp -b -T srmv1', ], 'lcg4': ['', 'lcg-cp -b -T srmv2', ], 'lcg5': ['', 'lcg-cp -b --vo atlas', ], 'nordugrid': ['source /local/inst2/ng080721/nordugrid-arc-standalone-0.6.3/setup.sh /local/inst2/ng080721/nordugrid-arc-standalone-0.6.3/', 'ngcp -d 2', ], 'srmf': ['', 'srmcp', ], 'srmf2': ['', 'srmcp -2', ], 'srmf3': ['', 'srmcp -1', ], 'srmf4': ['', 'srmcp -streams_num=1', ], 'srml': ['', 'srm-copy', ], 'srmg': ['source /share/glite/glite/etc/profile.d/grid-env.sh', 'glite-srm-get', ], } # print header print "*SITE TEST" testname= "sitetest1_" if opt.runtestsetup: if opt.dryrun: print "No setup - dryrun - would be: ", test_setup_str else: pass # ec, out = commands.getstatusoutput(test_setup_str) # if opt.verbose>0 or ec<>0: # print "Test Setup (", ec, "): ", out site_list = [ 'SWT2_CPB_DATADISK', 'SLACXRD_DATADISK', 'WISC', 'AGLT2_DATADISK', 'MWT2_DATADISK', 'NET2_DATADISK', 'BNL-OSG2_DATADISK', 'BNLXRDHDD1', ] site_skip = [] test_opt = { 'def': '', 'srm': '-p srm', 'lcg': '-p lcg', } prep_command = "mkdir %s; cd %s;" test_setup = "" #too big 2.1G test_command = "time dq2-get -L UCT3 -s %s %s -f fdr08_run2.0052304.physics_Jet.merge.AOD.o3_f8_m10._0001.1 fdr08_run2.0052304.physics_Jet.merge.AOD.o3_f8_m10 >& dq2gettest.log" test_command = "time dq2-get -L UCT3 -s %s %s -f fdr08_run2.0052304.physics_Jet.merge.AOD.o3_f8_m10._0020.1 fdr08_run2.0052304.physics_Jet.merge.AOD.o3_f8_m10 >& dq2gettest.log" results = {} if opt.verbose>1: print "***** EXECUTION:" for i in site_list: results[i] = [] first_test = True for j in test_opt.items(): dirname = "%s%s%s" % (testname, i, j[0]) cmd_str = prep_command % (dirname, dirname) cmd_str += test_setup cmd_str += test_command % (i, j[1]) if opt.verbose>0: if first_test or opt.verbose>1: print "Executing: ", cmd_str ec = -1 if not opt.dryrun: try: # ec, out = commands.getstatusoutput(c_line) ec, telapsed, cout, cerr = timed_command(cmd_str, timeout) out = cerr+cout if ec != 0: check_syserr(ec, out) if is_timeout(ec): if opt.verbose>0: print "Timed out!" # return ERR_TIMEOUT if opt.verbose>0: if first_test or opt.verbose>1: print "Testing %s/%s in %s (%s): %s" % (i, j[0], telapsed, ec, out) except: print get_exc() first_test = False results[i].append(ec == 0) print "***** TEST RESULTS:" print "Tests: \t", [ i for i in site_list if i not in site_skip] for i in results.items(): print i[0], ": \t", i[1]