Skip to content

Commit

Permalink
[irods#3988][irods#4009][irods#4013] test cases for three issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Kelly committed Jul 16, 2018
1 parent 1a897d1 commit 8d2b316
Show file tree
Hide file tree
Showing 10 changed files with 1,114 additions and 82 deletions.
5 changes: 3 additions & 2 deletions scripts/irods/test/test_chunkydevtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import shutil
import random
import subprocess
import ustrings

from . import session
from .. import test
Expand Down Expand Up @@ -526,7 +527,7 @@ def test_phybun_from_devtest(self):
shutil.copyfile(progname, mysfile)

# iphybun test
self.admin.assert_icommand("iput -rR " + self.testresc + " " + mysdir + " " + irodshome + "/icmdtestp")
self.admin.assert_icommand("iput -rR " + self.testresc + " " + mysdir + " " + irodshome + "/icmdtestp", "STDOUT_SINGLELINE", ustrings.recurse_ok_string())
self.admin.assert_icommand("iphybun -KR " + self.anotherresc + " " + irodshome + "/icmdtestp")
self.admin.assert_icommand("itrim -rS " + self.testresc + " -N1 " +
irodshome + "/icmdtestp", 'STDOUT_SINGLELINE', "files trimmed")
Expand Down Expand Up @@ -725,7 +726,7 @@ def test_large_files_from_devtest(self):
shutil.rmtree(dir_w + "/testz")
self.admin.assert_icommand("iget -vPKr --retries 10 -X " + rsfile + " --lfrestart " + lrsfile +
" --rlock -N 2 " + irodshome + "/icmdtest/testz " + dir_w + "/testz", 'STDOUT_SINGLELINE', "testz")
self.admin.assert_icommand("irsync -r " + dir_w + "/testz i:" + irodshome + "/icmdtest/testz")
self.admin.assert_icommand("irsync -r " + dir_w + "/testz i:" + irodshome + "/icmdtest/testz", "STDOUT_SINGLELINE", ustrings.recurse_ok_string())
self.admin.assert_icommand("irsync -r i:" + irodshome + "/icmdtest/testz " + dir_w + "/testz")
if os.path.isfile(lrsfile):
os.unlink(lrsfile)
Expand Down
21 changes: 11 additions & 10 deletions scripts/irods/test/test_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import time
import shutil
import socket
import ustrings

from .. import test
from . import settings
Expand Down Expand Up @@ -218,7 +219,7 @@ def test_slow_ils_over_federation__ticket_3215(self):

# put dir in remote collection
test_session.assert_icommand(
"iput -r {dir_path} {remote_home_collection}/".format(**parameters))
"iput -r {dir_path} {remote_home_collection}/".format(**parameters), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# time listing of collection
t0 = time.time()
Expand Down Expand Up @@ -254,7 +255,7 @@ def test_iput_r(self):

# put dir in remote collection
test_session.assert_icommand(
"iput -r {dir_path} {remote_home_collection}/".format(**parameters))
"iput -r {dir_path} {remote_home_collection}/".format(**parameters), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# new collection should be there
test_session.assert_icommand(
Expand Down Expand Up @@ -378,7 +379,7 @@ def test_iget_r(self):

# put dir in remote collection
test_session.assert_icommand(
"iput -r {dir_path} {remote_home_collection}/".format(**parameters))
"iput -r {dir_path} {remote_home_collection}/".format(**parameters), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# remove local test dir
shutil.rmtree(dir_path)
Expand Down Expand Up @@ -425,7 +426,7 @@ def test_iget_from_bundle(self):

# put dir in remote collection
remote_session.assert_icommand(
"iput -fr {dir_path} {remote_home_collection}/".format(**parameters))
"iput -fr {dir_path} {remote_home_collection}/".format(**parameters), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# new collection should be there
remote_session.assert_icommand(
Expand Down Expand Up @@ -500,7 +501,7 @@ def test_irm_rf(self):

# put dir in remote collection
test_session.assert_icommand(
"iput -r {dir_path} {remote_home_collection}/".format(**parameters))
"iput -r {dir_path} {remote_home_collection}/".format(**parameters), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# new collection should be there
test_session.assert_icommand(
Expand Down Expand Up @@ -698,7 +699,7 @@ def test_icp_r(self):

# put dir in local collection
test_session.assert_icommand(
"iput -r {dir_path} {local_home_collection}/".format(**parameters))
"iput -r {dir_path} {local_home_collection}/".format(**parameters), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# remove local test dir
shutil.rmtree(dir_path)
Expand Down Expand Up @@ -795,7 +796,7 @@ def test_irsync_r_dir_to_coll(self):

# sync dir with remote collection
test_session.assert_icommand(
"irsync -r {dir_path} i:{remote_home_collection}/{dir_name}".format(**parameters))
"irsync -r {dir_path} i:{remote_home_collection}/{dir_name}".format(**parameters), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# new collection should be there
test_session.assert_icommand(
Expand Down Expand Up @@ -831,7 +832,7 @@ def test_irsync_r_coll_to_coll(self):

# put dir in local collection
test_session.assert_icommand(
"iput -r {dir_path} {local_home_collection}/".format(**parameters))
"iput -r {dir_path} {local_home_collection}/".format(**parameters), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# remove local test dir
shutil.rmtree(dir_path)
Expand Down Expand Up @@ -883,7 +884,7 @@ def test_irsync_r_coll_to_dir(self):

# sync dir with remote collection
test_session.assert_icommand(
"irsync -r {dir_path} i:{remote_home_collection}/{dir_name}".format(**parameters))
"irsync -r {dir_path} i:{remote_home_collection}/{dir_name}".format(**parameters), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# remove local test dir
shutil.rmtree(dir_path)
Expand Down Expand Up @@ -1131,7 +1132,7 @@ def test_msirmcoll(self):

# put dir in remote collection
test_session.assert_icommand(
"iput -r {dir_path} {remote_home_collection}/".format(**parameters))
"iput -r {dir_path} {remote_home_collection}/".format(**parameters), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# new collection should be there
test_session.assert_icommand(
Expand Down
5 changes: 3 additions & 2 deletions scripts/irods/test/test_iadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import subprocess
import time
import tempfile
import ustrings

from ..configuration import IrodsConfig
from ..controller import IrodsController
Expand Down Expand Up @@ -279,8 +280,8 @@ def test_resource_hierarchy_manipulation(self):
lib.create_directory_of_small_files(dir2, tree2)

# add files
self.admin.assert_icommand("iput -R %s -r %s" % ("pt", dir1))
self.admin.assert_icommand("iput -R %s -r %s" % ("replB", dir2))
self.admin.assert_icommand("iput -R %s -r %s" % ("pt", dir1), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())
self.admin.assert_icommand("iput -R %s -r %s" % ("replB", dir2), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# debugging
self.admin.assert_icommand("ils -L %s" % dir1, 'STDOUT_SINGLELINE', dir1)
Expand Down
30 changes: 15 additions & 15 deletions scripts/irods/test/test_icommands_file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@
import inspect
import logging
import os
import pprint
import tempfile
import time
import shutil
import ustrings

from ..configuration import IrodsConfig
from ..controller import IrodsController
from ..core_file import temporary_core_file
from .. import paths
from .. import test
from . import settings
from .. import lib
from . import resource_suite
from .rule_texts_for_tests import rule_texts
Expand All @@ -43,7 +42,7 @@ def tearDown(self):
def iput_r_large_collection(self, user_session, base_name, file_count, file_size):
local_dir = os.path.join(self.testing_tmp_dir, base_name)
local_files = lib.make_large_local_tmp_dir(local_dir, file_count, file_size)
user_session.assert_icommand(['iput', '-r', local_dir])
user_session.assert_icommand(['iput', '-r', local_dir], "STDOUT_SINGLELINE", ustrings.recurse_ok_string())
rods_files = set(user_session.get_entries_in_collection(base_name))
self.assertTrue(set(local_files) == rods_files,
msg="Files missing:\n" + str(set(local_files) - rods_files) + "\n\n" +
Expand Down Expand Up @@ -98,7 +97,7 @@ def test_get_null_perms__2833(self):
base_name = 'test_dir_for_perms'
local_dir = os.path.join(self.testing_tmp_dir, base_name)
local_files = lib.make_large_local_tmp_dir(local_dir, 30, 10)
self.admin.assert_icommand(['iput', '-r', local_dir])
self.admin.assert_icommand(['iput', '-r', local_dir], "STDOUT_SINGLELINE", ustrings.recurse_ok_string())
ils_out, _, _ = self.admin.run_icommand(['ils', base_name])
rods_files = [f for f in lib.get_object_names_from_entries(ils_out)]

Expand Down Expand Up @@ -137,7 +136,7 @@ def test_irm_rf_nested_coll(self):
local_dirs = lib.make_deep_local_tmp_dir(local_dir, depth, files_per_level, file_size)

# iput dir
self.user0.assert_icommand("iput -r {local_dir}".format(**locals()), "EMPTY")
self.user0.assert_icommand("iput -r {local_dir}".format(**locals()), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# force remove collection
self.user0.assert_icommand("irm -rf {coll_name}".format(**locals()), "EMPTY")
Expand Down Expand Up @@ -168,7 +167,7 @@ def test_iput_r_with_kw(self):
initial_size_of_server_log = lib.get_file_size_by_path(IrodsConfig().server_log_path)

# iput dir
self.user0.assert_icommand("iput -r {local_dir}".format(**locals()), "EMPTY")
self.user0.assert_icommand("iput -r {local_dir}".format(**locals()), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# look for occurences of debug sequences in the log
rec_op_kw_string = 'DEBUG: unix_file_resolve_hierarchy: recursiveOpr = [1]'
Expand Down Expand Up @@ -260,7 +259,7 @@ def test_irsync_r_dir_to_coll(self):
local_dir = os.path.join(self.testing_tmp_dir, base_name)
file_names = set(lib.make_large_local_tmp_dir(local_dir, file_count=1000, file_size=100))

self.user0.assert_icommand("irsync -r " + local_dir + " i:" + base_name, "EMPTY")
self.user0.assert_icommand("irsync -r " + local_dir + " i:" + base_name, "STDOUT_SINGLELINE", ustrings.recurse_ok_string())
self.user0.assert_icommand("ils", 'STDOUT_SINGLELINE', base_name)
rods_files = set(self.user0.get_entries_in_collection(base_name))
self.assertTrue(file_names == rods_files,
Expand Down Expand Up @@ -342,7 +341,7 @@ def test_irsync_r_nested_dir_to_coll(self):
local_dirs = lib.make_deep_local_tmp_dir(local_dir, depth, files_per_level, file_size)

# sync dir to coll
self.user0.assert_icommand("irsync -r {local_dir} i:{base_name}".format(**locals()), "EMPTY")
self.user0.assert_icommand("irsync -r {local_dir} i:{base_name}".format(**locals()), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# compare files at each level
for dir, files in local_dirs.items():
Expand Down Expand Up @@ -378,7 +377,7 @@ def test_irsync_r_nested_dir_to_coll_large_files(self):
local_dirs = lib.make_deep_local_tmp_dir(local_dir, depth, files_per_level, file_size)

# sync dir to coll
self.user0.assert_icommand("irsync -r {local_dir} i:{base_name}".format(**locals()), "EMPTY")
self.user0.assert_icommand("irsync -r {local_dir} i:{base_name}".format(**locals()), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# compare files at each level
for dir, files in local_dirs.items():
Expand Down Expand Up @@ -415,7 +414,7 @@ def test_irsync_r_nested_coll_to_coll(self):
local_dirs = lib.make_deep_local_tmp_dir(local_dir, depth, files_per_level, file_size)

# iput dir
self.user0.assert_icommand("iput -r {local_dir}".format(**locals()), "EMPTY")
self.user0.assert_icommand("iput -r {local_dir}".format(**locals()), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# sync collections
self.user0.assert_icommand("irsync -r i:{source_base_name} i:{dest_base_name}".format(**locals()), "EMPTY")
Expand Down Expand Up @@ -474,7 +473,7 @@ def test_irsync_r_nested_coll_to_coll_large_files(self):
local_dirs = lib.make_deep_local_tmp_dir(local_dir, depth, files_per_level, file_size)

# iput dir
self.user0.assert_icommand("iput -r {local_dir}".format(**locals()), "EMPTY")
self.user0.assert_icommand("iput -r {local_dir}".format(**locals()), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# sync collections
self.user0.assert_icommand("irsync -r i:{source_base_name} i:{dest_base_name}".format(**locals()), "EMPTY")
Expand Down Expand Up @@ -532,7 +531,7 @@ def test_irsync_r_nested_coll_to_dir(self):
local_dirs = lib.make_deep_local_tmp_dir(local_dir, depth, files_per_level, file_size)

# sync dir to coll
self.user0.assert_icommand("irsync -r {local_dir} i:{base_name}".format(**locals()), "EMPTY")
self.user0.assert_icommand("irsync -r {local_dir} i:{base_name}".format(**locals()), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# remove local coll
shutil.rmtree(local_dir)
Expand Down Expand Up @@ -574,7 +573,7 @@ def test_irsync_r_nested_coll_to_dir_large_files(self):
local_dirs = lib.make_deep_local_tmp_dir(local_dir, depth, files_per_level, file_size)

# sync dir to coll
self.user0.assert_icommand("irsync -r {local_dir} i:{base_name}".format(**locals()), "EMPTY")
self.user0.assert_icommand("irsync -r {local_dir} i:{base_name}".format(**locals()), "STDOUT_SINGLELINE", ustrings.recurse_ok_string())

# remove local coll
shutil.rmtree(local_dir)
Expand Down Expand Up @@ -657,15 +656,15 @@ def test_iput_bulk_check_acpostprocforput__2841(self):
dirname = self.admin.local_session_dir + '/files'
# files less than 4200000 were failing to trigger the writeLine
for filesize in range(5000, 6000000, 500000):
files = lib.make_large_local_tmp_dir(dirname, number_of_files, filesize)
lib.make_large_local_tmp_dir(dirname, number_of_files, filesize)
# manipulate core.re and check the server log
with temporary_core_file() as core:
time.sleep(1) # remove once file hash fix is committed #2279
core.add_rule(rule_texts[self.plugin_name][self.class_name][inspect.currentframe().f_code.co_name])
time.sleep(1) # remove once file hash fix is committed #2279

initial_size_of_server_log = lib.get_file_size_by_path(paths.server_log_path())
self.admin.assert_icommand(['iput', '-frb', dirname])
self.admin.assert_icommand(['iput', '-frb', dirname], "STDOUT_SINGLELINE", ustrings.recurse_ok_string())
assert number_of_files == lib.count_occurrences_of_string_in_log(paths.server_log_path(), 'writeLine: inString = acPostProcForPut called for', start_index=initial_size_of_server_log)
shutil.rmtree(dirname)

Expand Down Expand Up @@ -906,3 +905,4 @@ def test_ichksum_admin_flag__3265(self):

os.unlink(filename1)
os.unlink(filename2)

46 changes: 12 additions & 34 deletions scripts/irods/test/test_iput_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from .resource_suite import ResourceBase
from .. import lib
from .. import test

class Test_iPut_Options(ResourceBase, unittest.TestCase):

Expand Down Expand Up @@ -108,42 +107,21 @@ def test_iput_r_bad_permissions__issue_3583(self):

os.chmod(os.path.join(bad_sub_dir), 0)

self.admin.assert_icommand('iput -r ' + test_dir, 'STDERR_SINGLELINE', 'Permission denied')
self.admin.assert_icommand('ils test_dir', 'STDOUT_SINGLELINE', 'good_sub_dir')
self.admin.assert_icommand('ils test_dir/good_sub_dir', 'STDOUT_SINGLELINE', 'a.txt')
# Issue 3988: the iput -r will fail during prescan, which means
# that no data transfer will occur at all. The ils command below
# should therefore fail.
cmd = 'iput -r ' + test_dir
_,stderr,_ = self.admin.run_icommand( cmd )
self.assertIn( 'directory error: Permission denied',
stderr,
"{0}: Expected stderr: \"...{1}...\", got: \"{2}\"".format(cmd, 'directory error: Permission denied', stderr))

self.admin.assert_icommand('ils test_dir', 'STDOUT_SINGLELINE', 'test_dir')
self.admin.assert_icommand_fail('ils test_dir/good_sub_dir', 'STDOUT_SINGLELINE', 'a.txt')

finally:
os.chmod(bad_sub_dir, stat.S_IRWXU)
os.chmod(os.path.join(test_dir, "bad_file"), stat.S_IWRITE)
os.chmod(os.path.join(bad_sub_dir, "bad_file"), stat.S_IWRITE)
os.chmod(os.path.join(good_sub_dir, "bad_file"), stat.S_IWRITE)

@unittest.skipIf(test.settings.RUN_IN_TOPOLOGY, "Skip for Topology Testing")
def test_iput_ignore_symbolic_links__issue_3072(self):
# The root directory where all files and symlinks will be stored.
parent_dir = 'issue_3072_parent_dir'
parent_dir_path = os.path.join(self.admin.local_session_dir, parent_dir)
os.mkdir(parent_dir_path)

filename = "test_file.txt"
filename_path = os.path.join(parent_dir_path, filename)
lib.make_file(filename_path, 1024)

# This directory will hold the symlink.
child_dir_path = os.path.join(parent_dir_path, 'child_dir')
os.mkdir(child_dir_path)

# Create a symlink.
dangling_symlink = 'dangling.test_file.txt'
dangling_symlink_path = os.path.join(child_dir_path, dangling_symlink)
os.symlink(filename_path, dangling_symlink_path)

# Break the symlink by renaming the target file.
os.rename(filename_path, os.path.join(parent_dir_path, 'renamed.test_file.txt'))

# Recursively put all directories and files under the
# parent directory. Symlinks should be completely ignored.
self.admin.assert_icommand('iput -r --link {0}'.format(parent_dir_path))

# Fail if the dangling symlink was stored in iRODS.
self.admin.assert_icommand_fail('ils -lr {0}'.format(parent_dir), 'STDOUT', dangling_symlink)

Loading

0 comments on commit 8d2b316

Please sign in to comment.