From e55bc903ccabb827ce5919ec27730457ea7ccfb4 Mon Sep 17 00:00:00 2001 From: Alan Malta Rodrigues Date: Sun, 20 Oct 2024 11:06:40 -0400 Subject: [PATCH] fix unit test for RPM based unit test with all possible fallbacks unit test: WMCORE_ROOT has double install dir now --- .../AgentStatusWatcher_t.py | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/test/python/WMComponent_t/AgentStatusWatcher_t/AgentStatusWatcher_t.py b/test/python/WMComponent_t/AgentStatusWatcher_t/AgentStatusWatcher_t.py index ec73c2776b..79970e8b9a 100644 --- a/test/python/WMComponent_t/AgentStatusWatcher_t/AgentStatusWatcher_t.py +++ b/test/python/WMComponent_t/AgentStatusWatcher_t/AgentStatusWatcher_t.py @@ -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 @@ -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() @@ -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()