Skip to content

Commit 7026549

Browse files
committed
Configure, start and stop stashcache
1 parent 1ebf5ea commit 7026549

File tree

4 files changed

+194
-0
lines changed

4 files changed

+194
-0
lines changed

files/test_sequence

Lines changed: 3 additions & 0 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
@@ -32,6 +33,7 @@ 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
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import os
2+
from osgtest.library import core
3+
from osgtest.library import files
4+
from osgtest.library.osgunittest import OSGTestCase
5+
from osgtest.library import service
6+
7+
8+
CACHE_DIR = "/tmp/sccache"
9+
CACHE_PORT = 1094 # can't change this - stashcp doesn't allow you to specify port
10+
CACHE_HTTP_PORT = 8001
11+
ORIGIN_PORT = 1095
12+
ORIGIN_DIR = "/tmp/scorigin"
13+
CACHE_AUTHFILE_PATH = "/etc/xrootd/Authfile-cache"
14+
CACHE_CONFIG_PATH = "/etc/xrootd/xrootd-stashcache-cache-server.cfg"
15+
ORIGIN_CONFIG_PATH = "/etc/xrootd/xrootd-stashcache-origin-server.cfg"
16+
CACHES_JSON_PATH = "/etc/stashcache/caches.json"
17+
18+
19+
# TODO Set up authenticated stashcache as well
20+
CACHE_CONFIG_TEXT = """\
21+
all.export /
22+
set cachedir = {CACHE_DIR}
23+
xrd.allow host *
24+
sec.protocol host
25+
all.adminpath /var/spool/xrootd
26+
27+
xrootd.trace emsg login stall redirect
28+
ofs.trace all
29+
xrd.trace all
30+
cms.trace all
31+
32+
ofs.osslib libXrdPss.so
33+
# normally this is the redirector but we don't have one in this environment
34+
pss.origin localhost:{ORIGIN_PORT}
35+
pss.cachelib libXrdFileCache.so
36+
pss.setopt DebugLevel 1
37+
38+
oss.localroot $(cachedir)
39+
40+
pfc.blocksize 512k
41+
pfc.ram 1024m
42+
# ^ xrootd won't start without a gig
43+
pfc.prefetch 10
44+
pfc.diskusage 0.90 0.95
45+
46+
ofs.authorize 1
47+
acc.audit deny grant
48+
49+
acc.authdb {CACHE_AUTHFILE_PATH}
50+
sec.protbind * none
51+
xrd.protocol http:{CACHE_HTTP_PORT} libXrdHttp.so
52+
53+
xrd.port {CACHE_PORT}
54+
55+
http.listingdeny yes
56+
http.staticpreload http://static/robots.txt /etc/xrootd/stashcache-robots.txt
57+
58+
# Tune the client timeouts to more aggressively timeout.
59+
pss.setopt ParallelEvtLoop 10
60+
pss.setopt RequestTimeout 25
61+
#pss.setopt TimeoutResolution 1
62+
pss.setopt ConnectTimeout 25
63+
pss.setopt ConnectionRetry 2
64+
#pss.setopt StreamTimeout 35
65+
66+
all.sitename osgtest
67+
68+
xrootd.diglib * /etc/xrootd/digauth.cf
69+
""".format(**globals())
70+
71+
72+
CACHE_AUTHFILE_TEXT = """\
73+
u * / rl
74+
"""
75+
76+
77+
ORIGIN_CONFIG_TEXT = """\
78+
xrd.allow host *
79+
sec.protocol host
80+
sec.protbind * none
81+
all.adminpath /var/spool/xrootd
82+
all.pidpath /var/run/xrootd
83+
84+
# The directory on local disk containing the files to share, e.g. "/stash".
85+
oss.localroot {ORIGIN_DIR}
86+
all.export /
87+
88+
xrd.port {ORIGIN_PORT}
89+
all.role server
90+
91+
xrootd.trace emsg login stall redirect
92+
ofs.trace all
93+
xrd.trace all
94+
cms.trace all
95+
""".format(**globals())
96+
97+
98+
CACHES_JSON_TEXT = """\
99+
[
100+
{"name":"root://localhost", "status":1, "longitude":-89.4012, "latitude":43.0731}
101+
]
102+
"""
103+
104+
105+
_NAMESPACE = "stashcache"
106+
107+
108+
def _getcfg(key):
109+
return core.config["%s.%s" % (_NAMESPACE, key)]
110+
111+
112+
def _setcfg(key, val):
113+
core.config["%s.%s" % (_NAMESPACE, key)] = val
114+
115+
116+
class TestStartStashCache(OSGTestCase):
117+
@core.elrelease(7,8)
118+
def setUp(self):
119+
core.skip_ok_unless_installed("stashcache-origin-server", "stashcache-cache-server", "stashcache-client")
120+
121+
def test_01_configure(self):
122+
for key, val in [
123+
("cache_authfile_path", CACHE_AUTHFILE_PATH),
124+
("cache_config_path", CACHE_CONFIG_PATH),
125+
("origin_config_path", ORIGIN_CONFIG_PATH),
126+
("caches_json_path", CACHES_JSON_PATH),
127+
("cache_http_port", CACHE_HTTP_PORT),
128+
("origin_dir", ORIGIN_DIR),
129+
("cache_dir", CACHE_DIR)
130+
]:
131+
_setcfg(key, val)
132+
133+
d = os.path.dirname(CACHES_JSON_PATH)
134+
if not os.path.isdir(d):
135+
os.makedirs(os.path.dirname(d))
136+
for key, text in [
137+
("cache_config_path", CACHE_CONFIG_TEXT),
138+
("cache_authfile_path", CACHE_AUTHFILE_TEXT),
139+
("origin_config_path", ORIGIN_CONFIG_TEXT),
140+
("caches_json_path", CACHES_JSON_TEXT)
141+
]:
142+
files.write(_getcfg(key), text, owner=_NAMESPACE, chmod=0o644)
143+
144+
def test_02_start_origin(self):
145+
if not service.is_running("xrootd@stashcache-origin-server"):
146+
service.check_start("xrootd@stashcache-origin-server")
147+
148+
def test_03_start_cache(self):
149+
if not service.is_running("xrootd@stashcache-cache-server"):
150+
service.check_start("xrootd@stashcache-cache-server")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# hiii
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import os
2+
from osgtest.library import core
3+
from osgtest.library import files
4+
from osgtest.library.osgunittest import OSGTestCase
5+
from osgtest.library import service
6+
7+
8+
_NAMESPACE = "stashcache"
9+
10+
11+
def _getcfg(key):
12+
return core.config["%s.%s" % (_NAMESPACE, key)]
13+
14+
15+
def _setcfg(key, val):
16+
core.config["%s.%s" % (_NAMESPACE, key)] = val
17+
18+
19+
class TestStopStashCache(OSGTestCase):
20+
@core.elrelease(7,8)
21+
def setUp(self):
22+
core.skip_ok_unless_installed("stashcache-origin-server", "stashcache-cache-server", "stashcache-client")
23+
24+
def test_01_stop_origin(self):
25+
service.check_stop("xrootd@stashcache-origin-server")
26+
27+
def test_02_stop_cache(self):
28+
service.check_stop("xrootd@stashcache-cache-server")
29+
30+
def test_03_unconfigure(self):
31+
for key in [
32+
"cache_config_path",
33+
"cache_authfile_path",
34+
"origin_config_path",
35+
"caches_json_path"
36+
]:
37+
files.restore(_getcfg(key), owner=_NAMESPACE)
38+
39+
def test_04_clean_dirs(self):
40+
pass

0 commit comments

Comments
 (0)