def setUp(self): ResourceBase.__init__(self) s.twousers_up() shutil.copy2('/bin/cp', RODSHOME + '/server/bin/cmd/mycp') shutil.copy2(FILESDIR + '/myWorkFlow', RODSHOME + '/server/bin/cmd/') shutil.copy2(FILESDIR + '/tt', RODSHOME + '/server/bin/cmd/') assertiCmd(s.adminsession, "iput -f " + FILESDIR + "/PHOTO.JPG /tempZone/home/rods") getiCmdOutput(s.adminsession, "irm -rf /tempZone/home/rods/workflow") assertiCmd(s.adminsession, "imkdir -p /tempZone/home/rods/workflow") self.run_resource_setup()
def test_rulemsiPhyBundleColl(self): rulefile = 'rulemsiPhyBundleColl.r' # rule test assertiCmd( s.adminsession, "irule -F " + rules30dir + rulefile, "LIST", "Create tar file of collection /tempZone/home/rods/test on resource testallrulesResc" ) # look for the bundle output = getiCmdOutput(s.adminsession, "ils -L /tempZone/bundle/home/rods") # last token in stdout should be the bundle file's full physical path bundlefile = output[0].split()[-1] # check on the bundle file's name assert bundlefile.find('test.') >= 0 # check physical path on resource assert os.path.isfile(bundlefile) # now try as a normal user (expect err msg) assertiCmd(s.sessions[1], "irule -F " + rules30dir + rulefile, "ERROR", "SYS_NO_API_PRIV") # cleanup s.adminsession.runCmd('irm', ['-rf', '/tempZone/bundle/home/rods'])
def test_iphybun_n(self): assertiCmd(s.adminsession, "imkdir testColl") assertiCmd(s.adminsession, "icd testColl") filenames = [] for i in range(0, 8): f = "empty" + str(i) + ".txt" filenames.append(f) cat(f, str(i)) assertiCmd(s.adminsession, "iput " + f) unlink(f) assertiCmd(s.adminsession, "icd ..") assertiCmd(s.adminsession, "iphybun -N3 -SdemoResc -RdemoResc testColl") coll_dir = getiCmdOutput(s.adminsession, "ils /tempZone/bundle/home/rods")[0].split('\n')[-2].lstrip(string.printable.translate(None, "/")) after = getiCmdOutput(s.adminsession, "ils " + coll_dir) after = after[0].split('\n'); assert(len(after) == 2 + 3) assertiCmd(s.adminsession, "irm -rf testColl" )
def test_ilsresc_tree(self): # Run ilsresc --tree output = getiCmdOutput(s.adminsession, "ilsresc --tree") # Print tree (might as well...) print output[0] # Check that stderr is empty assert len(output[1]) == 0
def test_iphybun_n(self): assertiCmd(s.adminsession, "imkdir testColl") assertiCmd(s.adminsession, "icd testColl") filenames = [] for i in range(0, 8): f = "empty" + str(i) + ".txt" filenames.append(f) pydevtest_common.cat(f, str(i)) assertiCmd(s.adminsession, "iput " + f) os.unlink(f) assertiCmd(s.adminsession, "icd ..") assertiCmd(s.adminsession, "iphybun -N3 -SdemoResc -RdemoResc testColl") coll_dir = getiCmdOutput( s.adminsession, "ils /tempZone/bundle/home/rods")[0].split('\n')[-2].lstrip(string.printable.translate(None, "/")) after = getiCmdOutput(s.adminsession, "ils " + coll_dir) after = after[0].split('\n') assert(len(after) == 2 + 3) assertiCmd(s.adminsession, "irm -rf testColl")
def test_iscan_local_file(self): assertiCmd( s.sessions[1], 'iscan non_existent_file', 'STDERR', 'ERROR: scanObj: non_existent_file does not exist' ) existent_file = os.path.join( s.sessions[1]._session_dir, 'existent_file' ) pydevtest_common.touch( existent_file ) assertiCmd( s.sessions[1], 'iscan ' + existent_file, 'STDOUT', existent_file + ' is not registered in iRODS' ) assertiCmd( s.sessions[1], 'iput ' + existent_file ); output = getiCmdOutput( s.sessions[1], '''iquest "SELECT DATA_PATH WHERE DATA_NAME = 'existent_file'"''' )[0] data_path = output.strip().strip('-').strip()[12:] assertiCmd( s.sessions[1], 'iscan ' + data_path ); assertiCmd( s.sessions[1], 'irm -f existent_file' );
def test_iscan_data_object(self): #test that rodsusers can't use iscan -d assertiCmd( s.sessions[1], 'iscan -d non_existent_file', 'STDOUT', 'Could not find the requested data object or collection in iRODS.' ) existent_file = os.path.join( s.sessions[1]._session_dir, 'existent_file' ) pydevtest_common.make_file( existent_file, 1 ) assertiCmd( s.sessions[1], 'iput ' + existent_file ); output = getiCmdOutput( s.adminsession, 'iquest "SELECT DATA_PATH WHERE DATA_NAME = \'existent_file\'"' )[0] data_path = output.strip().strip('-').strip()[12:] assertiCmd( s.sessions[1], 'iscan -d existent_file', 'STDOUT', 'User must be a rodsadmin to scan iRODS data objects.' ); os.remove( data_path ) assertiCmd( s.sessions[1], 'iscan -d existent_file', 'STDOUT', 'User must be a rodsadmin to scan iRODS data objects.' ); pydevtest_common.make_file( data_path, 1 ) assertiCmd( s.sessions[1], 'irm -f existent_file' ); zero_file = os.path.join( s.sessions[1]._session_dir, 'zero_file' ) pydevtest_common.touch( zero_file ) assertiCmd( s.sessions[1], 'iput ' + zero_file ); assertiCmd( s.sessions[1], 'iscan -d zero_file', 'STDOUT', 'User must be a rodsadmin to scan iRODS data objects.' ); assertiCmd( s.sessions[1], 'irm -f zero_file' ); #test that rodsadmins can use iscan -d assertiCmd( s.adminsession, 'iscan -d non_existent_file', 'STDOUT', 'Could not find the requested data object or collection in iRODS.' ) existent_file = os.path.join( s.adminsession._session_dir, 'existent_file' ) pydevtest_common.make_file( existent_file, 1 ) assertiCmd( s.adminsession, 'iput ' + existent_file ); output = getiCmdOutput( s.adminsession, '''iquest "SELECT DATA_PATH WHERE DATA_NAME = 'existent_file'"''' )[0] data_path = output.strip().strip('-').strip()[12:] assertiCmd( s.adminsession, 'iscan -d existent_file' ); os.remove( data_path ) assertiCmd( s.adminsession, 'iscan -d existent_file', 'STDOUT', 'is missing, corresponding to iRODS object' ); pydevtest_common.make_file( data_path, 1 ) assertiCmd( s.adminsession, 'irm -f existent_file' ); zero_file = os.path.join( s.adminsession._session_dir, 'zero_file' ) pydevtest_common.touch( zero_file ) assertiCmd( s.adminsession, 'iput ' + zero_file ); assertiCmd( s.adminsession, 'iscan -d zero_file' ); assertiCmd( s.adminsession, 'irm -f zero_file' );
def test_rulemsiPhyBundleColl(self): rulefile = 'rulemsiPhyBundleColl.r' # rule test assertiCmd(s.adminsession,"irule -F "+rules30dir+rulefile, "LIST", "Create tar file of collection /tempZone/home/rods/test on resource testallrulesResc") # look for the bundle output = getiCmdOutput(s.adminsession, "ils -L /tempZone/bundle/home/rods") # last token in stdout should be the bundle file's full physical path bundlefile = output[0].split()[-1] # check on the bundle file's name assert bundlefile.find('test.') >= 0 # check physical path on resource assert os.path.isfile(bundlefile) # now try as a normal user (expect err msg) assertiCmd(s.sessions[1],"irule -F "+rules30dir+rulefile, "ERROR", "SYS_NO_API_PRIV") # cleanup s.adminsession.runCmd('irm', ['-rf', '/tempZone/bundle/home/rods'])
def test_rebalance_for_object_count(self): # =-=-=-=-=-=-=- # read server_config.json and .odbc.ini cfg = ServerConfig() root_dir = "/tmp/irods/big_dir" if os.path.exists(root_dir): shutil.rmtree(root_dir) os.makedirs(root_dir) for i in range(30): path = root_dir + "/rebalance_testfile_" + str(i) output = commands.getstatusoutput('dd if=/dev/zero of=' + path + ' bs=1M count=1') print output[1] assert output[0] == 0, "dd did not successfully exit" # get initial object count initial_output = getiCmdOutput(s.adminsession, "iadmin lr demoResc") objcount_line = initial_output[0].splitlines()[-1] initial_objcount = int(objcount_line.split(":")[-1].strip()) print "initial: " + str(initial_objcount) # put the new files assertiCmd(s.adminsession, "iput -r " + root_dir) # =-=-=-=-=-=-=- # drop several rows from the R_DATA_MAIN table to jkjjq:q cfg.exec_sql_cmd("delete from R_DATA_MAIN where data_name like 'rebalance_testfile_1%'") # rebalance assertiCmd(s.adminsession, "iadmin modresc demoResc rebalance") # expected object count expected_objcount = initial_objcount + 19 # 19 = 30 initial - 11 (1 and 10 through 19) deleted files print "expected: " + str(expected_objcount) assertiCmd(s.adminsession, "iadmin lr demoResc", "LIST", "resc_objcount: " + str(expected_objcount))
def test_ilsresc_tree_with_ascii_output(self): # Run ilsresc --tree with ascii output output = getiCmdOutput(s.adminsession, "ilsresc --tree --ascii") # Check that stderr is empty assert len(output[1]) == 0
def test_ilsresc_tree(self): # Run ilsresc --tree output = getiCmdOutput(s.adminsession, "ilsresc --tree") # Check that stderr is empty assert len(output[1]) == 0