Skip to content

Commit f0077ec

Browse files
authored
Merge pull request #6454 from fstagni/cherry-pick-2-79f484841-integration
[sweep:integration] feat: launching optimizers in the integration environment
2 parents e3bb502 + 86c9c1a commit f0077ec

File tree

14 files changed

+739
-459
lines changed

14 files changed

+739
-459
lines changed

src/DIRAC/WorkloadManagementSystem/Client/JobState/CachedJobState.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
everything locally instead of going to the DB.
55
"""
66
import copy
7-
import time, datetime
7+
import datetime
8+
import time
89

10+
from DIRAC import S_ERROR, S_OK, gLogger
911
from DIRAC.Core.Utilities import DEncode
10-
from DIRAC import S_OK, S_ERROR, gLogger
11-
from DIRAC.WorkloadManagementSystem.Client.JobState.JobState import JobState
1212
from DIRAC.WorkloadManagementSystem.Client.JobState.JobManifest import JobManifest
13+
from DIRAC.WorkloadManagementSystem.Client.JobState.JobState import JobState
1314

1415

1516
class CachedJobState:
@@ -288,9 +289,9 @@ def __addLogRecord(self, majorStatus=None, minorStatus=None, appStatus=None, sou
288289
if majorStatus:
289290
record["status"] = majorStatus
290291
if minorStatus:
291-
record["minor"] = minorStatus
292+
record["minorStatus"] = minorStatus
292293
if appStatus:
293-
record["application"] = appStatus
294+
record["applicationStatus"] = appStatus
294295
if not record:
295296
return
296297
if not source:

src/DIRAC/WorkloadManagementSystem/Executor/Base/OptimizerExecutor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def initializeOptimizer(cls):
4444

4545
def processTask(self, jid, jobState):
4646
self.__jobData.jobState = jobState
47-
self.__jobData.jobLog = self.log.getSubLogger(f"{self.ex_optimizerName()}/JID_{jid}]")
47+
self.__jobData.jobLog = self.log.getSubLogger(f"{self.ex_optimizerName()}/JID_{jid}")
4848
try:
4949
self.jobLog.info("Processing")
5050
optResult = self.optimizeJob(jid, jobState)

src/DIRAC/WorkloadManagementSystem/Executor/test/Test_Executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"""
33
# pylint: disable=protected-access, missing-docstring
44

5-
import pytest
65
from unittest.mock import MagicMock
6+
import pytest
77

88
from DIRAC.WorkloadManagementSystem.Client.JobState.CachedJobState import CachedJobState
99
from DIRAC.WorkloadManagementSystem.Client.JobState.JobManifest import JobManifest

src/DIRAC/WorkloadManagementSystem/Service/JobMonitoringHandler.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
from DIRAC.WorkloadManagementSystem.Client.PilotManagerClient import PilotManagerClient
1717
from DIRAC.WorkloadManagementSystem.Service.JobPolicy import JobPolicy, RIGHT_GET_INFO
1818

19-
SUMMARY = []
20-
2119

2220
class JobMonitoringHandlerMixin:
2321
@classmethod
@@ -301,14 +299,14 @@ def export_getJobsSites(cls, jobIDs):
301299

302300
@classmethod
303301
def export_getJobSummary(cls, jobID):
304-
return cls.jobDB.getJobAttributes(jobID, SUMMARY)
302+
return cls.jobDB.getJobAttributes(jobID)
305303

306304
##############################################################################
307305
types_getJobsSummary = [list]
308306

309307
@classmethod
310308
def export_getJobsSummary(cls, jobIDs):
311-
return cls.getJobsAttributes(jobIDs, SUMMARY)
309+
return cls.getJobsAttributes(jobIDs)
312310

313311
##############################################################################
314312
types_getJobPageSummaryWeb = [dict, list, int, int]
@@ -380,7 +378,7 @@ def export_getJobPageSummaryWeb(self, selectDict, sortList, startItem, maxItems,
380378
)
381379
summaryJobList = validJobs
382380

383-
result = self.getJobsAttributes(summaryJobList, SUMMARY)
381+
result = self.getJobsAttributes(summaryJobList)
384382
if not result["OK"]:
385383
return result
386384

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
from DIRAC.ConfigurationSystem.Client.Helpers import Registry
2-
from DIRAC.Core.Security import ProxyInfo
3-
from DIRAC.FrameworkSystem.Client.UserProfileClient import UserProfileClient
4-
51
import pytest
6-
72
import DIRAC
83

94
DIRAC.initialize() # Initialize configuration
105

6+
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getVOForGroup
7+
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
8+
from DIRAC.FrameworkSystem.Client.UserProfileClient import UserProfileClient
9+
1110
up = UserProfileClient("Web/application/desktop")
1211
key = "key"
1312
value = "value"
1413

1514

1615
def _userInfo():
17-
retVal = ProxyInfo.getProxyInfo()
16+
retVal = getProxyInfo()
1817
assert retVal["OK"], retVal
1918
proxyInfo = retVal["Value"]
2019
currentUser = proxyInfo["username"]
2120
currentDN = proxyInfo["DN"]
2221
currentGroup = proxyInfo["group"]
23-
userVO = Registry.getVOForGroup(currentGroup)
22+
userVO = getVOForGroup(currentGroup)
2423

