Skip to content

Commit

Permalink
fix: few test simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Mar 7, 2025
1 parent 61a98c7 commit 21778ac
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 72 deletions.
2 changes: 0 additions & 2 deletions integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,8 +1133,6 @@ def _make_config(modules, flags, release_var, editable):
"SERVER_HOST": "server",
"CLIENT_HOST": "client",
"PILOT_HOST": "pilot",
# Test specific variables
"WORKSPACE": "/home/dirac",
# DiracX variable
"DIRACX_URL": "http://diracx:8000",
}
Expand Down
6 changes: 3 additions & 3 deletions src/DIRAC/Core/scripts/dirac_install_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def main():
for db in args:
result = gComponentInstaller.installDatabase(db)
if not result["OK"]:
gLogger.error(f"ERROR: failed to correctly install {db}", result["Message"])
gLogger.error(f"Failed to correctly install {db}:", result["Message"])
DIRACExit(1)
extension, system = result["Value"]
result = gComponentInstaller.addDatabaseOptionsToCS(gConfig, system, db, overwrite=True)
if not result["OK"]:
gLogger.error(f"ERROR: failed to add database options to CS: {result['Message']}")
gLogger.error("Failed to add database options to CS:", result["Message"])
DIRACExit(1)

if db != "InstalledComponentsDB":
Expand All @@ -46,7 +46,7 @@ def main():

result = MonitoringUtilities.monitorInstallation("DB", system, db, user=user)
if not result["OK"]:
gLogger.error(f"ERROR: failed to register installation in database: {result['Message']}")
gLogger.error("Failed to register installation in database:", result["Message"])
DIRACExit(1)


Expand Down
50 changes: 22 additions & 28 deletions src/DIRAC/tests/Utilities/testJobDefinitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def helloWorld():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorld.log")
return endOfAllJobs(J)

