Commit bb48dd37 authored by Michael Salim's avatar Michael Salim
Browse files

worker MPI tests

parent cc97e189
......@@ -4,6 +4,8 @@ import django
import tempfile
import unittest
import balsam
test_dir = os.path.abspath(os.path.dirname(balsam.__file__))
def set_permissions(top):
os.chmod(top, 0o755)
......@@ -14,7 +16,7 @@ def set_permissions(top):
os.chmod(file, 0o644)
def main():
tempdir = tempfile.TemporaryDirectory(dir=os.getcwd(), prefix="testdata_")
tempdir = tempfile.TemporaryDirectory(dir=test_dir, prefix="testdata_")
os.environ['BALSAM_TEST_DIRECTORY'] = tempdir.name
os.environ['BALSAM_TEST']='1'
......
import os
import sys
from importlib.util import find_spec
import subprocess
from .BalsamTestCase import BalsamTestCase
from balsam.launcher import worker
from balsam.launcher.launcher import get_args
from balsam.launcher import mpi_commands
from balsam.service.schedulers import Scheduler
......@@ -47,3 +51,28 @@ class WorkerGroupUnitTests(BalsamTestCase):
workers_str=self.scheduler.workers_str,
workers_file=self.scheduler.workers_file)
self.assertGreaterEqual(len(group.workers), 1)
def test_mpi_can_run(self):
'''The system-detected mpirun works'''
config = get_args('--consume-all'.split())
host_type = self.scheduler.host_type
worker_group = worker.WorkerGroup(config, host_type=host_type,
workers_str=self.scheduler.workers_str,
workers_file=self.scheduler.workers_file)
mpi_cmd_class = getattr(mpi_commands, f"{host_type}MPICommand")
mpi_cmd = mpi_cmd_class()
app_path = f"{sys.executable} {find_spec('tests.mock_mpi_app').origin}"
mpi_str = mpi_cmd([worker_group[0]], app_cmd=app_path, envs={},
num_ranks=2, ranks_per_node=2,
threads_per_rank=1, threads_per_core=1)
args = mpi_str.split()
mpi = subprocess.Popen(args, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout, _ = mpi.communicate()
stdout = stdout.decode()
self.assertIn('Rank 0', stdout)
self.assertIn('Rank 1', stdout)
self.assertEqual(mpi.returncode, 0)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment