Skip to content

Commit 5a54660

Browse files
authored
Merge pull request #5 from opensciencegrid/master
Keep my fork up to date
2 parents 4d18182 + 2ef231f commit 5a54660

19 files changed

+417
-49
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

files/test_sequence

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test_110_condor_cron
99
test_130_gridftp
1010
test_140_lcmaps
1111
test_150_xrootd
12+
test_155_stashcache
1213
test_160_rsv
1314
test_170_pbs
1415
test_180_cvmfs
@@ -25,13 +26,14 @@ test_290_slurm
2526
test_300_misc
2627
test_380_cvmfs
2728
test_400_proxy
28-
test_480_myproxy
29-
test_500_voms
29+
test_403_myproxy
30+
test_407_voms
3031
test_410_jobs
3132
test_420_gridftp
3233
test_430_uberftp
3334
test_440_glexec
3435
test_450_xrootd
36+
test_460_stashcache
3537
test_470_rsv
3638
test_490_jobs
3739
test_510_edgmkgridmap
@@ -50,6 +52,7 @@ test_790_condorce
5052
test_800_gratia
5153
test_820_cvmfs
5254
test_830_rsv
55+
test_835_stashcache
5356
test_840_xrootd
5457
test_850_lcmaps
5558
test_860_gridftp

osg-test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ if __name__ == '__main__':
229229

230230
# Check for osg-ca-generator, which may have been forgotten in a source install
231231
try:
232-
__import__('cagen')
232+
import cagen
233233
except ImportError:
234234
sys.exit("Cannot find 'cagen' library. Please install osg-ca-generator")
235235

@@ -254,5 +254,6 @@ if __name__ == '__main__':
254254
signal.signal(signal.SIGALRM, signal.SIG_DFL)
255255
else:
256256
print('No tests to run.')
257+
EXIT_CODE = 1
257258
wrap_up()
258259
sys.exit(EXIT_CODE)

osgtest/library/core.py

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,17 @@ def version_compare(evr1, evr2):
416416
as a 3-element tuple or list.
417417
418418
"""
419-
if isinstance(evr1, basestring):
419+
if is_string(evr1):
420420
epoch1, version1, release1 = stringToVersion(evr1)
421+
elif isinstance(evr1, bytes):
422+
epoch1, version1, release1 = stringToVersion(evr1.decode())
421423
else:
422424
epoch1, version1, release1 = evr1
423425

424-
if isinstance(evr2, basestring):
426+
if is_string(evr2):
425427
epoch2, version2, release2 = stringToVersion(evr2)
428+
elif isinstance(evr2, bytes):
429+
epoch2, version2, release2 = stringToVersion(evr2.decode())
426430
else:
427431
epoch2, version2, release2 = evr2
428432

@@ -634,19 +638,28 @@ def get_hostname():
634638
except socket.error:
635639
return None
636640

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
637652

638653
def check_file_and_perms(file_path, owner_name, permissions):
639-
"""Return True if the file at 'file_path' exists, is owned by
640-
'owner_name', is a file, and has the given permissions; False otherwise
641-
"""
642-
owner_uid = pwd.getpwnam(owner_name)
643-
try:
644-
file_stat = os.stat(file_path)
645-
return (file_stat.st_uid == owner_uid and
646-
file_stat.st_mode & 0o7777 == permissions and
647-
stat.S_ISREG(file_stat.st_mode))
648-
except OSError: # file does not exist
649-
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+
try:
658+
file_stat = os.stat(file_path)
659+
return (check_file_ownership(file_path, owner_name) and
660+
file_stat.st_mode & 0o7777 == permissions)
661+
except OSError: # file does not exist
662+
return False
650663

651664
def parse_env_output(output):
652665
"""
@@ -755,3 +768,12 @@ def run_fn_if_el_release_ok(*args, **kwargs):
755768
return run_fn_if_el_release_ok
756769
return el_release_decorator
757770

771+
772+
try:
773+
unicode
774+
except NameError: # python 3
775+
unicode = str
776+
777+
778+
def is_string(var):
779+
return isinstance(var, (str, unicode))

osgtest/library/files.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,12 @@ def filesBackedup(path, owner):
237237
return True
238238
else:
239239
return False
240+
241+
242+
def safe_makedirs(directory, mode=0o777):
243+
"""Create a directory and all its parent directories, unless it already
244+
exists.
245+
246+
"""
247+
if not os.path.isdir(directory):
248+
os.makedirs(directory, mode)

osgtest/library/osgunittest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@
1212
import unittest
1313
import time
1414

15+
16+
# Copied from unittest.util, Python 3.6
17+
_MAX_LENGTH = 80
18+
def safe_repr(obj, short=False):
19+
try:
20+
result = repr(obj)
21+
except Exception:
22+
result = object.__repr__(obj)
23+
if not short or len(result) < _MAX_LENGTH:
24+
return result
25+
return result[:_MAX_LENGTH] + ' [truncated]...'
26+
27+
1528
# Define the classes we need to handle the two new types of test results: ok
1629
# skip, and bad skip.
1730

@@ -111,6 +124,14 @@ def failIfSubsetOf(self, a, b, message=None):
111124
if set(a).issubset(set(b)):
112125
raise AssertionError(message)
113126

127+
def assertEqualVerbose(self, actual, expected, message=None):
128+
aftermessage = "actual %s != expected %s" % (safe_repr(actual), safe_repr(expected))
129+
if message:
130+
fullmessage = "%s (%s)" % (message, aftermessage)
131+
else:
132+
fullmessage = aftermessage
133+
self.assertEqual(actual, expected, fullmessage)
134+
114135
# This is mostly a copy of the method from unittest in python 2.4.
115136
# There is some code here to test if the 'result' object accepts 'skips',
116137
# since the original TestResult object does not. If it does not, an

osgtest/tests/test_100_condor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class TestStartCondor(osgunittest.OSGTestCase):
1515

1616
def test_01_start_condor(self):
17+
core.state['condor.started-service'] = False
1718
core.state['condor.running-service'] = False
1819

1920
core.skip_ok_unless_installed('condor')

osgtest/tests/test_150_xrootd.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import osgtest.library.service as service
66
import osgtest.library.osgunittest as osgunittest
77

8+
9+
XROOTD_PORT = 1096 # chosen so it doesn't conflict w/ the stashcache instances
10+
811
XROOTD_CFG_TEXT = """\
912
cms.space min 2g 5g
1013
xrootd.seclib /usr/lib64/libXrdSec-4.so
@@ -17,6 +20,7 @@
1720
%s
1821
acc.authdb /etc/xrootd/auth_file
1922
ofs.authorize
23+
xrd.port %d
2024
"""
2125

2226
AUTHFILE_TEXT = """\
@@ -32,7 +36,9 @@ def test_01_start_xrootd(self):
3236
core.config['certs.xrootdcert'] = '/etc/grid-security/xrd/xrdcert.pem'
3337
core.config['certs.xrootdkey'] = '/etc/grid-security/xrd/xrdkey.pem'
3438
core.config['xrootd.config'] = '/etc/xrootd/xrootd-clustered.cfg'
39+
core.config['xrootd.port'] = XROOTD_PORT
3540
core.config['xrootd.gsi'] = "ON"
41+
core.config['xrootd.multiuser'] = "OFF"
3642
core.state['xrootd.started-server'] = False
3743
core.state['xrootd.backups-exist'] = False
3844

@@ -58,7 +64,9 @@ def test_01_start_xrootd(self):
5864
owner="xrootd",
5965
chown=(user.pw_uid, user.pw_gid))
6066

61-
files.append(core.config['xrootd.config'], XROOTD_CFG_TEXT % sec_protocol, owner='xrootd', backup=True)
67+
files.append(core.config['xrootd.config'],
68+
XROOTD_CFG_TEXT % (sec_protocol, core.config['xrootd.port']),
69+
owner='xrootd', backup=True)
6270
authfile = '/etc/xrootd/auth_file'
6371
files.write(authfile, AUTHFILE_TEXT, owner="xrootd", chown=(user.pw_uid, user.pw_gid))
6472

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

72-
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):
7389
core.skip_ok_unless_installed('xrootd', by_dependency=True)
7490
if core.el_release() < 7:
7591
core.config['xrootd_service'] = "xrootd"
92+
elif core.config['xrootd.multiuser'] == "ON":
93+
core.config['xrootd_service'] = "xrootd-privileged@clustered"
7694
else:
7795
core.config['xrootd_service'] = "xrootd@clustered"
7896

0 commit comments

Comments
 (0)