Skip to content

Commit 97b018e

Browse files
author
efajardo
committed
initiate TPC
1 parent cc38c1d commit 97b018e

File tree

9 files changed

+105
-77
lines changed

9 files changed

+105
-77
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +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
8-
- OS_TYPE=centos OS_VERSION=7 PACKAGES=xrootd,xrootd-client,xrootd-scitokens,globus-proxy-utils,lcmaps,lcmaps-db-templates,xrootd-lcmaps,vo-client,vo-client-lcmaps-voms
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
99

1010
services:
1111
- docker

files/test_sequence

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ test_430_uberftp
3535
test_440_glexec
3636
test_450_xrootd
3737
test_460_stashcache
38+
test_465_xrootd_tpc
3839
test_470_rsv
3940
test_490_jobs
4041
test_510_edgmkgridmap

osgtest/library/files.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import re
2626
import shutil
2727
import tempfile
28-
28+
import hashlib
2929
import osgtest.library.core as core
3030

3131

@@ -176,7 +176,7 @@ def append(path, contents, force=False, owner=None, backup=True):
176176
return
177177

178178
new_contents = old_contents + [contents]
179-
write(path, new_contents, owner, backup=False)
179+
write(path, new_contents, backup=False)
180180

181181

182182
def restore(path, owner):
@@ -246,3 +246,21 @@ def safe_makedirs(directory, mode=0o777):
246246
"""
247247
if not os.path.isdir(directory):
248248
os.makedirs(directory, mode)
249+
250+
def checksum_file(path):
251+
"""Return the md5 checksum of a file """
252+
if os.path.exists(path):
253+
return hashlib.md5(open(path,'rb').read()).hexdigest()
254+
else:
255+
return False
256+
257+
def checksum_files_match(file1, file2):
258+
"""Returns true if the checksum of the files matches
259+
260+
"""
261+
checksum1 = checksum_file(file1)
262+
checksum2 = checksum_file(file2)
263+
if checksum1 and checksum2:
264+
return checksum1==checksum2
265+
else:
266+
return False

osgtest/library/service.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ def start(service_name):
3636
core.check_system(command, 'Start ' + service_name + ' service')
3737
core.state[service_name + '.started-service'] = True
3838

39-
def check_start(service_name, timeout=10, logToCheck = None):
39+
def check_start(service_name, timeout=10, log_to_check = None):
4040
"""
4141
Start a service, 'service_name' via init script or systemd and ensure that
4242
it starts running within a 'timeout' second window (default=10s)
4343
"""
4444
start(service_name)
45-
assert is_running(service_name, timeout=10, logToCheck = logToCheck), "%s is not running" % service_name
45+
assert is_running(service_name, timeout=10, log_to_check = log_to_check), "%s is not running" % service_name
4646

4747
def stop(service_name):
4848
"""
@@ -90,7 +90,7 @@ def status(service_name):
9090
status_rc, _, _ = core.system(command)
9191
return status_rc
9292

93-
def check_status(service_name, expected_status, timeout=10, logToCheck = None):
93+
def check_status(service_name, expected_status, timeout=10, log_to_check = None):
9494
"""
9595
Return True if the exit code of the 'service_name' status check is
9696
expected_status before 'timeout' seconds. Otherwise, False.
@@ -102,20 +102,20 @@ def check_status(service_name, expected_status, timeout=10, logToCheck = None):
102102
time.sleep(1)
103103
timer += 1
104104

105-
if status_rc != expected_status and logToCheck!= None:
106-
LogFileContents = files.read(logToCheck)
107-
core.log_message("Last lines of log: %s" % logToCheck)
108-
for line in LogFileContents[-9:]:
105+
if status_rc != expected_status and log_to_check:
106+
log_file_contents = files.read(log_to_check)
107+
core.log_message("Last lines of log: %s" % log_to_check)
108+
for line in log_file_contents[-9:]:
109109
core.log_message(line)
110110
return status_rc == expected_status
111111

112-
def is_running(service_name, timeout=1, logToCheck = None):
112+
def is_running(service_name, timeout=1, log_to_check = None):
113113
"""
114114
Return True if 'service_name' is determined to be running via init script or
115115
systemd, according to LSB init standards, before 'timeout'
116116
seconds. Otherwise, False.
117117
"""
118-
return check_status(service_name, STATUS_RUNNING, timeout, logToCheck)
118+
return check_status(service_name, STATUS_RUNNING, timeout, log_to_check)
119119

120120
def is_stopped(service_name, timeout=1):
121121
"""

