Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt CMS_PATH and SITECONFIG_PATH to locate the site catalog #11481

Merged
merged 2 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/python/WMCore/Storage/SiteLocalConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def loadSiteLocalConfig():

Runtime Accessor for the site local config.

Requires that CMS_PATH is defined as an environment variable
Requires that SITECONFIG_PATH is defined as an environment variable

"""
overVarName = "WMAGENT_SITE_CONFIG_OVERRIDE"
Expand All @@ -39,11 +39,11 @@ def loadSiteLocalConfig():
msg = "%s env. var. provided but not pointing to an existing file, ignoring." % overVarName
logging.log(logging.ERROR, msg)

defaultPath = "$CMS_PATH/SITECONF/local/JobConfig/site-local-config.xml"
defaultPath = "$SITECONFIG_PATH/JobConfig/site-local-config.xml"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the ../local.. part from this path here is usually a sym. link related to the site name/setup. Are we sure it has been properly expanded in the $SITECONFIG_PATH env. variable? Or should we even care to check, actually?... Maybe we just take it for granted and use what ever provided inside the environment? (just a thought here, no request for a change).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @khurtado, indeed we can.

actualPath = os.path.expandvars(defaultPath)
if os.environ.get("CMS_PATH", None) is None:
if os.environ.get("SITECONFIG_PATH", None) is None:
msg = "Unable to find site local config file:\n"
msg += "CMS_PATH variable is not defined."
msg += "SITECONFIG_PATH variable is not defined."
raise SiteConfigError(msg)

if not os.path.exists(actualPath):
Expand Down
4 changes: 4 additions & 0 deletions src/python/WMCore/WMRuntime/Tools/Scram.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,12 @@ def __call__(self, command, hackLdLibPath=False, runtimeDir=None, cleanEnv=True)
self.procWriter(proc, 'export VO_CMS_SW_DIR=%s\n' % os.environ['VO_CMS_SW_DIR'])
if os.environ.get('OSG_APP', None) is not None:
self.procWriter(proc, 'export VO_CMS_SW_DIR=%s/cmssoft/cms\n' % os.environ['OSG_APP'])
# In general, CMSSW releases <= 12_6_0 will use CMS_PATH, while anything beyond that
# requires the SITECONFIG_PATH variable to properly load storage.xml/json file.
if os.environ.get('CMS_PATH', None) is not None:
self.procWriter(proc, 'export CMS_PATH=%s\n' % os.environ['CMS_PATH'])
if os.environ.get('SITECONFIG_PATH', None) is not None:
self.procWriter(proc, 'export SITECONFIG_PATH=%s\n' % os.environ['SITECONFIG_PATH'])
if os.environ.get('_CONDOR_JOB_AD'):
self.procWriter(proc, 'export _CONDOR_JOB_AD=%s\n' % os.environ['_CONDOR_JOB_AD'])
if os.environ.get('_CONDOR_MACHINE_AD'):
Expand Down
20 changes: 8 additions & 12 deletions test/python/WMCore_t/Misc_t/Runtime_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from WMCore_t.WMSpec_t.TestSpec import testWorkload
from nose.plugins.attrib import attr

import WMCore.WMBase
import WMCore.WMRuntime.Bootstrap as Bootstrap
# DataStructs
from WMCore.DataStructs.File import File
Expand Down Expand Up @@ -89,9 +90,6 @@ class RuntimeTest(unittest.TestCase):
A unittest to test the WMRuntime/WMSpec/Storage/etc tree
"""

# This is an integration test
__integration__ = "Any old bollocks"

