Skip to content

Commit

Permalink
Merge pull request #7560 from fstagni/cherry-pick-2-58bd1ca0c-integra…
Browse files Browse the repository at this point in the history
…tion

[sweep:integration] test: fix PilotWrapper test
  • Loading branch information
fstagni authored Apr 9, 2024
2 parents e0160a0 + 8aa427d commit 8101f84
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
5 changes: 4 additions & 1 deletion integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ def prepare_environment(
modules = DEFAULT_MODULES | dict(f.split("=", 1) for f in extra_module)
modules = {k: Path(v).absolute() for k, v in modules.items()}

flags = dict(f.split("=", 1) for f in flags)
if not flags:
flags = {}
else:
flags = dict(f.split("=", 1) for f in flags)
docker_compose_env = _make_env(flags)
server_flags = {}
client_flags = {}
Expand Down
3 changes: 1 addition & 2 deletions src/DIRAC/Core/Security/ProxyFile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
""" Collection of utilities for dealing with security files (i.e. proxy files)
"""
import os
import stat
import tempfile

from DIRAC import S_OK, S_ERROR
Expand All @@ -20,7 +19,7 @@ def writeToProxyFile(proxyContents, fileName=False):
- fileName : filename to dump to
"""
try:
with secureOpenForWrite(fileName) as fd:
with secureOpenForWrite(fileName) as (fd, fileName):
fd.write(proxyContents)
except Exception as e:
return S_ERROR(DErrno.EWF, f" {fileName}: {repr(e).replace(',)', ')')}")
Expand Down
2 changes: 1 addition & 1 deletion src/DIRAC/Core/Security/m2crypto/X509CRL.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def dumpAllToFile(self, filename=False):
if not self.__loadedCert:
return S_ERROR("No certificate loaded")
try:
with secureOpenForWrite(filename) as fd:
with secureOpenForWrite(filename) as (fd, filename):
fd.write(self.__pemData)
except Exception as e:
return S_ERROR(DErrno.EWF, f"{filename}: {repr(e).replace(',)', ')')}")
Expand Down
4 changes: 2 additions & 2 deletions src/DIRAC/Core/Security/m2crypto/X509Chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def generateProxyToFile(self, filePath, lifetime, diracGroup=False, strength=DEF
if not retVal["OK"]:
return retVal
try:
with secureOpenForWrite(filePath) as fd:
with secureOpenForWrite(filePath) as (fd, _filename):
fd.write(retVal["Value"])
except Exception as e:
return S_ERROR(DErrno.EWF, f"{filePath} :{repr(e).replace(',)', ')')}")
Expand Down Expand Up @@ -829,7 +829,7 @@ def dumpAllToFile(self, filename=False):
return retVal
pemData = retVal["Value"]
try:
with secureOpenForWrite(filename) as fh:
with secureOpenForWrite(filename) as (fh, filename):
fh.write(pemData)
except Exception as e:
return S_ERROR(DErrno.EWF, f"{filename} :{repr(e).replace(',)', ')')}")
Expand Down
2 changes: 1 addition & 1 deletion src/DIRAC/Core/Utilities/File.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def secureOpenForWrite(filename=None, *, text=True):
else:
fd, filename = tempfile.mkstemp(text=text)
with open(fd, "w" if text else "wb", encoding="ascii") as fd:
yield fd
yield fd, filename


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def writeToTokenFile(tokenContents, fileName):
"""
location = getTokenFileLocation(fileName)
try:
with secureOpenForWrite(location) as fd:
with secureOpenForWrite(location) as (fd, location):
fd.write(tokenContents)
except Exception as e:
return S_ERROR(DErrno.EWF, f" {location}: {repr(e)}")
Expand Down
2 changes: 1 addition & 1 deletion src/DIRAC/Interfaces/Utilities/DConfigCache.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def cacheConfig(self):
if self.newConfig:
self.__cleanCacheDirectory()

with secureOpenForWrite(self.configCacheName, text=False) as fcache:
with secureOpenForWrite(self.configCacheName, text=False) as (fcache, self.configCacheName):
pickle.dump(gConfigurationData.mergedCFG, fcache)
else:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_scriptoptions():
pilotOptions="-c 123 --foo bar",
)

assert "with open('dirac_boh.py', 'wb') as fd:" in res
assert "os.open('dirac_boh.py', os.O_WRONLY" in res
assert 'os.environ["someName"]="someValue"' not in res


Expand Down Expand Up @@ -58,7 +58,7 @@ def test_scriptReal():
pilotOptions="-c 123 --foo bar",
)

assert "with open('dirac-pilot.py', 'wb') as fd:" in res
assert "os.open('dirac-pilot.py', os.O_WRONLY" in res
assert 'os.environ["someName"]="someValue"' not in res


Expand Down
2 changes: 0 additions & 2 deletions tests/CI/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.4'

volumes:
# Volume used to store the config of diracx
diracx-cs-store:
Expand Down

0 comments on commit 8101f84

Please sign in to comment.