Skip to content

Commit 244537c

Browse files
Merge pull request #185 from efajardo/SOFTWARE-3936
Adding HTTP(S) tests to the cache (SOFTWARE-3936)
2 parents a918acc + a471225 commit 244537c

File tree

2 files changed

+73
-5
lines changed

2 files changed

+73
-5
lines changed

osgtest/tests/test_155_stashcache.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
PARAMS_CFG_CONTENTS = "\n".join("setenv {0} = {1}\nset {0} = {1}".format(k, v)
3838
for k, v in PARAMS.items()) + "\n"
3939

40+
4041
PRE_CFG_PATH = "/etc/xrootd/config.d/11-pre.cfg"
4142
PRE_CFG_CONTENTS = """
4243
set DisableOsgMonitoring = 1
@@ -52,6 +53,7 @@
5253
5354
pss.origin localhost:$(OriginAuthXrootPort)
5455
xrd.protocol http:$(CacheHTTPSPort) libXrdHttp.so
56+
setenv XrdSecGSISRVNAMES=*
5557
else if named stash-cache
5658
xrd.port $(CacheXrootPort)
5759
set rootdir = $(CacheRootdir)
@@ -77,10 +79,19 @@
7779
"""
7880

7981
CACHE_AUTHFILE_PATH = PARAMS["StashCacheAuthfile"]
80-
CACHE_AUTHFILE_CONTENTS = "u * / rl\n"
82+
# The hash of the vdttest user DN
83+
# "/DC=org/DC=opensciencegrid/C=US/O=OSG Software/OU=People/CN=vdttest"
84+
# is b64f6609.0
85+
user_DN_hash = "b64f6609.0"
86+
CACHE_AUTHFILE_CONTENTS = "u %s /osgtest/PROTECTED rl\n" % user_DN_hash
87+
8188

8289
CACHE_PUBLIC_AUTHFILE_PATH = PARAMS["StashCachePublicAuthfile"]
83-
CACHE_PUBLIC_AUTHFILE_CONTENTS = "u * / rl\n"
90+
CACHE_PUBLIC_AUTHFILE_CONTENTS = """
91+
u * /osgtest/PROTECTED -rl \
92+
/ rl
93+
"""
94+
8495

8596
ORIGIN_AUTHFILE_PATH = PARAMS["StashOriginAuthfile"]
8697
ORIGIN_AUTHFILE_CONTENTS = "u * /osgtest/PROTECTED rl\n"

osgtest/tests/test_460_stashcache.py

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ class TestStashCache(OSGTestCase):
2727
for x in range(4)
2828
]
2929

30-
def assertCached(self, name, contents):
30+
def assertCached(self, name, contents, auth=False):
31+
OriginExport = getcfg("OriginExport")
32+
if auth:
33+
OriginExport = getcfg("OriginAuthExport")
3134
fpath = os.path.join(getcfg("CacheRootdir"), getcfg("OriginExport").lstrip("/"), name)
3235
self.assertTrue(os.path.exists(fpath),
3336
name + " not cached")
@@ -47,16 +50,20 @@ def setUp(self):
4750
by_dependency=True)
4851
if core.rpm_is_installed("xcache"):
4952
self.skip_ok_if(core.PackageVersion("xcache") < "1.0.2", "needs xcache 1.0.2+")
50-
self.skip_bad_unless_running("xrootd@stash-origin", "xrootd@stash-cache")
53+
self.skip_bad_unless_running("xrootd@stash-origin", "xrootd@stash-cache", "xrootd@stash-origin-auth",
54+
"xrootd@stash-cache-auth")
5155

5256
def test_01_create_files(self):
5357
xrootd_user = pwd.getpwnam("xrootd")
5458
for name, contents in self.testfiles:
5559
files.write(os.path.join(getcfg("OriginRootdir"), getcfg("OriginExport").lstrip("/"), name),
5660
contents, backup=False, chmod=0o644,
5761
chown=(xrootd_user.pw_uid, xrootd_user.pw_gid))
62+
files.write(os.path.join(getcfg("OriginRootdir"), getcfg("OriginAuthExport").lstrip("/"), name),
63+
contents, backup=False, chmod=0o644,
64+
chown=(xrootd_user.pw_uid, xrootd_user.pw_gid))
5865

59-
def test_02_xroot_fetch_from_origin(self):
66+
def test_02_xrootd_fetch_from_origin(self):
6067
name, contents = self.testfiles[0]
6168
path = os.path.join(getcfg("OriginExport"), name)
6269
result, _, _ = \
@@ -100,3 +107,53 @@ def test_05_stashcp(self):
100107
result = tf.read()
101108
self.assertEqualVerbose(result, contents, "stashcp'ed file mismatch")
102109
self.assertCached(name, contents)
110+
111+
def test_06_xrootd_fetch_from_origin_auth(self):
112+
core.skip_ok_unless_installed('globus-proxy-utils', by_dependency=True)
113+
self.skip_bad_unless(core.state['proxy.valid'], 'requires a proxy cert')
114+
name, contents = self.testfiles[0]
115+
path = os.path.join(getcfg("OriginAuthExport"), name)
116+
dest_file = '/tmp/testfileFromOriginAuth'
117+
os.environ["XrdSecGSISRVNAMES"] = "*"
118+
result, _, _ = core.check_system(["xrdcp", "-d1", '-f',
119+
"root://localhost:%d/%s" % (getcfg("OriginAuthXrootPort"), path),
120+
dest_file],
121+
"Checking xrootd copy from authenticated origin", user=True)
122+
origin_file = os.path.join(getcfg("OriginRootdir"), getcfg("OriginAuthExport").lstrip("/"), name)
123+
checksum_match = files.checksum_files_match(origin_file, dest_file)
124+
self.assert_(checksum_match, 'Origin and directly downloaded file have the same contents')
125+
126+
def test_07_xrootd_fetch_from_auth_cache(self):
127+
core.skip_ok_unless_installed('globus-proxy-utils', by_dependency=True)
128+
self.skip_bad_unless(core.state['proxy.valid'], 'requires a proxy cert')
129+
name, contents = self.testfiles[2]
130+
path = os.path.join(getcfg("OriginAuthExport"), name)
131+
os.environ["XrdSecGSISRVNAMES"] = "*"
132+
dest_file = '/tmp/testfileXrootdFromAuthCache'
133+
result, _, _ = \
134+
core.check_system(["xrdcp", "-d1","-f",
135+
"root://%s:%d/%s" % (core.get_hostname(),getcfg("CacheHTTPSPort"), path),
136+
dest_file], "Checking xrootd copy from Authenticated cache", user=True)
137+
origin_file = os.path.join(getcfg("OriginRootdir"), getcfg("OriginAuthExport").lstrip("/"), name)
138+
checksum_match = files.checksum_files_match(origin_file, dest_file)
139+
self.assert_(checksum_match, 'Origin and file downloaded via cache have the same contents')
140+
141+
def test_08_https_fetch_from_auth_cache(self):
142+
core.skip_ok_unless_installed('globus-proxy-utils', 'gfal2-plugin-http', 'gfal2-util',
143+
'gfal2-plugin-file', by_dependency=True)
144+
self.skip_bad_unless(core.state['proxy.valid'], 'requires a proxy cert')
145+
name, contents = self.testfiles[3]
146+
path = os.path.join(getcfg("OriginAuthExport"), name)
147+
dest_file = '/tmp/testfileHTTPsFromAuthCache'
148+
uid = pwd.getpwnam(core.options.username)[2]
149+
usercert = '/tmp/x509up_u%d' % uid
150+
userkey = '/tmp/x509up_u%d' % uid
151+
result, _, _ = \
152+
core.check_system(["gfal-copy", "-vf",
153+
"--cert", usercert, "--key", userkey,
154+
"https://%s:%d%s" % (core.get_hostname(),getcfg("CacheHTTPSPort"), path),
155+
"file://%s"%dest_file],
156+
"Checking xrootd copy from Authenticated cache", user=True)
157+
origin_file = os.path.join(getcfg("OriginRootdir"), getcfg("OriginAuthExport").lstrip("/"), name)
158+
checksum_match = files.checksum_files_match(origin_file, dest_file)
159+
self.assert_(checksum_match, 'Origin and file downloaded via cache have the same contents')

0 commit comments

Comments
 (0)