def setUp(self):
"""
Basic setUp
Expand All @@ -109,6 +107,7 @@ def setUp(self):
self.unpackDir = None
self.initialDir = os.getcwd()
self.origPath = sys.path
self.thisDirPath = os.path.dirname(__file__)

# Create some dirs
os.makedirs(os.path.join(self.testDir, 'packages'))
Expand Down Expand Up @@ -153,9 +152,10 @@ def createTestWorkload(self, workloadName='Test', emulator=True):
siteConfigPath = os.path.join(workloadDir, 'SITECONF/local/JobConfig/')
if not os.path.exists(siteConfigPath):
os.makedirs(siteConfigPath)
shutil.copy('site-local-config.xml', siteConfigPath)
shutil.copy(os.path.join(self.thisDirPath, 'site-local-config.xml'), siteConfigPath)
environment = rereco.data.section_('environment')
environment.CMS_PATH = workloadDir
environment.SITECONFIG_PATH = os.path.join(workloadDir, 'SITECONF/local')

taskMaker = TaskMaker(workload, workloadDir)
taskMaker.skipSubscription = True
Expand Down Expand Up @@ -316,15 +316,14 @@ def runJobs(self, workload):
# Scream, run around in panic, blow up machine
print("About to run jobs")
print(taskDir)
miniStartup(dir=taskDir)
miniStartup(thisDir=taskDir)

# When exiting, go back to where you started
os.chdir(self.initialDir)
sys.path.remove(taskDir)

return

@attr('integration')
def testA_CreateWorkload(self):
"""
_CreateWorkload_
Expand All @@ -350,7 +349,7 @@ def testA_CreateWorkload(self):

# Does it have the right directories?
dirList = os.listdir(workloadPath)
self.assertEqual(dirList, ['WMSandbox', 'TestWorkload-Sandbox.tar.bz2'])
self.assertCountEqual(dirList, ['WMSandbox', 'TestWorkload-Sandbox.tar.bz2'])
dirList = os.listdir(os.path.join(workloadPath, 'WMSandbox'))
for taskName in taskNames:
self.assertTrue(taskName in dirList)
Expand Down Expand Up @@ -396,7 +395,6 @@ def testA_CreateWorkload(self):

return

@attr('integration')
def testB_EmulatorTest(self):
"""
_EmulatorTest_
Expand Down Expand Up @@ -424,10 +422,8 @@ def testB_EmulatorTest(self):
cmsReport = report.data.cmsRun1

# Now validate the report
self.assertEqual(report.data.ceName, socket.gethostname())
self.assertEqual(report.data.pnn, 'T1_US_FNAL_Disk')
self.assertEqual(report.data.siteName, 'T1_US_FNAL')
self.assertEqual(report.data.hostName, socket.gethostname())
self.assertEqual(report.getSiteName(), {})
#self.assertEqual(report.data.hostName, socket.gethostname())
self.assertTrue(report.data.completed)

# Should have status 0 (emulator job)
Expand Down
3 changes: 2 additions & 1 deletion test/python/WMCore_t/Storage_t/SiteLocalConfig_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,15 @@ def testLoadingConfigFromOverridenEnvVarriable(self):
self.assertEqual(mySiteConfig.siteName, "T3_US_Vanderbilt",
"Error: Wrong site name.")


# this test requires access to CVMFS
@attr("integration")
def testSlcPhedexNodesEqualPhedexApiNodes(self):
"""
For each site, verify that the stageout node specified in
site-local-config.xml is the same as the one returned by the PhEDEx api.
"""
os.environ["CMS_PATH"] = "/cvmfs/cms.cern.ch"
os.environ["SITECONFIG_PATH"] = "/cvmfs/cms.cern.ch/SITECONF/local"

nodes = ['FIXME']

Expand Down
1 change: 1 addition & 0 deletions test/python/WMCore_t/Storage_t/StageOutMgr_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class StageOutMgrTest(unittest.TestCase):
def setUp(self):
# shut up SiteLocalConfig
os.putenv('CMS_PATH', os.getcwd())
os.putenv('SITECONFIG_PATH', os.getcwd())
khurtado marked this conversation as resolved.
Show resolved Hide resolved

def testName(self):
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def setUp(self):

# shut up SiteLocalConfig
os.environ['CMS_PATH'] = os.getcwd()
os.environ['SITECONFIG_PATH'] = os.getcwd()
khurtado marked this conversation as resolved.
Show resolved Hide resolved
workload = copy.deepcopy(testWorkloads.workload)
task = workload.getTask("Production")
step = task.getStep("stageOut1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def setUp(self):

# shut up SiteLocalConfig
os.environ['CMS_PATH'] = os.getcwd()
os.environ['SITECONFIG_PATH'] = os.getcwd()
amaltaro marked this conversation as resolved.
Show resolved Hide resolved
workload = copy.deepcopy(testWorkloads.workload)
task = workload.getTask("Production")
step = task.getStep("stageOut1")
Expand Down