示例#1
0
 def test_check_files_should_raise_an_exception_if_the_mpiexec_is_not_found(
         self):
     lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"])
     lm.mpirun = "mpifoo"
     self.assertRaises(
         IOError, lm.check_files, MockExecutable(sys.executable),
         "main_file"
     )  # main_file does not exist either, but mpirun is checked first
示例#2
0
class TestDistributedLaunchMode(unittest.TestCase, BaseTestLaunchMode):

    def setUp(self):
        self.lm = DistributedLaunchMode(2, "mpiexec", ["node1", "node2"])
        if self.lm.mpirun is None:
            raise unittest.SkipTest("mpiexec not found")

    def tearDown(self):
        for path in "valid_test_script.py", "invalid_test_script.py", "test_parameters":
            if os.path.exists(path):
                os.remove(path)

    def test__init__should_not_raise_an_exception_if_the_mpiexec_is_not_found(self):
        lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"])

    def test_check_files_should_raise_an_exception_if_the_mpiexec_is_not_found(self):
        lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"])
        lm.mpirun = "mpifoo"
        self.assertRaises(IOError, lm.check_files, MockExecutable(sys.executable), "main_file")  # main_file does not exist either, but mpirun is checked first

    def test__init__should_set_mpirun_to_the_full_path(self):
        for path in "/usr/bin/mpiexec", "/usr/local/bin/mpiexec":
            if os.path.exists(path):
                self.assertEqual(self.lm.mpirun, path)
                break

    def test_getstate_should_return_an_appropriate_dict(self):
        self.assertEqual(self.lm.__getstate__(),
                         {'working_directory': self.lm.working_directory,
                          'mpirun': self.lm.mpirun,
                          'n': 2,
                          'options': None,
                          'hosts': ["node1", "node2"],
                          'pfi_path': '/usr/local/bin/pfi.py'})
示例#3
0
class TestDistributedLaunchMode(unittest.TestCase, BaseTestLaunchMode):

    def setUp(self):
        self.lm = DistributedLaunchMode(2, "mpiexec", ["node1", "node2"])
        if self.lm.mpirun is None:
            raise unittest.SkipTest("mpiexec not found")

    def tearDown(self):
        for path in "valid_test_script.py", "invalid_test_script.py", "test_parameters":
            if os.path.exists(path):
                os.remove(path)

    def test__init__should_not_raise_an_exception_if_the_mpiexec_is_not_found(self):
        lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"])

    def test_check_files_should_raise_an_exception_if_the_mpiexec_is_not_found(self):
        lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"])
        lm.mpirun = "mpifoo"
        self.assertRaises(IOError, lm.check_files, MockExecutable(sys.executable), "main_file")  # main_file does not exist either, but mpirun is checked first

    def test__init__should_set_mpirun_to_the_full_path(self):
        for path in "/usr/bin/mpiexec", "/usr/local/bin/mpiexec":
            if os.path.exists(path):
                self.assertEqual(self.lm.mpirun, path)
                break

    def test_getstate_should_return_an_appropriate_dict(self):
        self.assertEqual(self.lm.__getstate__(),
                         {'working_directory': self.lm.working_directory,
                          'mpirun': self.lm.mpirun,
                          'n': 2,
                          'options': None,
                          'hosts': ["node1", "node2"],
                          'pfi_path': '/usr/local/bin/pfi.py'})
示例#4
0
    def __init__(self, np=1, reason=None, label=None):
        self.np = np
        self.reason = reason
        self.label = label + '_' + time.strftime("%d%m%y-%H%M%S")

        if self.np > 1:
            self.launchmode = DistributedLaunchMode(self.np)
            self.executable = sumatra.programs.Executable(path="mpirun")
        else:
            self.launchmode = SerialLaunchMode()
            self.executable = sumatra.programs.PythonExecutable(
                path=sys.executable)
示例#5
0
 def setUp(self):
     self.lm = DistributedLaunchMode(2, "mpiexec", ["node1", "node2"])
     if self.lm.mpirun is None:
         raise unittest.SkipTest("mpiexec not found")
示例#6
0
 def test_check_files_should_raise_an_exception_if_the_mpiexec_is_not_found(self):
     lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"])
     lm.mpirun = "mpifoo"
     self.assertRaises(IOError, lm.check_files, MockExecutable(sys.executable), "main_file")  # main_file does not exist either, but mpirun is checked first
示例#7
0
 def setUp(self):
     self.lm = DistributedLaunchMode(2, "mpiexec", ["node1", "node2"])
     if self.lm.mpirun is None:
         raise unittest.SkipTest("mpiexec not found")
示例#8
0
 def test__init__should_not_raise_an_exception_if_the_mpiexec_is_not_found(self):
     lm = DistributedLaunchMode(2, "mpifoo", ["node1", "node2"])