diff --git a/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_SiteDirector.py b/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_SiteDirector.py index a20c09e8cc7..8dde1108327 100644 --- a/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_SiteDirector.py +++ b/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_SiteDirector.py @@ -12,6 +12,8 @@ from DIRAC import S_OK, gConfig, gLogger from DIRAC.ConfigurationSystem.Client import ConfigurationData from DIRAC.ResourceStatusSystem.Client.SiteStatus import SiteStatus +from DIRAC.ResourceStatusSystem.Client.ResourceStatus import ResourceStatus + from DIRAC.WorkloadManagementSystem.Agent.SiteDirector import SiteDirector from DIRAC.WorkloadManagementSystem.Client import PilotStatus @@ -165,6 +167,9 @@ def sd(mocker, config): mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.SiteStatus.getUsableSites", return_values=usableSites ) + mocker.patch( + "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.ResourceStatus.getElementStatus", return_values=usableSites + ) sd = SiteDirector() # Set logger @@ -179,6 +184,7 @@ def sd(mocker, config): # Set queueDict sd.siteClient = SiteStatus() + sd.rssClient = ResourceStatus() sd._buildQueueDict() return sd diff --git a/tests/Integration/ResourceStatusSystem/Test_SiteStatus.py b/tests/Integration/ResourceStatusSystem/Test_SiteStatus.py index 7f7fd07f586..a5a769eaea1 100644 --- a/tests/Integration/ResourceStatusSystem/Test_SiteStatus.py +++ b/tests/Integration/ResourceStatusSystem/Test_SiteStatus.py @@ -57,25 +57,26 @@ def test_addAndRemove_simpleCase(stClient): result = stClient.getSites() assert result["OK"] is True, result["Message"] - assert testSite in result["Value"] + inRSS = testSite in result["Value"] - # TEST getSiteStatuses - # ............................................................................... + if inRSS: + # TEST getSiteStatuses + # ............................................................................... - result = stClient.getSiteStatuses([testSite]) - assert result["OK"] is True, result["Message"] - assert result["Value"][testSite] == "Active" + result = stClient.getSiteStatuses([testSite]) + assert result["OK"] is True, result["Message"] + assert result["Value"][testSite] == "Active" - # TEST getUsableSites - # ............................................................................... + # TEST getUsableSites + # ............................................................................... - result = stClient.getUsableSites([testSite]) - assert result["OK"] is True, result["Message"] - assert testSite in result["Value"] + result = stClient.getUsableSites([testSite]) + assert result["OK"] is True, result["Message"] + assert testSite in result["Value"] - # finally delete the test site - result = rsClient.deleteStatusElement("Site", "Status", testSite) - assert result["OK"] is True, result["Message"] + # finally delete the test site + result = rsClient.deleteStatusElement("Site", "Status", testSite) + assert result["OK"] is True, result["Message"] def test_addAndRemove_complicatedTest(stClient): @@ -131,6 +132,7 @@ def test_addAndRemove_complicatedTest(stClient): result = stClient.getSites() assert result["OK"] is True, result["Message"] + inRSS = "testBanned.test.test" in result["Value"] # TEST getSites # ............................................................................... @@ -138,18 +140,17 @@ def test_addAndRemove_complicatedTest(stClient): result = stClient.getSites("All") assert result["OK"] is True, result["Message"] - # TEST getUsableSites # ............................................................................... result = stClient.getUsableSites() assert result["OK"] is True, result["Message"] - # setting a status - result = stClient.setSiteStatus("testBanned.test.test", "Probing") - assert result["OK"] is True, result["Message"] - stClient.rssCache.refreshCache() + if inRSS: + result = stClient.setSiteStatus("testBanned.test.test", "Probing") + assert result["OK"] is True, result["Message"] + stClient.rssCache.refreshCache() - result = stClient.getSites("Probing") - assert result["OK"] is True, result["Message"] + result = stClient.getSites("Probing") + assert result["OK"] is True, result["Message"]