osgtest/tests/test_150_xrootd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"""
2525

2626
AUTHFILE_TEXT = """\
27-
u * /tmp a
27+
u * /tmp a /usr/share/ r
2828
u = /tmp/@=/ a
2929
u xrootd /tmp a
3030
"""

osgtest/tests/test_158_xrootd_tpc.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@
1111

1212
XROOTD_CFG_TEXT = """\
1313
cms.space min 2g 5g
14-
xrootd.seclib /usr/lib64/libXrdSec-4.so
15-
sec.protocol /usr/lib64 gsi -certdir:/etc/grid-security/certificates \
14+
xrootd.seclib /usr/lib64/libXrdSec.so
15+
http.secxtractor /usr/lib64/libXrdLcmaps.so
16+
17+
sec.protocol /usr/lib64 gsi -d 2 -certdir:/etc/grid-security/certificates \
1618
-cert:/etc/grid-security/xrd/xrdcert.pem \
1719
-key:/etc/grid-security/xrd/xrdkey.pem \
18-
-crl:3 \
20+
-crl:1 \
21+
-ca:0 \
1922
--gmapopt:10 \
2023
--gmapto:0 \
2124
%s
2225
2326
acc.authdb /etc/xrootd/auth_file
2427
ofs.authorize
28+
all.export /
2529
2630
if exec xrootd
2731
http.cadir /etc/grid-security/certificates
@@ -36,7 +40,7 @@
3640
http.header2cgi Authorization authz
3741
3842
# Enable Macaroons
39-
ofs.authlib libXrdMacaroons.so libXrdAccSciTokens.so
43+
ofs.authlib libXrdMacaroons.so
4044
xrd.port %d
4145
xrd.protocol http:%d /usr/lib64/libXrdHttp-4.so
4246
fi
@@ -57,16 +61,14 @@ def test_01_configure_xrootd(self):
5761
core.state['xrootd.tpc.backups-exist'] = False
5862

5963
self.skip_ok_unless(core.options.adduser, 'user not created')
60-
core.skip_ok_unless_installed('xrootd', 'xrootd-scitokens', by_dependency=True)
64+
core.skip_ok_unless_installed('globus-proxy-utils', 'xrootd', 'xrootd-scitokens', by_dependency=True)
6165

6266
user = pwd.getpwnam("xrootd")
63-
core.skip_ok_unless_installed('globus-proxy-utils')
6467

6568
lcmaps_packages = ('lcmaps', 'lcmaps-db-templates', 'xrootd-lcmaps', 'vo-client', 'vo-client-lcmaps-voms')
6669
if all([core.rpm_is_installed(x) for x in lcmaps_packages]):
6770
core.log_message("Using xrootd-lcmaps authentication")
6871
sec_protocol = '-authzfun:libXrdLcmaps.so -authzfunparms:--loglevel,5'
69-
#XROOTD_CFG_TEXT += "http.secxtractor /usr/lib64/libXrdLcmaps.so/n"
7072
sec_protocol += ',--policy,authorize_only'
7173
else:
7274
core.log_message("Using XRootD mapfile authentication")
@@ -76,7 +78,7 @@ def test_01_configure_xrootd(self):
7678
XROOTD_CFG_TEXT % (sec_protocol, core.config['xrootd.tpc.http-port1'], core.config['xrootd.tpc.http-port1']),
7779
owner='xrootd', backup=True, chown=(user.pw_uid, user.pw_gid))
7880
files.write(core.config['xrootd.tpc.config-2'],
79-
XROOTD_CFG_TEXT % (sec_protocol, core.config['xrootd.tpc.http-port2'], core.config['xrootd.tpc.http-port1']),
81+
XROOTD_CFG_TEXT % (sec_protocol, core.config['xrootd.tpc.http-port2'], core.config['xrootd.tpc.http-port2']),
8082
owner='xrootd', backup=True, chown=(user.pw_uid, user.pw_gid))
8183
core.state['xrootd.tpc.backups-exist'] = True
8284

@@ -85,9 +87,9 @@ def test_02_create_secrets(self):
8587
core.config['xrootd.tpc.macaroon-secret-1'] = '/etc/xrootd/macaroon-secret-1'
8688
core.config['xrootd.tpc.macaroon-secret-2'] = '/etc/xrootd/macaroon-secret-2'
8789
core.check_system(["openssl", "rand", "-base64", "-out",
88-
core.config['xrootd.tpc.macaroon-secret-1'], "64"], "Creating simmetric key")
90+
core.config['xrootd.tpc.macaroon-secret-1'], "64"], "Creating symmetric key")
8991
core.check_system(["openssl", "rand", "-base64", "-out",
90-
core.config['xrootd.tpc.macaroon-secret-2'], "64"], "Creating simmetric key")
92+
core.config['xrootd.tpc.macaroon-secret-2'], "64"], "Creating symmetric key")
9193
files.append(core.config['xrootd.tpc.config-1'],
9294
"macaroons.secretkey %s"%(core.config['xrootd.tpc.macaroon-secret-1']),
9395
owner='xrootd', backup=False)
@@ -100,8 +102,8 @@ def test_03_start_xrootd(self):
100102
core.skip_ok_unless_installed('xrootd', 'xrootd-scitokens', by_dependency=True)
101103
core.config['xrootd_tpc_service_1'] = "xrootd@third-party-copy-1"
102104
core.config['xrootd_tpc_service_2'] = "xrootd@third-party-copy-2"
103-
service.check_start(core.config['xrootd_tpc_service_1'], logToCheck = '/var/log/xrootd/third-party-copy-1/xrootd.log')
104-
service.check_start(core.config['xrootd_tpc_service_2'], logToCheck = '/var/log/xrootd/third-party-copy-2/xrootd.log')
105+
service.check_start(core.config['xrootd_tpc_service_1'], log_to_check = '/var/log/xrootd/third-party-copy-1/xrootd.log')
106+
service.check_start(core.config['xrootd_tpc_service_2'], log_to_check = '/var/log/xrootd/third-party-copy-2/xrootd.log')
105107
core.state['xrootd.started-http-server-1'] = True
106108
core.state['xrootd.started-http-server-2'] = True
107109

osgtest/tests/test_465_xrootd-tpc.py

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import os
2+
import json
3+
import pwd
4+
import requests
5+
6+
import osgtest.library.core as core
7+
import osgtest.library.files as files
8+
import osgtest.library.osgunittest as osgunittest
9+
10+
11+
class TestXrootdTPC(osgunittest.OSGTestCase):
12+
13+
def test_01_create_macaroons(self):
14+
core.skip_ok_unless_installed('xrootd', 'xrootd-scitokens', 'x509-scitokens-issuer-client', by_dependency=True)
15+
self.skip_bad_unless(core.state['proxy.created'], 'Proxy creation failed')
16+
17+
uid = pwd.getpwnam(core.options.username)[2]
18+
usercert = '/tmp/x509up_u%d' % uid
19+
userkey = '/tmp/x509up_u%d' % uid
20+
21+
core.config['xrootd.tpc.url-1'] = "https://" + core.get_hostname() + ":9001" + "/usr/share/osg-test/test_gridftp_data.txt"
22+
command = ('macaroon-init', core.config['xrootd.tpc.url-1'], '20', 'DOWNLOAD')
23+
24+
status, stdout, stderr = core.system(command, user=True)
25+
fail = core.diagnose('Obtain Macaroon one',
26+
command, status, stdout, stderr)
27+
core.config['xrootd.tpc.macaroon-1'] = stdout.strip('\n')
28+
29+
core.config['xrootd.tpc.url-2'] = "https://" + core.get_hostname() + ":9002" + "/tmp/test_gridftp_data_tpc.txt"
30+
command = ('macaroon-init', core.config['xrootd.tpc.url-2'], '20', 'UPLOAD')
31+
status, stdout, stderr = core.system(command, user=True)
32+
fail = core.diagnose('Obtain Macaroon number two',
33+
command, status, stdout, stderr)
34+
core.config['xrootd.tpc.macaroon-2'] = stdout.strip('\n')
35+
36+
37+
def test_02_initate_tpc(self):
38+
core.skip_ok_unless_installed('xrootd', 'xrootd-scitokens', by_dependency=True)
39+
session = requests.Session()
40+
session.verify = False
41+
headers = {}
42+
headers['Overwrite'] = 'T'
43+
headers['Authorization'] = 'Bearer %s' % core.config['xrootd.tpc.macaroon-1']
44+
headers['Source'] = core.config['xrootd.tpc.url-1']
45+
headers['Copy-Header'] = 'Authorization: Bearer %s' % core.config['xrootd.tpc.macaroon-2']
46+
resp = session.request('COPY',
47+
core.config['xrootd.tpc.url-2'], headers=headers,
48+
allow_redirects=True)
49+
file_copied = os.path.exists("/tmp/test_gridftp_data_tpc.txt")
50+
self.assert_(file_copied, 'Copied file missing')
51+
chechskum_match = files.checksum_files_match("/tmp/test_gridftp_data_tpc.txt", "/usr/share/osg-test/test_gridftp_data.txt")
52+
self.assert_(chechskum_match, 'Files have same contents')
53+
54+

travis-ci/test_inside_docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ export _condor_CONDOR_CE_TRACE_ATTEMPTS=60
5757
# Ok, do actual testing
5858
INSTALL_STR="--install ${PACKAGES//,/ --install }"
5959
echo "------------ OSG Test --------------"
60-
osg-test --extra-repo osg-testing -vad --hostcert --no-cleanup ${INSTALL_STR}
60+
osg-test -vad --hostcert --no-cleanup ${INSTALL_STR}

0 commit comments

Comments
 (0)