Expand All @@ -74,7 +74,7 @@ def helloWorldJenkins():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setDestination("DIRAC.Jenkins.ch")
return endOfAllJobs(J)
Expand All @@ -90,9 +90,7 @@ def helloWorld_input():
try:
J.setInputSandbox([find_all("exe-script-with-input.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox(
[find_all("exe-script-with-input.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]]
)
J.setInputSandbox([find_all("exe-script-with-input.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script-with-input.py", "", "helloWorld.log")
return endOfAllJobs(J)

Expand All @@ -108,11 +106,7 @@ def helloWorld_input_single():
J.setInputSandbox([find_all("exe-script-with-input-single-location.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox(
[
find_all(
"exe-script-with-input-single-location.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow"
)[0]
]
[find_all("exe-script-with-input-single-location.py", "/home/dirac", "DIRAC/tests/Workflow")[0]]
)
J.setExecutable("exe-script-with-input-single-location.py", "", "helloWorld.log")
return endOfAllJobs(J)
Expand All @@ -128,7 +122,7 @@ def helloWorldCERN():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setDestination("LCG.CERN.cern")
return endOfAllJobs(J)
Expand All @@ -144,7 +138,7 @@ def helloWorldNCBJ():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setDestination("LCG.NCBJ.pl")
return endOfAllJobs(J)
Expand All @@ -160,7 +154,7 @@ def helloWorldGRIDKA():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setDestination("LCG.GRIDKA.de")
return endOfAllJobs(J)
Expand All @@ -176,7 +170,7 @@ def helloWorldRAL():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setDestination("LCG.RAL.uk")
return endOfAllJobs(J)
Expand All @@ -192,7 +186,7 @@ def helloWorldPIC():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setDestination("LCG.PIC.es")
return endOfAllJobs(J)
Expand All @@ -208,7 +202,7 @@ def helloWorldRALPP():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setDestination("LCG.UKI-SOUTHGRID-RALPP.uk")
return endOfAllJobs(J)
Expand All @@ -224,7 +218,7 @@ def helloWorldGRIF():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setDestination("LCG.GRIF.fr")
return endOfAllJobs(J)
Expand All @@ -240,7 +234,7 @@ def helloWorldSSHBatch():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setDestination("DIRAC.Jenkins_SSHBatch.ch")
return endOfAllJobs(J)
Expand All @@ -256,7 +250,7 @@ def helloWorldARM():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setDestination("DIRAC.ARM.ch")
return endOfAllJobs(J)
Expand All @@ -272,7 +266,7 @@ def helloWorldCloudCE():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setExecutable("exe-script.py", "", "helloWorldCloud.log")
J.setDestinationCE("stealthcloud.ic.ac.uk", "LCG.UKI-LT2-IC-HEP.uk")
return endOfAllJobs(J)
Expand All @@ -288,7 +282,7 @@ def mpJob():
try:
J.setInputSandbox([find_all("mpTest.py", ".", "DIRAC/tests/Utilities")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("mpTest.py", os.environ["WORKSPACE"], "DIRAC/tests/Utilities")[0]])
J.setInputSandbox([find_all("mpTest.py", "/home/dirac", "DIRAC/tests/Utilities")[0]])

J.setExecutable("mpTest.py")
J.setTag(["4Processors", "MultiProcessor"])
Expand All @@ -305,7 +299,7 @@ def mp3Job():
try:
J.setInputSandbox([find_all("mpTest.py", ".", "DIRAC/tests/Utilities")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("mpTest.py", os.environ["WORKSPACE"], "DIRAC/tests/Utilities")[0]])
J.setInputSandbox([find_all("mpTest.py", "/home/dirac", "DIRAC/tests/Utilities")[0]])

J.setExecutable("mpTest.py")
J.setNumberOfProcessors(numberOfProcessors=3)
Expand All @@ -322,7 +316,7 @@ def min2max4Job():
try:
J.setInputSandbox([find_all("mpTest.py", ".", "DIRAC/tests/Utilities")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("mpTest.py", os.environ["WORKSPACE"], "DIRAC/tests/Utilities")[0]])
J.setInputSandbox([find_all("mpTest.py", "/home/dirac", "DIRAC/tests/Utilities")[0]])

J.setExecutable("mpTest.py")
J.setNumberOfProcessors(minNumberOfProcessors=2, maxNumberOfProcessors=4)
Expand All @@ -339,7 +333,7 @@ def wholeNodeJob():
try:
J.setInputSandbox([find_all("mpTest.py", ".", "DIRAC/tests/Utilities")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("mpTest.py", os.environ["WORKSPACE"], "DIRAC/tests/Utilities")[0]])
J.setInputSandbox([find_all("mpTest.py", "/home/dirac", "DIRAC/tests/Utilities")[0]])

J.setExecutable("mpTest.py")
J.setTag(["WholeNode", "MultiProcessor"])
Expand All @@ -356,7 +350,7 @@ def parametricJob():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setParameterSequence("args", ["one", "two", "three"])
J.setParameterSequence("iargs", [1, 2, 3])
J.setExecutable("exe-script.py", arguments=": testing %(args)s %(iargs)s", logFile="helloWorld_%n.log")
Expand All @@ -373,7 +367,7 @@ def parametricJobInputData():
try:
J.setInputSandbox([find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]])
except IndexError: # we are in Jenkins
J.setInputSandbox([find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]])
J.setInputSandbox([find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]])
J.setParameterSequence("args", ["one", "two", "three"])
J.setParameterSequence("iargs", [1, 2, 3])
J.setParameterSequence(
Expand Down Expand Up @@ -404,7 +398,7 @@ def jobWithOutput():
try:
inp2 = [find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]]
except IndexError: # we are in Jenkins
inp2 = [find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]]
inp2 = [find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]]
J.setInputSandbox(inp1 + inp2)
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setOutputData([timenow + "testFileUpload.txt"])
Expand Down Expand Up @@ -434,7 +428,7 @@ def jobWithOutputs():
try:
inp2 = [find_all("exe-script.py", ".", "DIRAC/tests/Workflow")[0]]
except IndexError: # we are in Jenkins
inp2 = [find_all("exe-script.py", os.environ["WORKSPACE"], "DIRAC/tests/Workflow")[0]]
inp2 = [find_all("exe-script.py", "/home/dirac", "DIRAC/tests/Workflow")[0]]
J.setInputSandbox(inp1 + inp2)
J.setExecutable("exe-script.py", "", "helloWorld.log")
J.setOutputData([timenow + "testFileUpload.txt"], outputSE=["RAL-SE", "IN2P3-SE"])
Expand Down
8 changes: 4 additions & 4 deletions tests/CI/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ echo -e "*** $(date -u) **** Starting integration tests on ${INSTALLTYPE} ****\n

if [[ "$INSTALLTYPE" == "server" ]]; then
# shellcheck source=/dev/null
source "$WORKSPACE/ServerInstallDIR/bashrc"
source /home/dirac/ServerInstallDIR/bashrc
# If not unset, assert will not trigger
unset PYTHONOPTIMIZE
# shellcheck disable=SC2034
Expand All @@ -34,14 +34,14 @@ if [[ "$INSTALLTYPE" == "server" ]]; then
ERR=0
for repo_path in "${TESTREPO[@]}"; do
# TODO: The tests should be refactored to remove the need for this
cp -r "${repo_path}/tests" "$WORKSPACE/ServerInstallDIR/$(basename "${repo_path}")"
cp -r "${repo_path}/tests" /home/dirac/ServerInstallDIR/$(basename "${repo_path}")
done
for repo_path in "${TESTREPO[@]}"; do
source "${repo_path}/tests/Integration/all_integration_server_tests.sh"
done
elif [[ "$INSTALLTYPE" == "client" ]]; then
# shellcheck source=/dev/null
source "$WORKSPACE/ClientInstallDIR/bashrc"
source /home/dirac/ClientInstallDIR/bashrc
# If not unset, assert will not trigger
unset PYTHONOPTIMIZE
set -o pipefail
Expand All @@ -52,7 +52,7 @@ elif [[ "$INSTALLTYPE" == "client" ]]; then

elif [[ "$INSTALLTYPE" == "pilot" ]]; then
# shellcheck source=/dev/null
source "$WORKSPACE/bashrc"
source /home/dirac/bashrc"
# If not unset, assert will not trigger
unset PYTHONOPTIMIZE
set -o pipefail
Expand Down
13 changes: 3 additions & 10 deletions tests/Jenkins/dirac_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#
# === optional environment variables:
#
# WORKSPACE (/home/dirac)
# DEBUG (set it to whatever value to turn on debug messages)
#
# DIRAC_RELEASE (for installing a specific release)
Expand Down Expand Up @@ -52,18 +51,12 @@ else
DEBUG='-dd'
fi

if [[ "$WORKSPACE" ]]; then
echo "==> We are in Jenkins I guess"
else
WORKSPACE=$PWD
fi

# Creating default structure
mkdir -p "$WORKSPACE/TestCode" # Where the test code resides
mkdir -p /home/dirac/TestCode # Where the test code resides
TESTCODE=${_}
mkdir -p "$WORKSPACE/ServerInstallDIR" # Where servers are installed
mkdir -p /home/dirac/ServerInstallDIR # Where servers are installed
SERVERINSTALLDIR=${_}
mkdir -p "$WORKSPACE/ClientInstallDIR" # Where clients are installed
mkdir -p /home/dirac/ClientInstallDIR # Where clients are installed
CLIENTINSTALLDIR=${_}

# Location of the CFG file to be used (this can be replaced by the extensions)
Expand Down
Loading

0 comments on commit 21778ac

Please sign in to comment.