Skip to content

Commit

Permalink
fix unit test for RPM based
Browse files Browse the repository at this point in the history
unit test with all possible fallbacks

unit test: WMCORE_ROOT has double install dir now
  • Loading branch information
amaltaro committed Oct 21, 2024
1 parent 62aab36 commit e55bc90
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"""
AgentStatusWatcher test
"""

from __future__ import print_function, division

import os
import threading
import unittest
from WMQuality.TestInitCouchApp import TestInitCouchApp as TestInit
Expand Down Expand Up @@ -82,6 +80,28 @@ def testAgentStatusPoller(self):
"""
threading.currentThread()
config = self.getConfig()
# change between RPM and Docker based tests
print(f"WMA_DEPLOY_DIR: {os.environ.get('WMA_DEPLOY_DIR')}")
print(f"WMCORE_ROOT: {os.environ.get('WMCORE_ROOT')}")
if os.environ.get('WMA_DEPLOY_DIR'):
## check for Alma9 docker
print(f"Found WMA_DEPLOY_DIR set to: {os.environ.get('WMA_DEPLOY_DIR')}")
elif os.environ.get('TEST_DIR'):
# check for CC7 docker
print(f"Found TEST_DIR set to: {os.environ.get('TEST_DIR')}")
os.environ["WMA_DEPLOY_DIR"] = os.path.join(os.environ.get('TEST_DIR'), "WMCore")
elif os.environ.get('WMCORE_ROOT'):
# check for CC7 RPM
print(f"Found WMCORE_ROOT set to: {os.environ.get('WMCORE_ROOT')}")
#os.environ["WMA_DEPLOY_DIR"] = os.path.join(os.environ.get('WMCORE_ROOT'), "install")
os.environ["WMA_DEPLOY_DIR"] = os.environ.get('WMCORE_ROOT')
else:
# last fallback path
fallbackDir = "/home/cmsbld/WMCore/"
print("Did not find any of the expected env vars: WMA_DEPLOY_DIR, TEST_DIR, WMCORE_ROOT")
print(f"Setting WMA_DEPLOY_DIR environment variable to: {fallbackDir}")
os.environ["WMA_DEPLOY_DIR"] = os.path.join(fallbackDir, "install")

watcher = AgentStatusPoller(config)
# Note:
# Should call: watcher.setup() and watcher.algorithm()
Expand All @@ -94,7 +114,7 @@ def testAgentStatusPoller(self):
# Check service certificate and proxy lifetimes
watcher.checkCredLifetime(agInfo, "proxy")
watcher.checkCredLifetime(agInfo, "certificate")
print("Agent Info:\n%s" % (agInfo))
print(f"Agent Info:\n{agInfo}")

if __name__ == '__main__':
unittest.main()

0 comments on commit e55bc90

Please sign in to comment.