Skip to content

Commit c125c3d

Browse files
authored
Merge pull request #149 from efajardo/sw3359
SOFTWARE-3359 Add Xrootd multiuser tests
2 parents 3dfdf65 + 830077b commit c125c3d

File tree

4 files changed

+48
-22
lines changed

4 files changed

+48
-22
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
sudo: required
22
env:
33
matrix:
4-
- OS_TYPE=centos OS_VERSION=6 PACKAGES=osg-ce-condor,rsv,vo-client-lcmaps-voms,llrun
5-
- OS_TYPE=centos OS_VERSION=6 PACKAGES=osg-gridftp,rsv,lcmaps,lcmaps-db-templates,vo-client-lcmaps-voms,rsv,llrun
6-
- OS_TYPE=centos OS_VERSION=7 PACKAGES=osg-ce-condor,rsv,vo-client-lcmaps-voms,llrun,singularity-runtime,osg-oasis
7-
- OS_TYPE=centos OS_VERSION=7 PACKAGES=osg-gridftp,rsv,lcmaps,lcmaps-db-templates,vo-client-lcmaps-voms,rsv,llrun,singularity-runtime,osg-oasis
4+
- OS_TYPE=centos OS_VERSION=6 PACKAGES=osg-ce-condor,rsv,vo-client-lcmaps-voms,llrun
5+
- OS_TYPE=centos OS_VERSION=6 PACKAGES=osg-gridftp,rsv,lcmaps,lcmaps-db-templates,vo-client-lcmaps-voms,rsv,llrun
6+
- OS_TYPE=centos OS_VERSION=7 PACKAGES=osg-ce-condor,rsv,vo-client-lcmaps-voms,llrun,singularity-runtime,osg-oasis
7+
- OS_TYPE=centos OS_VERSION=7 PACKAGES=osg-gridftp,rsv,lcmaps,lcmaps-db-templates,vo-client-lcmaps-voms,rsv,llrun,singularity-runtime,osg-oasis
8+
- OS_TYPE=centos OS_VERSION=7 PACKAGES=xrootd,xrootd-client,xrootd-multiuser,globus-proxy-utils
89

910
services:
1011
- docker

osgtest/library/core.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -638,19 +638,25 @@ def get_hostname():
638638
except socket.error:
639639
return None
640640

641+
def check_file_ownership(file_path, owner_name):
642+
"""Return True if at 'file_path' exists, is owned by
643+
'owner_name' and is a file
644+
"""
645+
owner_uid = pwd.getpwnam(owner_name)
646+
try:
647+
file_stat = os.stat(file_path)
648+
return (file_stat.st_uid == owner_uid.pw_uid and
649+
stat.S_ISREG(file_stat.st_mode))
650+
except OSError: # file does not exist
651+
return False
641652

642653
def check_file_and_perms(file_path, owner_name, permissions):
643-
"""Return True if the file at 'file_path' exists, is owned by
644-
'owner_name', is a file, and has the given permissions; False otherwise
645-
"""
646-
owner_uid = pwd.getpwnam(owner_name)
647-
try:
648-
file_stat = os.stat(file_path)
649-
return (file_stat.st_uid == owner_uid and
650-
file_stat.st_mode & 0o7777 == permissions and
651-
stat.S_ISREG(file_stat.st_mode))
652-
except OSError: # file does not exist
653-
return False
654+
"""Return True if the file at 'file_path' exists, is owned by
655+
'owner_name', is a file, and has the given permissions; False otherwise
656+
"""
657+
file_stat = os.stat(file_path)
658+
return (check_file_ownership(file_path, owner_name) and
659+
file_stat.st_mode & 0o7777 == permissions)
654660

655661
def parse_env_output(output):
656662
"""

osgtest/tests/test_150_xrootd.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_01_start_xrootd(self):
3838
core.config['xrootd.config'] = '/etc/xrootd/xrootd-clustered.cfg'
3939
core.config['xrootd.port'] = XROOTD_PORT
4040
core.config['xrootd.gsi'] = "ON"
41+
core.config['xrootd.multiuser'] = "OFF"
4142
core.state['xrootd.started-server'] = False
4243
core.state['xrootd.backups-exist'] = False
4344

@@ -76,10 +77,20 @@ def test_02_configure_hdfs(self):
7677
hdfs_config = "ofs.osslib /usr/lib64/libXrdHdfs.so"
7778
files.append(core.config['xrootd.config'], hdfs_config, backup=False)
7879

79-
def test_03_start_xrootd(self):
80+
def test_03_configure_multiuser(self):
81+
core.skip_ok_unless_installed('xrootd-multiuser')
82+
core.config['xrootd.multiuser'] = "ON"
83+
# We need both multiuser and gsi part to test multiuser
84+
if core.config['xrootd.multiuser'] == "ON" and core.config['xrootd.gsi'] == "ON":
85+
xrootd_multiuser_conf = "xrootd.fslib libXrdMultiuser.so default"
86+
files.append(core.config['xrootd.config'], xrootd_multiuser_conf, owner='xrootd', backup=False)
87+
88+
def test_04_start_xrootd(self):
8089
core.skip_ok_unless_installed('xrootd', by_dependency=True)
8190
if core.el_release() < 7:
8291
core.config['xrootd_service'] = "xrootd"
92+
elif core.config['xrootd.multiuser'] == "ON":
93+
core.config['xrootd_service'] = "xrootd-privileged@clustered"
8394
else:
8495
core.config['xrootd_service'] = "xrootd@clustered"
8596

osgtest/tests/test_450_xrootd.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ def test_01_xrdcp_local_to_server(self):
1919
if core.config['xrootd.gsi'] == "ON":
2020
core.skip_ok_unless_installed('globus-proxy-utils')
2121
self.skip_bad_unless(core.state['xrootd.started-server'] is True, 'Server not running')
22-
22+
temp_dir = "/tmp/vdttest"
2323
hostname = socket.getfqdn()
2424
if core.config['xrootd.gsi'] == "ON":
25-
temp_dir = "/tmp/vdttest"
2625
if not os.path.exists(temp_dir):
2726
os.mkdir(temp_dir)
2827
user = pwd.getpwnam(core.options.username)
@@ -38,12 +37,21 @@ def test_01_xrdcp_local_to_server(self):
3837
fail = core.diagnose('xrdcp copy, local to URL',
3938
command, status, stdout, stderr)
4039
file_copied = os.path.exists(os.path.join(temp_dir, 'copied_file.txt'))
41-
shutil.rmtree(temp_dir)
42-
40+
if core.config['xrootd.multiuser'] != "ON":
41+
shutil.rmtree(temp_dir)
4342
self.assertEqual(status, 0, fail)
4443
self.assert_(file_copied, 'Copied file missing')
4544

46-
def test_02_xrdcp_server_to_local(self):
45+
def test_02_xrootd_multiuser(self):
46+
core.skip_ok_unless_installed('xrootd', 'xrootd-client', 'xrootd-multiuser', by_dependency=True)
47+
temp_dir = "/tmp/vdttest"
48+
if core.config['xrootd.multiuser'] == "ON":
49+
file_path = os.path.join(temp_dir, 'copied_file.txt')
50+
result_perm = core.check_file_ownership(file_path, core.options.username)
51+
shutil.rmtree(temp_dir)
52+
self.assertEqual(result_perm, True)
53+
54+
def test_03_xrdcp_server_to_local(self):
4755
core.skip_ok_unless_installed('xrootd', 'xrootd-client', by_dependency=True)
4856
if core.config['xrootd.gsi'] == "ON":
4957
core.skip_ok_unless_installed('globus-proxy-utils')
@@ -72,7 +80,7 @@ def test_02_xrdcp_server_to_local(self):
7280
self.assertEqual(status, 0, fail)
7381
self.assert_(file_copied, 'Copied file missing')
7482

75-
def test_03_xrootd_fuse(self):
83+
def test_04_xrootd_fuse(self):
7684
# This tests xrootd-fuse using a mount in /mnt
7785
core.skip_ok_unless_installed('xrootd', 'xrootd-client', by_dependency=True)
7886
self.skip_ok_unless(os.path.exists("/mnt"), "/mnt did not exist")

0 commit comments

Comments
 (0)