2524
return currentUser, currentDN, currentGroup, userVO
2625

2726

2827
def test_storeRetrieveDelete():
29-
currentUser, currentDN, currentGroup, userVO = _userInfo()
28+
_, _, currentGroup, _ = _userInfo()
3029

3130
retVal = up.storeVar(key, value, {"ReadAccess": "ALL", "PublishAccess": "ALL"})
3231
assert retVal["OK"], retVal
3332
assert retVal["Value"] == 1
3433

35-
retVal = up.retrieveVar(key)
36-
assert retVal["OK"], retVal
37-
assert retVal["Value"] == value
38-
39-
retVal = up.listAvailableVars()
40-
assert retVal["OK"], retVal
41-
assert retVal["Value"] == [["adminusername", currentGroup, userVO or "undefined", key]]
34+
try:
35+
retVal = up.retrieveVar(key)
36+
assert retVal["OK"], retVal
37+
assert retVal["Value"] == value
4238

43-
retVal = up.getUserProfiles()
44-
assert retVal["OK"], retVal
45-
assert retVal["Value"] == {"Web/application/desktop": {key: "s5:value"}}
39+
retVal = up.listAvailableVars()
40+
assert retVal["OK"], retVal
41+
assert retVal["Value"] == [["adminusername", currentGroup, "vo", key]]
4642

47-
retVal = up.getVarPermissions(key)
48-
assert retVal["OK"], retVal
49-
assert retVal["Value"] == {"PublishAccess": "ALL", "ReadAccess": "ALL"}
43+
retVal = up.getUserProfiles()
44+
assert retVal["OK"], retVal
45+
assert retVal["Value"] == {"Web/application/desktop": {key: "s5:value"}}
5046

51-
retVal = up.deleteVar(key)
52-
assert retVal["OK"], retVal
53-
assert retVal["Value"] == 1
47+
retVal = up.getVarPermissions(key)
48+
assert retVal["OK"], retVal
49+
assert retVal["Value"] == {"PublishAccess": "ALL", "ReadAccess": "ALL"}
50+
finally:
51+
retVal = up.deleteVar(key)
52+
assert retVal["OK"], retVal
53+
assert retVal["Value"] == 1
5454

5555

5656
def test_retrieveAllVars():
@@ -61,12 +61,13 @@ def test_retrieveAllVars():
6161
retVal = up.storeVar(key, value, {"ReadAccess": "ALL", "PublishAccess": "ALL"})
6262
assert retVal["OK"], retVal
6363

64-
retVal = up.retrieveAllVars()
65-
assert retVal["OK"], retVal
66-
assert retVal["Value"] == {key: value}
67-
68-
retVal = up.deleteVar(key)
69-
assert retVal["OK"], retVal
64+
try:
65+
retVal = up.retrieveAllVars()
66+
assert retVal["OK"], retVal
67+
assert retVal["Value"] == {key: value}
68+
finally:
69+
retVal = up.deleteVar(key)
70+
assert retVal["OK"], retVal
7071

7172

7273
def test_listStatesForWeb():
@@ -93,27 +94,29 @@ def test_setVarPermissions(readAccess, publishAccess):
9394
assert retVal["OK"], retVal
9495
newPermissions = {"ReadAccess": readAccess, "PublishAccess": publishAccess}
9596

96-
retVal = up.setVarPermissions(key, newPermissions)
97-
assert retVal["OK"], retVal
98-
assert retVal["Value"] == 1
99-
100-
retVal = up.getVarPermissions(key)
101-
assert retVal["OK"], retVal
102-
assert retVal["Value"] == newPermissions
97+
try:
98+
retVal = up.setVarPermissions(key, newPermissions)
99+
assert retVal["OK"], retVal
100+
assert retVal["Value"] == 1
103101

104-
retVal = up.deleteVar(key)
105-
assert retVal["OK"], retVal
102+
retVal = up.getVarPermissions(key)
103+
assert retVal["OK"], retVal
104+
assert retVal["Value"] == newPermissions
105+
finally:
106+
retVal = up.deleteVar(key)
107+
assert retVal["OK"], retVal
106108

107109

108110
def test_retrieveVarFromUser():
109-
currentUser, currentDN, currentGroup, userVO = _userInfo()
111+
currentUser, _, currentGroup, _ = _userInfo()
110112

111113
retVal = up.storeVar(key, value, {"ReadAccess": "ALL", "PublishAccess": "ALL"})
112114
assert retVal["OK"], retVal
113115

114-
retVal = up.retrieveVarFromUser(currentUser, currentGroup, key)
115-
assert retVal["OK"], retVal
116-
assert retVal["Value"] == value
117-
118-
retVal = up.deleteVar(key)
119-
assert retVal["OK"], retVal
116+
try:
117+
retVal = up.retrieveVarFromUser(currentUser, currentGroup, key)
118+
assert retVal["OK"], retVal
119+
assert retVal["Value"] == value
120+
finally:
121+
retVal = up.deleteVar(key)
122+
assert retVal["OK"], retVal

0 commit comments

Comments
 (0)