Skip to content

Commit

Permalink
test: fix SiteDirector and SiteStatus test
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Sep 11, 2024
1 parent bf003b3 commit 1252509
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from DIRAC.ConfigurationSystem.Client import ConfigurationData
from DIRAC.Core.Utilities.ProcessPool import S_OK
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
Expand Down Expand Up @@ -166,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
Expand All @@ -180,6 +184,7 @@ def sd(mocker, config):

# Set queueDict
sd.siteClient = SiteStatus()
sd.rssClient = ResourceStatus()
sd._buildQueueDict()
return sd

Expand Down
43 changes: 22 additions & 21 deletions tests/Integration/ResourceStatusSystem/Test_SiteStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -131,25 +132,25 @@ def test_addAndRemove_complicatedTest(stClient):

result = stClient.getSites()
assert result["OK"] is True, result["Message"]
inRSS = "testBanned.test.test" in result["Value"]

# TEST getSites
# ...............................................................................

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"]

0 comments on commit 1252509

Please sign in to comment.