Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
etf
cmssam
Commits
baa74819
Commit
baa74819
authored
Feb 19, 2007
by
Andrea Sciaba
Browse files
First version
parent
93e5e8c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
SiteTests/MonteCarlo/cms-MC-test/RuntimeSAMStageOut.py
0 → 100755
View file @
baa74819
#!/usr/bin/env python
"""
_RuntimeSAMStageOut_
Test script for using TFC to determine local stage out is working properly
at a site
"""
import
time
import
os
import
sys
from
FwkJobRep.SiteLocalConfig
import
loadSiteLocalConfig
from
StageOut.Registry
import
retrieveStageOutImpl
import
StageOut.Impl
class
StageOutDiagnostic
:
"""
_StageOutDiagnostic_
Object to test the local stage out details step by step
"""
def
__init__
(
self
):
self
.
summary
=
{}
self
.
summary
.
setdefault
(
'SiteConf'
,
"NotRun"
)
self
.
summary
.
setdefault
(
'TFC'
,
"NotRun"
)
self
.
summary
.
setdefault
(
'LocalStageOut'
,
"NotRun"
)
self
.
summary
.
setdefault
(
'CleanUp'
,
"NotRun"
)
self
.
status
=
0
self
.
siteConf
=
None
self
.
tfc
=
None
self
.
datestamp
=
time
.
asctime
(
time
.
localtime
(
time
.
time
()))
self
.
datestamp
=
self
.
datestamp
.
replace
(
" "
,
"-"
)
self
.
testLFN
=
"/store/unmerged/SAM/StageOutTest-%s"
%
self
.
datestamp
def
__call__
(
self
):
"""
_operator()_
Invoke step by step tests and create the summary
"""
try
:
self
.
testSiteConf
()
except
Exception
,
ex
:
print
str
(
ex
)
self
.
status
=
1
self
.
complete
()
return
try
:
self
.
testTFC
()
except
Exception
,
ex
:
print
str
(
ex
)
self
.
status
=
2
self
.
complete
()
return
try
:
self
.
testLocalStageOut
()
except
Exception
,
ex
:
print
str
(
ex
)
self
.
status
=
3
self
.
complete
()
return
try
:
self
.
testCleanUp
()
except
Exception
,
ex
:
print
str
(
ex
)
self
.
status
=
4
self
.
complete
()
return
def
complete
(
self
):
"""
_complete_
Print summary after tests
"""
msg
=
"==== StageOut Test Summary ====
\n
"
if
self
.
status
!=
0
:
msg
+=
"Status: FAILED: %s
\n
"
%
self
.
status
else
:
msg
+=
"Test Successful
\n
"
for
key
,
val
in
self
.
summary
.
items
():
msg
+=
" Test: %s : %s
\n
"
%
(
key
,
val
)
print
msg
return
def
testSiteConf
(
self
):
"""
_testSiteConf_
Test reading the site conf file
"""
if
not
os
.
environ
.
has_key
(
"CMS_PATH"
):
msg
=
"CMS_PATH Not Set: Cannot find SiteConf"
self
.
summary
[
'SiteConf'
]
=
"Failed: CMS_PATH not set"
raise
RuntimeError
,
msg
try
:
self
.
siteConf
=
loadSiteLocalConfig
()
except
Exception
,
ex
:
msg
=
"Error loading Site Conf File: %s"
%
str
(
ex
)
self
.
summary
[
'SiteConf'
]
=
"Failed: Cannot load SiteConf"
raise
RuntimeError
,
msg
if
self
.
siteConf
.
localStageOut
[
'command'
]
==
None
:
msg
=
"LocalStageOut Command is not set"
self
.
summary
[
'SiteConf'
]
=
\
"Failed: local-stage-out command not set"
raise
RuntimeError
,
msg
if
self
.
siteConf
.
localStageOut
[
'se-name'
]
==
None
:
msg
=
"LocalStageOut SE Name is not set"
self
.
summary
[
'SiteConf'
]
=
\
"Failed: local-stage-out se-name not set"
raise
RuntimeError
,
msg
if
self
.
siteConf
.
localStageOut
[
'catalog'
]
==
None
:
msg
=
"LocalStageOut Catalog is not set"
self
.
summary
[
'SiteConf'
]
=
\
"Failed: local-stage-out catalog not set"
raise
RuntimeError
,
msg
msg
=
"SiteConf test successful:
\n
"
for
key
,
val
in
self
.
siteConf
.
localStageOut
.
items
():
msg
+=
" %s = %s
\n
"
%
(
key
,
val
)
print
msg
return
def
testTFC
(
self
):
"""
_testTFC_
Test the Trivial File Catalog
"""
try
:
self
.
tfc
=
self
.
siteConf
.
trivialFileCatalog
()
except
Exception
,
ex
:
msg
=
"Failed to load Trivial File Catalog: %s"
%
str
(
ex
)
self
.
summary
[
'TFC'
]
=
"Failed: Cannot load TFC"
raise
RuntimeError
,
msg
sampleLFN
=
"/store/unmerged/testLFN"
try
:
samplePFN
=
self
.
tfc
.
matchLFN
(
self
.
tfc
.
preferredProtocol
,
sampleLFN
)
except
Exception
,
ex
:
msg
=
"Failed to translate LFN: %s"
%
str
(
ex
)
self
.
summary
[
'TFC'
]
=
"Failed: Cannot translate LFN to PFN"
raise
RuntimeError
,
msg
msg
=
"TFC test successful:
\n
"
msg
+=
"Mapped LFN: %s
\n
To PFN: %s
\n
"
%
(
sampleLFN
,
samplePFN
)
msg
+=
"Using Catalog Rules:
\n
"
msg
+=
str
(
self
.
tfc
)
print
msg
return
def
testLocalStageOut
(
self
):
"""
_testLocalStageOut_
Test a local stage out
"""
handle
=
open
(
"TEST-FILE"
,
'w'
)
for
i
in
range
(
0
,
1000
):
handle
.
write
(
"This is a test file
\n
"
)
handle
.
close
()
sourcePFN
=
os
.
path
.
join
(
os
.
getcwd
(),
"TEST-FILE"
)
seName
=
self
.
siteConf
.
localStageOut
[
'se-name'
]
command
=
self
.
siteConf
.
localStageOut
[
'command'
]
options
=
self
.
siteConf
.
localStageOut
.
get
(
'option'
,
None
)
protocol
=
self
.
tfc
.
preferredProtocol
targetPFN
=
self
.
tfc
.
matchLFN
(
self
.
tfc
.
preferredProtocol
,
self
.
testLFN
)
try
:
impl
=
retrieveStageOutImpl
(
command
)
except
Exception
,
ex
:
msg
=
"Unable to retrieve impl for local stage out:
\n
"
msg
+=
"Error retrieving StageOutImpl for command named: %s
\n
"
%
(
command
,)
self
.
summary
[
'LocalStageOut'
]
=
\
"Failure: Cant retrieve StageOut Impl"
raise
RuntimeError
,
msg
try
:
impl
(
protocol
,
sourcePFN
,
targetPFN
,
options
)
except
Exception
,
ex
:
msg
=
"Failure for local stage out:
\n
"
msg
+=
str
(
ex
)
self
.
summary
[
'LocalStageOut'
]
=
\
"Failure: Local Stage Out Failed"
raise
RuntimeError
,
msg
def
testCleanUp
(
self
):
"""
_testCleanUp_
Test clean up of the temp file
"""
os
.
remove
(
"TEST-FILE"
)
if
__name__
==
'__main__'
:
diagnostic
=
StageOutDiagnostic
()
diagnostic
()
sys
.
exit
(
diagnostic
.
status
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment