Skip to content

Commit

Permalink
add singularity and apptainer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SpheMakh committed Jul 2, 2023
1 parent 6304f3f commit 179ec5c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 35 deletions.
6 changes: 6 additions & 0 deletions Jenkinsfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ stimela pull #--force
cd $TEST_OUTPUT_DIR
export SILENT_STDERR=ON
python3 -m nose --with-xunit --xunit-file $WORKSPACE_ROOT/nosetests.xml "${WORKSPACE_ROOT}/projects/Stimela/stimela/tests" -v

# Re-run unit tests with apptainer
module unload singularity
module load apptainer/1.2.0-rc.1

python3 -m nose --with-xunit --xunit-file $WORKSPACE_ROOT/nosetests.xml "${WORKSPACE_ROOT}/projects/Stimela/stimela/tests/unit_tests" -v
75 changes: 40 additions & 35 deletions stimela/tests/unit_tests/test-containertech.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ def setUpClass(cls):
global SINGULARITY, PODMAN
SINGULARITY = False
PODMAN = False
SINGULARITY = singularity.version and singularity.version >= "2.6.0"
if singularity.version:
if singularity.BINARY_NAME == "singularity":
SINGULARITY = singularity.version >= "2.6.0"
else:
SINGULARITY = True


@classmethod
def tearDownClass(cls):
Expand All @@ -55,40 +60,40 @@ def setUp(self):
if not os.path.isdir(INPUT):
os.mkdir(INPUT)

# def test_singularity(self):
# global MSDIR
# global INPUT
# global OUTPUT
# global SINGULARITY
#
# if SINGULARITY is False:
# return
#
# stimela.register_globals()
# rrr = stimela.Recipe("singularitypaths",
# ms_dir=MSDIR,
# JOB_TYPE="singularity",
# cabpath="cab/",
# singularity_image_dir=os.environ["STIMELA_PULLFOLDER"],
# log_dir="logs")
# rrr.add("cab/custom", "test1", {
# "bla1": "a", # only accepts a, b or c
# "bla5": ["testinput2.txt:input",
# "testinput3.txt:msfile",
# spf("{}hello\{reim\}.fits,{}to.fits,{}world.fits", "input", "msfile", "output")],
# }, input=INPUT, output=OUTPUT)
# rrr.run() #validate and run
#
# assert rrr.jobs[0].job._cab.parameters[4].value[0] == os.path.join(rrr.jobs[0].job.IODEST["input"],
# "testinput2.txt")
# assert rrr.jobs[0].job._cab.parameters[4].value[1] == os.path.join(rrr.jobs[0].job.IODEST["msfile"],
# "testinput3.txt")
# assert rrr.jobs[0].job._cab.parameters[4].value[2] == \
# "{}/hello{{reim}}.fits,{}/to.fits,{}/world.fits".format(
# rrr.jobs[0].job.IODEST["input"],
# rrr.jobs[0].job.IODEST["msfile"],
# rrr.jobs[0].job.IODEST["output"]
# )
def test_singularity(self):
global MSDIR
global INPUT
global OUTPUT
global SINGULARITY

if SINGULARITY is False:
return

stimela.register_globals()
rrr = stimela.Recipe("singularitypaths",
ms_dir=MSDIR,
JOB_TYPE="singularity",
cabpath="cab/",
singularity_image_dir=os.environ["STIMELA_PULLFOLDER"],
log_dir="logs")
rrr.add("cab/custom", "test1", {
"bla1": "a", # only accepts a, b or c
"bla5": ["testinput2.txt:input",
"testinput3.txt:msfile",
spf("{}hello\{reim\}.fits,{}to.fits,{}world.fits", "input", "msfile", "output")],
}, input=INPUT, output=OUTPUT)
rrr.run() #validate and run

assert rrr.jobs[0].job._cab.parameters[4].value[0] == os.path.join(rrr.jobs[0].job.IODEST["input"],
"testinput2.txt")
assert rrr.jobs[0].job._cab.parameters[4].value[1] == os.path.join(rrr.jobs[0].job.IODEST["msfile"],
"testinput3.txt")
assert rrr.jobs[0].job._cab.parameters[4].value[2] == \
"{}/hello{{reim}}.fits,{}/to.fits,{}/world.fits".format(
rrr.jobs[0].job.IODEST["input"],
rrr.jobs[0].job.IODEST["msfile"],
rrr.jobs[0].job.IODEST["output"]
)

def test_podman(self):
global MSDIR
Expand Down

0 comments on commit 179ec5c

Please sign in to comment.