##// END OF EJS Templates
add Condor launcher tests
James Booth -
Show More
@@ -1,179 +1,185
1 1 """Tests for launchers
2 2
3 3 Doesn't actually start any subprocesses, but goes through the motions of constructing
4 4 objects, which should test basic config.
5 5
6 6 Authors:
7 7
8 8 * Min RK
9 9 """
10 10
11 11 #-------------------------------------------------------------------------------
12 12 # Copyright (C) 2013 The IPython Development Team
13 13 #
14 14 # Distributed under the terms of the BSD License. The full license is in
15 15 # the file COPYING, distributed as part of this software.
16 16 #-------------------------------------------------------------------------------
17 17
18 18 #-------------------------------------------------------------------------------
19 19 # Imports
20 20 #-------------------------------------------------------------------------------
21 21
22 22 import logging
23 23 import os
24 24 import shutil
25 25 import sys
26 26 import tempfile
27 27
28 28 from unittest import TestCase
29 29
30 30 from nose import SkipTest
31 31
32 32 from IPython.config import Config
33 33
34 34 from IPython.parallel.apps import launcher
35 35
36 36 from IPython.testing import decorators as dec
37 37
38 38
39 39 #-------------------------------------------------------------------------------
40 40 # TestCase Mixins
41 41 #-------------------------------------------------------------------------------
42 42
43 43 class LauncherTest:
44 44 """Mixin for generic launcher tests"""
45 45 def setUp(self):
46 46 self.profile_dir = tempfile.mkdtemp(prefix="profile_")
47 47
48 48 def tearDown(self):
49 49 shutil.rmtree(self.profile_dir)
50 50
51 51 @property
52 52 def config(self):
53 53 return Config()
54 54
55 55 def build_launcher(self, **kwargs):
56 56 kw = dict(
57 57 work_dir=self.profile_dir,
58 58 profile_dir=self.profile_dir,
59 59 config=self.config,
60 60 cluster_id='',
61 61 log=logging.getLogger(),
62 62 )
63 63 kw.update(kwargs)
64 64 return self.launcher_class(**kw)
65 65
66 66 def test_profile_dir_arg(self):
67 67 launcher = self.build_launcher()
68 68 self.assertTrue("--profile-dir" in launcher.cluster_args)
69 69 self.assertTrue(self.profile_dir in launcher.cluster_args)
70 70
71 71 def test_cluster_id_arg(self):
72 72 launcher = self.build_launcher()
73 73 self.assertTrue("--cluster-id" in launcher.cluster_args)
74 74 idx = launcher.cluster_args.index("--cluster-id")
75 75 self.assertEqual(launcher.cluster_args[idx+1], '')
76 76 launcher.cluster_id = 'foo'
77 77 self.assertEqual(launcher.cluster_args[idx+1], 'foo')
78 78
79 79 def test_args(self):
80 80 launcher = self.build_launcher()
81 81 for arg in launcher.args:
82 82 self.assertTrue(isinstance(arg, basestring), str(arg))
83 83
84 84 class BatchTest:
85 85 """Tests for batch-system launchers (LSF, SGE, PBS)"""
86 86 def test_batch_template(self):
87 87 launcher = self.build_launcher()
88 88 batch_file = os.path.join(self.profile_dir, launcher.batch_file_name)
89 89 self.assertEqual(launcher.batch_file, batch_file)
90 90 launcher.write_batch_script(1)
91 91 self.assertTrue(os.path.isfile(batch_file))
92 92
93 93 class SSHTest:
94 94 """Tests for SSH launchers"""
95 95 def test_cluster_id_arg(self):
96 96 raise SkipTest("SSH Launchers don't support cluster ID")
97 97
98 98 def test_remote_profile_dir(self):
99 99 cfg = Config()
100 100 launcher_cfg = getattr(cfg, self.launcher_class.__name__)
101 101 launcher_cfg.remote_profile_dir = "foo"
102 102 launcher = self.build_launcher(config=cfg)
103 103 self.assertEqual(launcher.remote_profile_dir, "foo")
104 104
105 105 def test_remote_profile_dir_default(self):
106 106 launcher = self.build_launcher()
107 107 self.assertEqual(launcher.remote_profile_dir, self.profile_dir)
108 108
109 109 #-------------------------------------------------------------------------------
110 110 # Controller Launcher Tests
111 111 #-------------------------------------------------------------------------------
112 112
113 113 class ControllerLauncherTest(LauncherTest):
114 114 """Tests for Controller Launchers"""
115 115 pass
116 116
117 117 class TestLocalControllerLauncher(ControllerLauncherTest, TestCase):
118 118 launcher_class = launcher.LocalControllerLauncher
119 119
120 120 class TestMPIControllerLauncher(ControllerLauncherTest, TestCase):
121 121 launcher_class = launcher.MPIControllerLauncher
122 122
123 123 class TestPBSControllerLauncher(BatchTest, ControllerLauncherTest, TestCase):
124 124 launcher_class = launcher.PBSControllerLauncher
125 125
126 126 class TestSGEControllerLauncher(BatchTest, ControllerLauncherTest, TestCase):
127 127 launcher_class = launcher.SGEControllerLauncher
128 128
129 129 class TestLSFControllerLauncher(BatchTest, ControllerLauncherTest, TestCase):
130 130 launcher_class = launcher.LSFControllerLauncher
131 131
132 class TestCondorControllerLauncher(BatchTest, ControllerLauncherTest, TestCase):
133 launcher_class = launcher.CondorControllerLauncher
134
132 135 class TestSSHControllerLauncher(SSHTest, ControllerLauncherTest, TestCase):
133 136 launcher_class = launcher.SSHControllerLauncher
134 137
135 138 #-------------------------------------------------------------------------------
136 139 # Engine Set Launcher Tests
137 140 #-------------------------------------------------------------------------------
138 141
139 142 class EngineSetLauncherTest(LauncherTest):
140 143 """Tests for EngineSet launchers"""
141 144 pass
142 145
143 146 class TestLocalEngineSetLauncher(EngineSetLauncherTest, TestCase):
144 147 launcher_class = launcher.LocalEngineSetLauncher
145 148
146 149 class TestMPIEngineSetLauncher(EngineSetLauncherTest, TestCase):
147 150 launcher_class = launcher.MPIEngineSetLauncher
148 151
149 152 class TestPBSEngineSetLauncher(BatchTest, EngineSetLauncherTest, TestCase):
150 153 launcher_class = launcher.PBSEngineSetLauncher
151 154
152 155 class TestSGEEngineSetLauncher(BatchTest, EngineSetLauncherTest, TestCase):
153 156 launcher_class = launcher.SGEEngineSetLauncher
154 157
155 158 class TestLSFEngineSetLauncher(BatchTest, EngineSetLauncherTest, TestCase):
156 159 launcher_class = launcher.LSFEngineSetLauncher
157 160
161 class TestCondorEngineSetLauncher(BatchTest, EngineSetLauncherTest, TestCase):
162 launcher_class = launcher.CondorEngineSetLauncher
163
158 164 class TestSSHEngineSetLauncher(EngineSetLauncherTest, TestCase):
159 165 launcher_class = launcher.SSHEngineSetLauncher
160 166
161 167 def test_cluster_id_arg(self):
162 168 raise SkipTest("SSH Launchers don't support cluster ID")
163 169
164 170 class TestSSHProxyEngineSetLauncher(SSHTest, LauncherTest, TestCase):
165 171 launcher_class = launcher.SSHProxyEngineSetLauncher
166 172
167 173 class TestSSHEngineLauncher(SSHTest, LauncherTest, TestCase):
168 174 launcher_class = launcher.SSHEngineLauncher
169 175
170 176 #-------------------------------------------------------------------------------
171 177 # Windows Launcher Tests
172 178 #-------------------------------------------------------------------------------
173 179
174 180 if sys.platform.startswith("win"):
175 181 class TestWinHPCControllerLauncher(ControllerLauncherTest, TestCase):
176 182 launcher_class = launcher.WindowsHPCControllerLauncher
177 183
178 184 class TestWinHPCEngineSetLauncher(EngineSetLauncherTest, TestCase):
179 185 launcher_class = launcher.WindowsHPCEngineSetLauncher
General Comments 0
You need to be logged in to leave comments. Login now